babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4352. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4523. static readonly GEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5302. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5303. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5304. lineProcessor?: (line: string, isFragment: boolean) => string;
  5305. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5306. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. }
  5308. }
  5309. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5310. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5329. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5330. /** @hidden */
  5331. export class ShaderCodeNode {
  5332. line: string;
  5333. children: ShaderCodeNode[];
  5334. additionalDefineKey?: string;
  5335. additionalDefineValue?: string;
  5336. isValid(preprocessors: {
  5337. [key: string]: string;
  5338. }): boolean;
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5345. /** @hidden */
  5346. export class ShaderCodeCursor {
  5347. private _lines;
  5348. lineIndex: number;
  5349. readonly currentLine: string;
  5350. readonly canRead: boolean;
  5351. lines: string[];
  5352. }
  5353. }
  5354. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5355. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5356. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5357. /** @hidden */
  5358. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5359. process(preprocessors: {
  5360. [key: string]: string;
  5361. }, options: ProcessingOptions): string;
  5362. }
  5363. }
  5364. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5365. /** @hidden */
  5366. export class ShaderDefineExpression {
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5373. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5374. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5375. /** @hidden */
  5376. export class ShaderCodeTestNode extends ShaderCodeNode {
  5377. testExpression: ShaderDefineExpression;
  5378. isValid(preprocessors: {
  5379. [key: string]: string;
  5380. }): boolean;
  5381. }
  5382. }
  5383. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5384. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5385. /** @hidden */
  5386. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5387. define: string;
  5388. not: boolean;
  5389. constructor(define: string, not?: boolean);
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5396. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5397. /** @hidden */
  5398. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5399. leftOperand: ShaderDefineExpression;
  5400. rightOperand: ShaderDefineExpression;
  5401. isTrue(preprocessors: {
  5402. [key: string]: string;
  5403. }): boolean;
  5404. }
  5405. }
  5406. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5407. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5408. /** @hidden */
  5409. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5410. leftOperand: ShaderDefineExpression;
  5411. rightOperand: ShaderDefineExpression;
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5418. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5419. /** @hidden */
  5420. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5421. define: string;
  5422. operand: string;
  5423. testValue: string;
  5424. constructor(define: string, operand: string, testValue: string);
  5425. isTrue(preprocessors: {
  5426. [key: string]: string;
  5427. }): boolean;
  5428. }
  5429. }
  5430. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5431. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5432. /** @hidden */
  5433. export class ShaderProcessor {
  5434. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5435. private static _ProcessPrecision;
  5436. private static _ExtractOperation;
  5437. private static _BuildSubExpression;
  5438. private static _BuildExpression;
  5439. private static _MoveCursorWithinIf;
  5440. private static _MoveCursor;
  5441. private static _EvaluatePreProcessors;
  5442. private static _PreparePreProcessors;
  5443. private static _ProcessShaderConversion;
  5444. private static _ProcessIncludes;
  5445. }
  5446. }
  5447. declare module "babylonjs/Misc/performanceMonitor" {
  5448. /**
  5449. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5450. */
  5451. export class PerformanceMonitor {
  5452. private _enabled;
  5453. private _rollingFrameTime;
  5454. private _lastFrameTimeMs;
  5455. /**
  5456. * constructor
  5457. * @param frameSampleSize The number of samples required to saturate the sliding window
  5458. */
  5459. constructor(frameSampleSize?: number);
  5460. /**
  5461. * Samples current frame
  5462. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5463. */
  5464. sampleFrame(timeMs?: number): void;
  5465. /**
  5466. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5467. */
  5468. readonly averageFrameTime: number;
  5469. /**
  5470. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTimeVariance: number;
  5473. /**
  5474. * Returns the frame time of the most recent frame
  5475. */
  5476. readonly instantaneousFrameTime: number;
  5477. /**
  5478. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5479. */
  5480. readonly averageFPS: number;
  5481. /**
  5482. * Returns the average framerate in frames per second using the most recent frame time
  5483. */
  5484. readonly instantaneousFPS: number;
  5485. /**
  5486. * Returns true if enough samples have been taken to completely fill the sliding window
  5487. */
  5488. readonly isSaturated: boolean;
  5489. /**
  5490. * Enables contributions to the sliding window sample set
  5491. */
  5492. enable(): void;
  5493. /**
  5494. * Disables contributions to the sliding window sample set
  5495. * Samples will not be interpolated over the disabled period
  5496. */
  5497. disable(): void;
  5498. /**
  5499. * Returns true if sampling is enabled
  5500. */
  5501. readonly isEnabled: boolean;
  5502. /**
  5503. * Resets performance monitor
  5504. */
  5505. reset(): void;
  5506. }
  5507. /**
  5508. * RollingAverage
  5509. *
  5510. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5511. */
  5512. export class RollingAverage {
  5513. /**
  5514. * Current average
  5515. */
  5516. average: number;
  5517. /**
  5518. * Current variance
  5519. */
  5520. variance: number;
  5521. protected _samples: Array<number>;
  5522. protected _sampleCount: number;
  5523. protected _pos: number;
  5524. protected _m2: number;
  5525. /**
  5526. * constructor
  5527. * @param length The number of samples required to saturate the sliding window
  5528. */
  5529. constructor(length: number);
  5530. /**
  5531. * Adds a sample to the sample set
  5532. * @param v The sample value
  5533. */
  5534. add(v: number): void;
  5535. /**
  5536. * Returns previously added values or null if outside of history or outside the sliding window domain
  5537. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5538. * @return Value previously recorded with add() or null if outside of range
  5539. */
  5540. history(i: number): number;
  5541. /**
  5542. * Returns true if enough samples have been taken to completely fill the sliding window
  5543. * @return true if sample-set saturated
  5544. */
  5545. isSaturated(): boolean;
  5546. /**
  5547. * Resets the rolling average (equivalent to 0 samples taken so far)
  5548. */
  5549. reset(): void;
  5550. /**
  5551. * Wraps a value around the sample range boundaries
  5552. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5553. * @return Wrapped position in sample range
  5554. */
  5555. protected _wrapPosition(i: number): number;
  5556. }
  5557. }
  5558. declare module "babylonjs/Misc/stringDictionary" {
  5559. import { Nullable } from "babylonjs/types";
  5560. /**
  5561. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5562. * The underlying implementation relies on an associative array to ensure the best performances.
  5563. * The value can be anything including 'null' but except 'undefined'
  5564. */
  5565. export class StringDictionary<T> {
  5566. /**
  5567. * This will clear this dictionary and copy the content from the 'source' one.
  5568. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5569. * @param source the dictionary to take the content from and copy to this dictionary
  5570. */
  5571. copyFrom(source: StringDictionary<T>): void;
  5572. /**
  5573. * Get a value based from its key
  5574. * @param key the given key to get the matching value from
  5575. * @return the value if found, otherwise undefined is returned
  5576. */
  5577. get(key: string): T | undefined;
  5578. /**
  5579. * Get a value from its key or add it if it doesn't exist.
  5580. * This method will ensure you that a given key/data will be present in the dictionary.
  5581. * @param key the given key to get the matching value from
  5582. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5583. * The factory will only be invoked if there's no data for the given key.
  5584. * @return the value corresponding to the key.
  5585. */
  5586. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5587. /**
  5588. * Get a value from its key if present in the dictionary otherwise add it
  5589. * @param key the key to get the value from
  5590. * @param val if there's no such key/value pair in the dictionary add it with this value
  5591. * @return the value corresponding to the key
  5592. */
  5593. getOrAdd(key: string, val: T): T;
  5594. /**
  5595. * Check if there's a given key in the dictionary
  5596. * @param key the key to check for
  5597. * @return true if the key is present, false otherwise
  5598. */
  5599. contains(key: string): boolean;
  5600. /**
  5601. * Add a new key and its corresponding value
  5602. * @param key the key to add
  5603. * @param value the value corresponding to the key
  5604. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5605. */
  5606. add(key: string, value: T): boolean;
  5607. /**
  5608. * Update a specific value associated to a key
  5609. * @param key defines the key to use
  5610. * @param value defines the value to store
  5611. * @returns true if the value was updated (or false if the key was not found)
  5612. */
  5613. set(key: string, value: T): boolean;
  5614. /**
  5615. * Get the element of the given key and remove it from the dictionary
  5616. * @param key defines the key to search
  5617. * @returns the value associated with the key or null if not found
  5618. */
  5619. getAndRemove(key: string): Nullable<T>;
  5620. /**
  5621. * Remove a key/value from the dictionary.
  5622. * @param key the key to remove
  5623. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5624. */
  5625. remove(key: string): boolean;
  5626. /**
  5627. * Clear the whole content of the dictionary
  5628. */
  5629. clear(): void;
  5630. /**
  5631. * Gets the current count
  5632. */
  5633. readonly count: number;
  5634. /**
  5635. * Execute a callback on each key/val of the dictionary.
  5636. * Note that you can remove any element in this dictionary in the callback implementation
  5637. * @param callback the callback to execute on a given key/value pair
  5638. */
  5639. forEach(callback: (key: string, val: T) => void): void;
  5640. /**
  5641. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5642. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5643. * Note that you can remove any element in this dictionary in the callback implementation
  5644. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5645. * @returns the first item
  5646. */
  5647. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5648. private _count;
  5649. private _data;
  5650. }
  5651. }
  5652. declare module "babylonjs/Misc/promise" {
  5653. /**
  5654. * Helper class that provides a small promise polyfill
  5655. */
  5656. export class PromisePolyfill {
  5657. /**
  5658. * Static function used to check if the polyfill is required
  5659. * If this is the case then the function will inject the polyfill to window.Promise
  5660. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5661. */
  5662. static Apply(force?: boolean): void;
  5663. }
  5664. }
  5665. declare module "babylonjs/Meshes/buffer" {
  5666. import { Nullable, DataArray } from "babylonjs/types";
  5667. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5668. /**
  5669. * Class used to store data that will be store in GPU memory
  5670. */
  5671. export class Buffer {
  5672. private _engine;
  5673. private _buffer;
  5674. /** @hidden */
  5675. _data: Nullable<DataArray>;
  5676. private _updatable;
  5677. private _instanced;
  5678. /**
  5679. * Gets the byte stride.
  5680. */
  5681. readonly byteStride: number;
  5682. /**
  5683. * Constructor
  5684. * @param engine the engine
  5685. * @param data the data to use for this buffer
  5686. * @param updatable whether the data is updatable
  5687. * @param stride the stride (optional)
  5688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5689. * @param instanced whether the buffer is instanced (optional)
  5690. * @param useBytes set to true if the stride in in bytes (optional)
  5691. */
  5692. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5693. /**
  5694. * Create a new VertexBuffer based on the current buffer
  5695. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5696. * @param offset defines offset in the buffer (0 by default)
  5697. * @param size defines the size in floats of attributes (position is 3 for instance)
  5698. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5699. * @param instanced defines if the vertex buffer contains indexed data
  5700. * @param useBytes defines if the offset and stride are in bytes
  5701. * @returns the new vertex buffer
  5702. */
  5703. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5704. /**
  5705. * Gets a boolean indicating if the Buffer is updatable?
  5706. * @returns true if the buffer is updatable
  5707. */
  5708. isUpdatable(): boolean;
  5709. /**
  5710. * Gets current buffer's data
  5711. * @returns a DataArray or null
  5712. */
  5713. getData(): Nullable<DataArray>;
  5714. /**
  5715. * Gets underlying native buffer
  5716. * @returns underlying native buffer
  5717. */
  5718. getBuffer(): Nullable<DataBuffer>;
  5719. /**
  5720. * Gets the stride in float32 units (i.e. byte stride / 4).
  5721. * May not be an integer if the byte stride is not divisible by 4.
  5722. * DEPRECATED. Use byteStride instead.
  5723. * @returns the stride in float32 units
  5724. */
  5725. getStrideSize(): number;
  5726. /**
  5727. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5728. * @param data defines the data to store
  5729. */
  5730. create(data?: Nullable<DataArray>): void;
  5731. /** @hidden */
  5732. _rebuild(): void;
  5733. /**
  5734. * Update current buffer data
  5735. * @param data defines the data to store
  5736. */
  5737. update(data: DataArray): void;
  5738. /**
  5739. * Updates the data directly.
  5740. * @param data the new data
  5741. * @param offset the new offset
  5742. * @param vertexCount the vertex count (optional)
  5743. * @param useBytes set to true if the offset is in bytes
  5744. */
  5745. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5746. /**
  5747. * Release all resources
  5748. */
  5749. dispose(): void;
  5750. }
  5751. /**
  5752. * Specialized buffer used to store vertex data
  5753. */
  5754. export class VertexBuffer {
  5755. /** @hidden */
  5756. _buffer: Buffer;
  5757. private _kind;
  5758. private _size;
  5759. private _ownsBuffer;
  5760. private _instanced;
  5761. private _instanceDivisor;
  5762. /**
  5763. * The byte type.
  5764. */
  5765. static readonly BYTE: number;
  5766. /**
  5767. * The unsigned byte type.
  5768. */
  5769. static readonly UNSIGNED_BYTE: number;
  5770. /**
  5771. * The short type.
  5772. */
  5773. static readonly SHORT: number;
  5774. /**
  5775. * The unsigned short type.
  5776. */
  5777. static readonly UNSIGNED_SHORT: number;
  5778. /**
  5779. * The integer type.
  5780. */
  5781. static readonly INT: number;
  5782. /**
  5783. * The unsigned integer type.
  5784. */
  5785. static readonly UNSIGNED_INT: number;
  5786. /**
  5787. * The float type.
  5788. */
  5789. static readonly FLOAT: number;
  5790. /**
  5791. * Gets or sets the instance divisor when in instanced mode
  5792. */
  5793. instanceDivisor: number;
  5794. /**
  5795. * Gets the byte stride.
  5796. */
  5797. readonly byteStride: number;
  5798. /**
  5799. * Gets the byte offset.
  5800. */
  5801. readonly byteOffset: number;
  5802. /**
  5803. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5804. */
  5805. readonly normalized: boolean;
  5806. /**
  5807. * Gets the data type of each component in the array.
  5808. */
  5809. readonly type: number;
  5810. /**
  5811. * Constructor
  5812. * @param engine the engine
  5813. * @param data the data to use for this vertex buffer
  5814. * @param kind the vertex buffer kind
  5815. * @param updatable whether the data is updatable
  5816. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5817. * @param stride the stride (optional)
  5818. * @param instanced whether the buffer is instanced (optional)
  5819. * @param offset the offset of the data (optional)
  5820. * @param size the number of components (optional)
  5821. * @param type the type of the component (optional)
  5822. * @param normalized whether the data contains normalized data (optional)
  5823. * @param useBytes set to true if stride and offset are in bytes (optional)
  5824. */
  5825. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5826. /** @hidden */
  5827. _rebuild(): void;
  5828. /**
  5829. * Returns the kind of the VertexBuffer (string)
  5830. * @returns a string
  5831. */
  5832. getKind(): string;
  5833. /**
  5834. * Gets a boolean indicating if the VertexBuffer is updatable?
  5835. * @returns true if the buffer is updatable
  5836. */
  5837. isUpdatable(): boolean;
  5838. /**
  5839. * Gets current buffer's data
  5840. * @returns a DataArray or null
  5841. */
  5842. getData(): Nullable<DataArray>;
  5843. /**
  5844. * Gets underlying native buffer
  5845. * @returns underlying native buffer
  5846. */
  5847. getBuffer(): Nullable<DataBuffer>;
  5848. /**
  5849. * Gets the stride in float32 units (i.e. byte stride / 4).
  5850. * May not be an integer if the byte stride is not divisible by 4.
  5851. * DEPRECATED. Use byteStride instead.
  5852. * @returns the stride in float32 units
  5853. */
  5854. getStrideSize(): number;
  5855. /**
  5856. * Returns the offset as a multiple of the type byte length.
  5857. * DEPRECATED. Use byteOffset instead.
  5858. * @returns the offset in bytes
  5859. */
  5860. getOffset(): number;
  5861. /**
  5862. * Returns the number of components per vertex attribute (integer)
  5863. * @returns the size in float
  5864. */
  5865. getSize(): number;
  5866. /**
  5867. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5868. * @returns true if this buffer is instanced
  5869. */
  5870. getIsInstanced(): boolean;
  5871. /**
  5872. * Returns the instancing divisor, zero for non-instanced (integer).
  5873. * @returns a number
  5874. */
  5875. getInstanceDivisor(): number;
  5876. /**
  5877. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5878. * @param data defines the data to store
  5879. */
  5880. create(data?: DataArray): void;
  5881. /**
  5882. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5883. * This function will create a new buffer if the current one is not updatable
  5884. * @param data defines the data to store
  5885. */
  5886. update(data: DataArray): void;
  5887. /**
  5888. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5889. * Returns the directly updated WebGLBuffer.
  5890. * @param data the new data
  5891. * @param offset the new offset
  5892. * @param useBytes set to true if the offset is in bytes
  5893. */
  5894. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5895. /**
  5896. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5897. */
  5898. dispose(): void;
  5899. /**
  5900. * Enumerates each value of this vertex buffer as numbers.
  5901. * @param count the number of values to enumerate
  5902. * @param callback the callback function called for each value
  5903. */
  5904. forEach(count: number, callback: (value: number, index: number) => void): void;
  5905. /**
  5906. * Positions
  5907. */
  5908. static readonly PositionKind: string;
  5909. /**
  5910. * Normals
  5911. */
  5912. static readonly NormalKind: string;
  5913. /**
  5914. * Tangents
  5915. */
  5916. static readonly TangentKind: string;
  5917. /**
  5918. * Texture coordinates
  5919. */
  5920. static readonly UVKind: string;
  5921. /**
  5922. * Texture coordinates 2
  5923. */
  5924. static readonly UV2Kind: string;
  5925. /**
  5926. * Texture coordinates 3
  5927. */
  5928. static readonly UV3Kind: string;
  5929. /**
  5930. * Texture coordinates 4
  5931. */
  5932. static readonly UV4Kind: string;
  5933. /**
  5934. * Texture coordinates 5
  5935. */
  5936. static readonly UV5Kind: string;
  5937. /**
  5938. * Texture coordinates 6
  5939. */
  5940. static readonly UV6Kind: string;
  5941. /**
  5942. * Colors
  5943. */
  5944. static readonly ColorKind: string;
  5945. /**
  5946. * Matrix indices (for bones)
  5947. */
  5948. static readonly MatricesIndicesKind: string;
  5949. /**
  5950. * Matrix weights (for bones)
  5951. */
  5952. static readonly MatricesWeightsKind: string;
  5953. /**
  5954. * Additional matrix indices (for bones)
  5955. */
  5956. static readonly MatricesIndicesExtraKind: string;
  5957. /**
  5958. * Additional matrix weights (for bones)
  5959. */
  5960. static readonly MatricesWeightsExtraKind: string;
  5961. /**
  5962. * Deduces the stride given a kind.
  5963. * @param kind The kind string to deduce
  5964. * @returns The deduced stride
  5965. */
  5966. static DeduceStride(kind: string): number;
  5967. /**
  5968. * Gets the byte length of the given type.
  5969. * @param type the type
  5970. * @returns the number of bytes
  5971. */
  5972. static GetTypeByteLength(type: number): number;
  5973. /**
  5974. * Enumerates each value of the given parameters as numbers.
  5975. * @param data the data to enumerate
  5976. * @param byteOffset the byte offset of the data
  5977. * @param byteStride the byte stride of the data
  5978. * @param componentCount the number of components per element
  5979. * @param componentType the type of the component
  5980. * @param count the total number of components
  5981. * @param normalized whether the data is normalized
  5982. * @param callback the callback function called for each value
  5983. */
  5984. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5985. private static _GetFloatValue;
  5986. }
  5987. }
  5988. declare module "babylonjs/Maths/sphericalPolynomial" {
  5989. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5990. /**
  5991. * Class representing spherical harmonics coefficients to the 3rd degree
  5992. */
  5993. export class SphericalHarmonics {
  5994. /**
  5995. * Defines whether or not the harmonics have been prescaled for rendering.
  5996. */
  5997. preScaled: boolean;
  5998. /**
  5999. * The l0,0 coefficients of the spherical harmonics
  6000. */
  6001. l00: Vector3;
  6002. /**
  6003. * The l1,-1 coefficients of the spherical harmonics
  6004. */
  6005. l1_1: Vector3;
  6006. /**
  6007. * The l1,0 coefficients of the spherical harmonics
  6008. */
  6009. l10: Vector3;
  6010. /**
  6011. * The l1,1 coefficients of the spherical harmonics
  6012. */
  6013. l11: Vector3;
  6014. /**
  6015. * The l2,-2 coefficients of the spherical harmonics
  6016. */
  6017. l2_2: Vector3;
  6018. /**
  6019. * The l2,-1 coefficients of the spherical harmonics
  6020. */
  6021. l2_1: Vector3;
  6022. /**
  6023. * The l2,0 coefficients of the spherical harmonics
  6024. */
  6025. l20: Vector3;
  6026. /**
  6027. * The l2,1 coefficients of the spherical harmonics
  6028. */
  6029. l21: Vector3;
  6030. /**
  6031. * The l2,2 coefficients of the spherical harmonics
  6032. */
  6033. l22: Vector3;
  6034. /**
  6035. * Adds a light to the spherical harmonics
  6036. * @param direction the direction of the light
  6037. * @param color the color of the light
  6038. * @param deltaSolidAngle the delta solid angle of the light
  6039. */
  6040. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6041. /**
  6042. * Scales the spherical harmonics by the given amount
  6043. * @param scale the amount to scale
  6044. */
  6045. scaleInPlace(scale: number): void;
  6046. /**
  6047. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6048. *
  6049. * ```
  6050. * E_lm = A_l * L_lm
  6051. * ```
  6052. *
  6053. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6054. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6055. * the scaling factors are given in equation 9.
  6056. */
  6057. convertIncidentRadianceToIrradiance(): void;
  6058. /**
  6059. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6060. *
  6061. * ```
  6062. * L = (1/pi) * E * rho
  6063. * ```
  6064. *
  6065. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6066. */
  6067. convertIrradianceToLambertianRadiance(): void;
  6068. /**
  6069. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6070. * required operations at run time.
  6071. *
  6072. * This is simply done by scaling back the SH with Ylm constants parameter.
  6073. * The trigonometric part being applied by the shader at run time.
  6074. */
  6075. preScaleForRendering(): void;
  6076. /**
  6077. * Constructs a spherical harmonics from an array.
  6078. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6079. * @returns the spherical harmonics
  6080. */
  6081. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6082. /**
  6083. * Gets the spherical harmonics from polynomial
  6084. * @param polynomial the spherical polynomial
  6085. * @returns the spherical harmonics
  6086. */
  6087. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6088. }
  6089. /**
  6090. * Class representing spherical polynomial coefficients to the 3rd degree
  6091. */
  6092. export class SphericalPolynomial {
  6093. private _harmonics;
  6094. /**
  6095. * The spherical harmonics used to create the polynomials.
  6096. */
  6097. readonly preScaledHarmonics: SphericalHarmonics;
  6098. /**
  6099. * The x coefficients of the spherical polynomial
  6100. */
  6101. x: Vector3;
  6102. /**
  6103. * The y coefficients of the spherical polynomial
  6104. */
  6105. y: Vector3;
  6106. /**
  6107. * The z coefficients of the spherical polynomial
  6108. */
  6109. z: Vector3;
  6110. /**
  6111. * The xx coefficients of the spherical polynomial
  6112. */
  6113. xx: Vector3;
  6114. /**
  6115. * The yy coefficients of the spherical polynomial
  6116. */
  6117. yy: Vector3;
  6118. /**
  6119. * The zz coefficients of the spherical polynomial
  6120. */
  6121. zz: Vector3;
  6122. /**
  6123. * The xy coefficients of the spherical polynomial
  6124. */
  6125. xy: Vector3;
  6126. /**
  6127. * The yz coefficients of the spherical polynomial
  6128. */
  6129. yz: Vector3;
  6130. /**
  6131. * The zx coefficients of the spherical polynomial
  6132. */
  6133. zx: Vector3;
  6134. /**
  6135. * Adds an ambient color to the spherical polynomial
  6136. * @param color the color to add
  6137. */
  6138. addAmbient(color: Color3): void;
  6139. /**
  6140. * Scales the spherical polynomial by the given amount
  6141. * @param scale the amount to scale
  6142. */
  6143. scaleInPlace(scale: number): void;
  6144. /**
  6145. * Gets the spherical polynomial from harmonics
  6146. * @param harmonics the spherical harmonics
  6147. * @returns the spherical polynomial
  6148. */
  6149. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6150. /**
  6151. * Constructs a spherical polynomial from an array.
  6152. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6153. * @returns the spherical polynomial
  6154. */
  6155. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6156. }
  6157. }
  6158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6159. import { Nullable } from "babylonjs/types";
  6160. /**
  6161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6162. */
  6163. export interface CubeMapInfo {
  6164. /**
  6165. * The pixel array for the front face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. front: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the back face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. back: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the left face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. left: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the right face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. right: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the up face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. up: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The pixel array for the down face.
  6191. * This is stored in format, left to right, up to down format.
  6192. */
  6193. down: Nullable<ArrayBufferView>;
  6194. /**
  6195. * The size of the cubemap stored.
  6196. *
  6197. * Each faces will be size * size pixels.
  6198. */
  6199. size: number;
  6200. /**
  6201. * The format of the texture.
  6202. *
  6203. * RGBA, RGB.
  6204. */
  6205. format: number;
  6206. /**
  6207. * The type of the texture data.
  6208. *
  6209. * UNSIGNED_INT, FLOAT.
  6210. */
  6211. type: number;
  6212. /**
  6213. * Specifies whether the texture is in gamma space.
  6214. */
  6215. gammaSpace: boolean;
  6216. }
  6217. /**
  6218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6219. */
  6220. export class PanoramaToCubeMapTools {
  6221. private static FACE_FRONT;
  6222. private static FACE_BACK;
  6223. private static FACE_RIGHT;
  6224. private static FACE_LEFT;
  6225. private static FACE_DOWN;
  6226. private static FACE_UP;
  6227. /**
  6228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6229. *
  6230. * @param float32Array The source data.
  6231. * @param inputWidth The width of the input panorama.
  6232. * @param inputHeight The height of the input panorama.
  6233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6234. * @return The cubemap data
  6235. */
  6236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6237. private static CreateCubemapTexture;
  6238. private static CalcProjectionSpherical;
  6239. }
  6240. }
  6241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6245. /**
  6246. * Helper class dealing with the extraction of spherical polynomial dataArray
  6247. * from a cube map.
  6248. */
  6249. export class CubeMapToSphericalPolynomialTools {
  6250. private static FileFaces;
  6251. /**
  6252. * Converts a texture to the according Spherical Polynomial data.
  6253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6254. *
  6255. * @param texture The texture to extract the information from.
  6256. * @return The Spherical Polynomial data.
  6257. */
  6258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6259. /**
  6260. * Converts a cubemap to the according Spherical Polynomial data.
  6261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6262. *
  6263. * @param cubeInfo The Cube map to extract the information from.
  6264. * @return The Spherical Polynomial data.
  6265. */
  6266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6267. }
  6268. }
  6269. declare module "babylonjs/Engines/engineStore" {
  6270. import { Nullable } from "babylonjs/types";
  6271. import { Engine } from "babylonjs/Engines/engine";
  6272. import { Scene } from "babylonjs/scene";
  6273. /**
  6274. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6275. * during the life time of the application.
  6276. */
  6277. export class EngineStore {
  6278. /** Gets the list of created engines */
  6279. static Instances: import("babylonjs/Engines/engine").Engine[];
  6280. /** @hidden */
  6281. static _LastCreatedScene: Nullable<Scene>;
  6282. /**
  6283. * Gets the latest created engine
  6284. */
  6285. static readonly LastCreatedEngine: Nullable<Engine>;
  6286. /**
  6287. * Gets the latest created scene
  6288. */
  6289. static readonly LastCreatedScene: Nullable<Scene>;
  6290. }
  6291. }
  6292. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6293. /**
  6294. * Define options used to create a render target texture
  6295. */
  6296. export class RenderTargetCreationOptions {
  6297. /**
  6298. * Specifies is mipmaps must be generated
  6299. */
  6300. generateMipMaps?: boolean;
  6301. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6302. generateDepthBuffer?: boolean;
  6303. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6304. generateStencilBuffer?: boolean;
  6305. /** Defines texture type (int by default) */
  6306. type?: number;
  6307. /** Defines sampling mode (trilinear by default) */
  6308. samplingMode?: number;
  6309. /** Defines format (RGBA by default) */
  6310. format?: number;
  6311. }
  6312. }
  6313. declare module "babylonjs/States/alphaCullingState" {
  6314. /**
  6315. * @hidden
  6316. **/
  6317. export class _AlphaState {
  6318. private _isAlphaBlendDirty;
  6319. private _isBlendFunctionParametersDirty;
  6320. private _isBlendEquationParametersDirty;
  6321. private _isBlendConstantsDirty;
  6322. private _alphaBlend;
  6323. private _blendFunctionParameters;
  6324. private _blendEquationParameters;
  6325. private _blendConstants;
  6326. /**
  6327. * Initializes the state.
  6328. */
  6329. constructor();
  6330. readonly isDirty: boolean;
  6331. alphaBlend: boolean;
  6332. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6333. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6334. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6335. reset(): void;
  6336. apply(gl: WebGLRenderingContext): void;
  6337. }
  6338. }
  6339. declare module "babylonjs/States/depthCullingState" {
  6340. import { Nullable } from "babylonjs/types";
  6341. /**
  6342. * @hidden
  6343. **/
  6344. export class _DepthCullingState {
  6345. private _isDepthTestDirty;
  6346. private _isDepthMaskDirty;
  6347. private _isDepthFuncDirty;
  6348. private _isCullFaceDirty;
  6349. private _isCullDirty;
  6350. private _isZOffsetDirty;
  6351. private _isFrontFaceDirty;
  6352. private _depthTest;
  6353. private _depthMask;
  6354. private _depthFunc;
  6355. private _cull;
  6356. private _cullFace;
  6357. private _zOffset;
  6358. private _frontFace;
  6359. /**
  6360. * Initializes the state.
  6361. */
  6362. constructor();
  6363. readonly isDirty: boolean;
  6364. zOffset: number;
  6365. cullFace: Nullable<number>;
  6366. cull: Nullable<boolean>;
  6367. depthFunc: Nullable<number>;
  6368. depthMask: boolean;
  6369. depthTest: boolean;
  6370. frontFace: Nullable<number>;
  6371. reset(): void;
  6372. apply(gl: WebGLRenderingContext): void;
  6373. }
  6374. }
  6375. declare module "babylonjs/States/stencilState" {
  6376. /**
  6377. * @hidden
  6378. **/
  6379. export class _StencilState {
  6380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6381. static readonly ALWAYS: number;
  6382. /** Passed to stencilOperation to specify that stencil value must be kept */
  6383. static readonly KEEP: number;
  6384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6385. static readonly REPLACE: number;
  6386. private _isStencilTestDirty;
  6387. private _isStencilMaskDirty;
  6388. private _isStencilFuncDirty;
  6389. private _isStencilOpDirty;
  6390. private _stencilTest;
  6391. private _stencilMask;
  6392. private _stencilFunc;
  6393. private _stencilFuncRef;
  6394. private _stencilFuncMask;
  6395. private _stencilOpStencilFail;
  6396. private _stencilOpDepthFail;
  6397. private _stencilOpStencilDepthPass;
  6398. readonly isDirty: boolean;
  6399. stencilFunc: number;
  6400. stencilFuncRef: number;
  6401. stencilFuncMask: number;
  6402. stencilOpStencilFail: number;
  6403. stencilOpDepthFail: number;
  6404. stencilOpStencilDepthPass: number;
  6405. stencilMask: number;
  6406. stencilTest: boolean;
  6407. constructor();
  6408. reset(): void;
  6409. apply(gl: WebGLRenderingContext): void;
  6410. }
  6411. }
  6412. declare module "babylonjs/States/index" {
  6413. export * from "babylonjs/States/alphaCullingState";
  6414. export * from "babylonjs/States/depthCullingState";
  6415. export * from "babylonjs/States/stencilState";
  6416. }
  6417. declare module "babylonjs/Instrumentation/timeToken" {
  6418. import { Nullable } from "babylonjs/types";
  6419. /**
  6420. * @hidden
  6421. **/
  6422. export class _TimeToken {
  6423. _startTimeQuery: Nullable<WebGLQuery>;
  6424. _endTimeQuery: Nullable<WebGLQuery>;
  6425. _timeElapsedQuery: Nullable<WebGLQuery>;
  6426. _timeElapsedQueryEnded: boolean;
  6427. }
  6428. }
  6429. declare module "babylonjs/Materials/Textures/internalTexture" {
  6430. import { Observable } from "babylonjs/Misc/observable";
  6431. import { Nullable, int } from "babylonjs/types";
  6432. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6433. import { Engine } from "babylonjs/Engines/engine";
  6434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6435. /**
  6436. * Class used to store data associated with WebGL texture data for the engine
  6437. * This class should not be used directly
  6438. */
  6439. export class InternalTexture {
  6440. /** @hidden */
  6441. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6442. /**
  6443. * The source of the texture data is unknown
  6444. */
  6445. static DATASOURCE_UNKNOWN: number;
  6446. /**
  6447. * Texture data comes from an URL
  6448. */
  6449. static DATASOURCE_URL: number;
  6450. /**
  6451. * Texture data is only used for temporary storage
  6452. */
  6453. static DATASOURCE_TEMP: number;
  6454. /**
  6455. * Texture data comes from raw data (ArrayBuffer)
  6456. */
  6457. static DATASOURCE_RAW: number;
  6458. /**
  6459. * Texture content is dynamic (video or dynamic texture)
  6460. */
  6461. static DATASOURCE_DYNAMIC: number;
  6462. /**
  6463. * Texture content is generated by rendering to it
  6464. */
  6465. static DATASOURCE_RENDERTARGET: number;
  6466. /**
  6467. * Texture content is part of a multi render target process
  6468. */
  6469. static DATASOURCE_MULTIRENDERTARGET: number;
  6470. /**
  6471. * Texture data comes from a cube data file
  6472. */
  6473. static DATASOURCE_CUBE: number;
  6474. /**
  6475. * Texture data comes from a raw cube data
  6476. */
  6477. static DATASOURCE_CUBERAW: number;
  6478. /**
  6479. * Texture data come from a prefiltered cube data file
  6480. */
  6481. static DATASOURCE_CUBEPREFILTERED: number;
  6482. /**
  6483. * Texture content is raw 3D data
  6484. */
  6485. static DATASOURCE_RAW3D: number;
  6486. /**
  6487. * Texture content is a depth texture
  6488. */
  6489. static DATASOURCE_DEPTHTEXTURE: number;
  6490. /**
  6491. * Texture data comes from a raw cube data encoded with RGBD
  6492. */
  6493. static DATASOURCE_CUBERAW_RGBD: number;
  6494. /**
  6495. * Defines if the texture is ready
  6496. */
  6497. isReady: boolean;
  6498. /**
  6499. * Defines if the texture is a cube texture
  6500. */
  6501. isCube: boolean;
  6502. /**
  6503. * Defines if the texture contains 3D data
  6504. */
  6505. is3D: boolean;
  6506. /**
  6507. * Defines if the texture contains multiview data
  6508. */
  6509. isMultiview: boolean;
  6510. /**
  6511. * Gets the URL used to load this texture
  6512. */
  6513. url: string;
  6514. /**
  6515. * Gets the sampling mode of the texture
  6516. */
  6517. samplingMode: number;
  6518. /**
  6519. * Gets a boolean indicating if the texture needs mipmaps generation
  6520. */
  6521. generateMipMaps: boolean;
  6522. /**
  6523. * Gets the number of samples used by the texture (WebGL2+ only)
  6524. */
  6525. samples: number;
  6526. /**
  6527. * Gets the type of the texture (int, float...)
  6528. */
  6529. type: number;
  6530. /**
  6531. * Gets the format of the texture (RGB, RGBA...)
  6532. */
  6533. format: number;
  6534. /**
  6535. * Observable called when the texture is loaded
  6536. */
  6537. onLoadedObservable: Observable<InternalTexture>;
  6538. /**
  6539. * Gets the width of the texture
  6540. */
  6541. width: number;
  6542. /**
  6543. * Gets the height of the texture
  6544. */
  6545. height: number;
  6546. /**
  6547. * Gets the depth of the texture
  6548. */
  6549. depth: number;
  6550. /**
  6551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6552. */
  6553. baseWidth: number;
  6554. /**
  6555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseHeight: number;
  6558. /**
  6559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseDepth: number;
  6562. /**
  6563. * Gets a boolean indicating if the texture is inverted on Y axis
  6564. */
  6565. invertY: boolean;
  6566. /** @hidden */
  6567. _invertVScale: boolean;
  6568. /** @hidden */
  6569. _associatedChannel: number;
  6570. /** @hidden */
  6571. _dataSource: number;
  6572. /** @hidden */
  6573. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6574. /** @hidden */
  6575. _bufferView: Nullable<ArrayBufferView>;
  6576. /** @hidden */
  6577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6578. /** @hidden */
  6579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6580. /** @hidden */
  6581. _size: number;
  6582. /** @hidden */
  6583. _extension: string;
  6584. /** @hidden */
  6585. _files: Nullable<string[]>;
  6586. /** @hidden */
  6587. _workingCanvas: Nullable<HTMLCanvasElement>;
  6588. /** @hidden */
  6589. _workingContext: Nullable<CanvasRenderingContext2D>;
  6590. /** @hidden */
  6591. _framebuffer: Nullable<WebGLFramebuffer>;
  6592. /** @hidden */
  6593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6594. /** @hidden */
  6595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _attachments: Nullable<number[]>;
  6600. /** @hidden */
  6601. _cachedCoordinatesMode: Nullable<number>;
  6602. /** @hidden */
  6603. _cachedWrapU: Nullable<number>;
  6604. /** @hidden */
  6605. _cachedWrapV: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapR: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6610. /** @hidden */
  6611. _isDisabled: boolean;
  6612. /** @hidden */
  6613. _compression: Nullable<string>;
  6614. /** @hidden */
  6615. _generateStencilBuffer: boolean;
  6616. /** @hidden */
  6617. _generateDepthBuffer: boolean;
  6618. /** @hidden */
  6619. _comparisonFunction: number;
  6620. /** @hidden */
  6621. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6622. /** @hidden */
  6623. _lodGenerationScale: number;
  6624. /** @hidden */
  6625. _lodGenerationOffset: number;
  6626. /** @hidden */
  6627. _colorTextureArray: Nullable<WebGLTexture>;
  6628. /** @hidden */
  6629. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6630. /** @hidden */
  6631. _lodTextureHigh: Nullable<BaseTexture>;
  6632. /** @hidden */
  6633. _lodTextureMid: Nullable<BaseTexture>;
  6634. /** @hidden */
  6635. _lodTextureLow: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _isRGBD: boolean;
  6638. /** @hidden */
  6639. _linearSpecularLOD: boolean;
  6640. /** @hidden */
  6641. _irradianceTexture: Nullable<BaseTexture>;
  6642. /** @hidden */
  6643. _webGLTexture: Nullable<WebGLTexture>;
  6644. /** @hidden */
  6645. _references: number;
  6646. private _engine;
  6647. /**
  6648. * Gets the Engine the texture belongs to.
  6649. * @returns The babylon engine
  6650. */
  6651. getEngine(): Engine;
  6652. /**
  6653. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6654. */
  6655. readonly dataSource: number;
  6656. /**
  6657. * Creates a new InternalTexture
  6658. * @param engine defines the engine to use
  6659. * @param dataSource defines the type of data that will be used
  6660. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6661. */
  6662. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6663. /**
  6664. * Increments the number of references (ie. the number of Texture that point to it)
  6665. */
  6666. incrementReferences(): void;
  6667. /**
  6668. * Change the size of the texture (not the size of the content)
  6669. * @param width defines the new width
  6670. * @param height defines the new height
  6671. * @param depth defines the new depth (1 by default)
  6672. */
  6673. updateSize(width: int, height: int, depth?: int): void;
  6674. /** @hidden */
  6675. _rebuild(): void;
  6676. /** @hidden */
  6677. _swapAndDie(target: InternalTexture): void;
  6678. /**
  6679. * Dispose the current allocated resources
  6680. */
  6681. dispose(): void;
  6682. }
  6683. }
  6684. declare module "babylonjs/Animations/easing" {
  6685. /**
  6686. * This represents the main contract an easing function should follow.
  6687. * Easing functions are used throughout the animation system.
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export interface IEasingFunction {
  6691. /**
  6692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6693. * of the easing function.
  6694. * The link below provides some of the most common examples of easing functions.
  6695. * @see https://easings.net/
  6696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6697. * @returns the corresponding value on the curve defined by the easing function
  6698. */
  6699. ease(gradient: number): number;
  6700. }
  6701. /**
  6702. * Base class used for every default easing function.
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class EasingFunction implements IEasingFunction {
  6706. /**
  6707. * Interpolation follows the mathematical formula associated with the easing function.
  6708. */
  6709. static readonly EASINGMODE_EASEIN: number;
  6710. /**
  6711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEOUT: number;
  6714. /**
  6715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6716. */
  6717. static readonly EASINGMODE_EASEINOUT: number;
  6718. private _easingMode;
  6719. /**
  6720. * Sets the easing mode of the current function.
  6721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6722. */
  6723. setEasingMode(easingMode: number): void;
  6724. /**
  6725. * Gets the current easing mode.
  6726. * @returns the easing mode
  6727. */
  6728. getEasingMode(): number;
  6729. /**
  6730. * @hidden
  6731. */
  6732. easeInCore(gradient: number): number;
  6733. /**
  6734. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6735. * of the easing function.
  6736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6737. * @returns the corresponding value on the curve defined by the easing function
  6738. */
  6739. ease(gradient: number): number;
  6740. }
  6741. /**
  6742. * Easing function with a circle shape (see link below).
  6743. * @see https://easings.net/#easeInCirc
  6744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6745. */
  6746. export class CircleEase extends EasingFunction implements IEasingFunction {
  6747. /** @hidden */
  6748. easeInCore(gradient: number): number;
  6749. }
  6750. /**
  6751. * Easing function with a ease back shape (see link below).
  6752. * @see https://easings.net/#easeInBack
  6753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6754. */
  6755. export class BackEase extends EasingFunction implements IEasingFunction {
  6756. /** Defines the amplitude of the function */
  6757. amplitude: number;
  6758. /**
  6759. * Instantiates a back ease easing
  6760. * @see https://easings.net/#easeInBack
  6761. * @param amplitude Defines the amplitude of the function
  6762. */
  6763. constructor(
  6764. /** Defines the amplitude of the function */
  6765. amplitude?: number);
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with a bouncing shape (see link below).
  6771. * @see https://easings.net/#easeInBounce
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class BounceEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of bounces */
  6776. bounces: number;
  6777. /** Defines the amplitude of the bounce */
  6778. bounciness: number;
  6779. /**
  6780. * Instantiates a bounce easing
  6781. * @see https://easings.net/#easeInBounce
  6782. * @param bounces Defines the number of bounces
  6783. * @param bounciness Defines the amplitude of the bounce
  6784. */
  6785. constructor(
  6786. /** Defines the number of bounces */
  6787. bounces?: number,
  6788. /** Defines the amplitude of the bounce */
  6789. bounciness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with a power of 3 shape (see link below).
  6795. * @see https://easings.net/#easeInCubic
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class CubicEase extends EasingFunction implements IEasingFunction {
  6799. /** @hidden */
  6800. easeInCore(gradient: number): number;
  6801. }
  6802. /**
  6803. * Easing function with an elastic shape (see link below).
  6804. * @see https://easings.net/#easeInElastic
  6805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6806. */
  6807. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6808. /** Defines the number of oscillations*/
  6809. oscillations: number;
  6810. /** Defines the amplitude of the oscillations*/
  6811. springiness: number;
  6812. /**
  6813. * Instantiates an elastic easing function
  6814. * @see https://easings.net/#easeInElastic
  6815. * @param oscillations Defines the number of oscillations
  6816. * @param springiness Defines the amplitude of the oscillations
  6817. */
  6818. constructor(
  6819. /** Defines the number of oscillations*/
  6820. oscillations?: number,
  6821. /** Defines the amplitude of the oscillations*/
  6822. springiness?: number);
  6823. /** @hidden */
  6824. easeInCore(gradient: number): number;
  6825. }
  6826. /**
  6827. * Easing function with an exponential shape (see link below).
  6828. * @see https://easings.net/#easeInExpo
  6829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6830. */
  6831. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6832. /** Defines the exponent of the function */
  6833. exponent: number;
  6834. /**
  6835. * Instantiates an exponential easing function
  6836. * @see https://easings.net/#easeInExpo
  6837. * @param exponent Defines the exponent of the function
  6838. */
  6839. constructor(
  6840. /** Defines the exponent of the function */
  6841. exponent?: number);
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power shape (see link below).
  6847. * @see https://easings.net/#easeInQuad
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class PowerEase extends EasingFunction implements IEasingFunction {
  6851. /** Defines the power of the function */
  6852. power: number;
  6853. /**
  6854. * Instantiates an power base easing function
  6855. * @see https://easings.net/#easeInQuad
  6856. * @param power Defines the power of the function
  6857. */
  6858. constructor(
  6859. /** Defines the power of the function */
  6860. power?: number);
  6861. /** @hidden */
  6862. easeInCore(gradient: number): number;
  6863. }
  6864. /**
  6865. * Easing function with a power of 2 shape (see link below).
  6866. * @see https://easings.net/#easeInQuad
  6867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6868. */
  6869. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6870. /** @hidden */
  6871. easeInCore(gradient: number): number;
  6872. }
  6873. /**
  6874. * Easing function with a power of 4 shape (see link below).
  6875. * @see https://easings.net/#easeInQuart
  6876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6877. */
  6878. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6879. /** @hidden */
  6880. easeInCore(gradient: number): number;
  6881. }
  6882. /**
  6883. * Easing function with a power of 5 shape (see link below).
  6884. * @see https://easings.net/#easeInQuint
  6885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6886. */
  6887. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6888. /** @hidden */
  6889. easeInCore(gradient: number): number;
  6890. }
  6891. /**
  6892. * Easing function with a sin shape (see link below).
  6893. * @see https://easings.net/#easeInSine
  6894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6895. */
  6896. export class SineEase extends EasingFunction implements IEasingFunction {
  6897. /** @hidden */
  6898. easeInCore(gradient: number): number;
  6899. }
  6900. /**
  6901. * Easing function with a bezier shape (see link below).
  6902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6904. */
  6905. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6906. /** Defines the x component of the start tangent in the bezier curve */
  6907. x1: number;
  6908. /** Defines the y component of the start tangent in the bezier curve */
  6909. y1: number;
  6910. /** Defines the x component of the end tangent in the bezier curve */
  6911. x2: number;
  6912. /** Defines the y component of the end tangent in the bezier curve */
  6913. y2: number;
  6914. /**
  6915. * Instantiates a bezier function
  6916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6917. * @param x1 Defines the x component of the start tangent in the bezier curve
  6918. * @param y1 Defines the y component of the start tangent in the bezier curve
  6919. * @param x2 Defines the x component of the end tangent in the bezier curve
  6920. * @param y2 Defines the y component of the end tangent in the bezier curve
  6921. */
  6922. constructor(
  6923. /** Defines the x component of the start tangent in the bezier curve */
  6924. x1?: number,
  6925. /** Defines the y component of the start tangent in the bezier curve */
  6926. y1?: number,
  6927. /** Defines the x component of the end tangent in the bezier curve */
  6928. x2?: number,
  6929. /** Defines the y component of the end tangent in the bezier curve */
  6930. y2?: number);
  6931. /** @hidden */
  6932. easeInCore(gradient: number): number;
  6933. }
  6934. }
  6935. declare module "babylonjs/Animations/animationKey" {
  6936. /**
  6937. * Defines an interface which represents an animation key frame
  6938. */
  6939. export interface IAnimationKey {
  6940. /**
  6941. * Frame of the key frame
  6942. */
  6943. frame: number;
  6944. /**
  6945. * Value at the specifies key frame
  6946. */
  6947. value: any;
  6948. /**
  6949. * The input tangent for the cubic hermite spline
  6950. */
  6951. inTangent?: any;
  6952. /**
  6953. * The output tangent for the cubic hermite spline
  6954. */
  6955. outTangent?: any;
  6956. /**
  6957. * The animation interpolation type
  6958. */
  6959. interpolation?: AnimationKeyInterpolation;
  6960. }
  6961. /**
  6962. * Enum for the animation key frame interpolation type
  6963. */
  6964. export enum AnimationKeyInterpolation {
  6965. /**
  6966. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6967. */
  6968. STEP = 1
  6969. }
  6970. }
  6971. declare module "babylonjs/Animations/animationRange" {
  6972. /**
  6973. * Represents the range of an animation
  6974. */
  6975. export class AnimationRange {
  6976. /**The name of the animation range**/
  6977. name: string;
  6978. /**The starting frame of the animation */
  6979. from: number;
  6980. /**The ending frame of the animation*/
  6981. to: number;
  6982. /**
  6983. * Initializes the range of an animation
  6984. * @param name The name of the animation range
  6985. * @param from The starting frame of the animation
  6986. * @param to The ending frame of the animation
  6987. */
  6988. constructor(
  6989. /**The name of the animation range**/
  6990. name: string,
  6991. /**The starting frame of the animation */
  6992. from: number,
  6993. /**The ending frame of the animation*/
  6994. to: number);
  6995. /**
  6996. * Makes a copy of the animation range
  6997. * @returns A copy of the animation range
  6998. */
  6999. clone(): AnimationRange;
  7000. }
  7001. }
  7002. declare module "babylonjs/Animations/animationEvent" {
  7003. /**
  7004. * Composed of a frame, and an action function
  7005. */
  7006. export class AnimationEvent {
  7007. /** The frame for which the event is triggered **/
  7008. frame: number;
  7009. /** The event to perform when triggered **/
  7010. action: (currentFrame: number) => void;
  7011. /** Specifies if the event should be triggered only once**/
  7012. onlyOnce?: boolean | undefined;
  7013. /**
  7014. * Specifies if the animation event is done
  7015. */
  7016. isDone: boolean;
  7017. /**
  7018. * Initializes the animation event
  7019. * @param frame The frame for which the event is triggered
  7020. * @param action The event to perform when triggered
  7021. * @param onlyOnce Specifies if the event should be triggered only once
  7022. */
  7023. constructor(
  7024. /** The frame for which the event is triggered **/
  7025. frame: number,
  7026. /** The event to perform when triggered **/
  7027. action: (currentFrame: number) => void,
  7028. /** Specifies if the event should be triggered only once**/
  7029. onlyOnce?: boolean | undefined);
  7030. /** @hidden */
  7031. _clone(): AnimationEvent;
  7032. }
  7033. }
  7034. declare module "babylonjs/Behaviors/behavior" {
  7035. import { Nullable } from "babylonjs/types";
  7036. /**
  7037. * Interface used to define a behavior
  7038. */
  7039. export interface Behavior<T> {
  7040. /** gets or sets behavior's name */
  7041. name: string;
  7042. /**
  7043. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7044. */
  7045. init(): void;
  7046. /**
  7047. * Called when the behavior is attached to a target
  7048. * @param target defines the target where the behavior is attached to
  7049. */
  7050. attach(target: T): void;
  7051. /**
  7052. * Called when the behavior is detached from its target
  7053. */
  7054. detach(): void;
  7055. }
  7056. /**
  7057. * Interface implemented by classes supporting behaviors
  7058. */
  7059. export interface IBehaviorAware<T> {
  7060. /**
  7061. * Attach a behavior
  7062. * @param behavior defines the behavior to attach
  7063. * @returns the current host
  7064. */
  7065. addBehavior(behavior: Behavior<T>): T;
  7066. /**
  7067. * Remove a behavior from the current object
  7068. * @param behavior defines the behavior to detach
  7069. * @returns the current host
  7070. */
  7071. removeBehavior(behavior: Behavior<T>): T;
  7072. /**
  7073. * Gets a behavior using its name to search
  7074. * @param name defines the name to search
  7075. * @returns the behavior or null if not found
  7076. */
  7077. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7078. }
  7079. }
  7080. declare module "babylonjs/Collisions/intersectionInfo" {
  7081. import { Nullable } from "babylonjs/types";
  7082. /**
  7083. * @hidden
  7084. */
  7085. export class IntersectionInfo {
  7086. bu: Nullable<number>;
  7087. bv: Nullable<number>;
  7088. distance: number;
  7089. faceId: number;
  7090. subMeshId: number;
  7091. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7092. }
  7093. }
  7094. declare module "babylonjs/Culling/boundingSphere" {
  7095. import { DeepImmutable } from "babylonjs/types";
  7096. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7097. /**
  7098. * Class used to store bounding sphere information
  7099. */
  7100. export class BoundingSphere {
  7101. /**
  7102. * Gets the center of the bounding sphere in local space
  7103. */
  7104. readonly center: Vector3;
  7105. /**
  7106. * Radius of the bounding sphere in local space
  7107. */
  7108. radius: number;
  7109. /**
  7110. * Gets the center of the bounding sphere in world space
  7111. */
  7112. readonly centerWorld: Vector3;
  7113. /**
  7114. * Radius of the bounding sphere in world space
  7115. */
  7116. radiusWorld: number;
  7117. /**
  7118. * Gets the minimum vector in local space
  7119. */
  7120. readonly minimum: Vector3;
  7121. /**
  7122. * Gets the maximum vector in local space
  7123. */
  7124. readonly maximum: Vector3;
  7125. private _worldMatrix;
  7126. private static readonly TmpVector3;
  7127. /**
  7128. * Creates a new bounding sphere
  7129. * @param min defines the minimum vector (in local space)
  7130. * @param max defines the maximum vector (in local space)
  7131. * @param worldMatrix defines the new world matrix
  7132. */
  7133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7134. /**
  7135. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7136. * @param min defines the new minimum vector (in local space)
  7137. * @param max defines the new maximum vector (in local space)
  7138. * @param worldMatrix defines the new world matrix
  7139. */
  7140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Scale the current bounding sphere by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding box
  7145. */
  7146. scale(factor: number): BoundingSphere;
  7147. /**
  7148. * Gets the world matrix of the bounding box
  7149. * @returns a matrix
  7150. */
  7151. getWorldMatrix(): DeepImmutable<Matrix>;
  7152. /** @hidden */
  7153. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding sphere is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding sphere center is in between the frustum planes.
  7162. * Used for optimistic fast inclusion.
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @returns true if the sphere center is in between the frustum planes
  7165. */
  7166. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a point is inside the bounding sphere
  7169. * @param point defines the point to test
  7170. * @returns true if the point is inside the bounding sphere
  7171. */
  7172. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7173. /**
  7174. * Checks if two sphere intersct
  7175. * @param sphere0 sphere 0
  7176. * @param sphere1 sphere 1
  7177. * @returns true if the speres intersect
  7178. */
  7179. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7180. }
  7181. }
  7182. declare module "babylonjs/Culling/boundingBox" {
  7183. import { DeepImmutable } from "babylonjs/types";
  7184. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7187. /**
  7188. * Class used to store bounding box information
  7189. */
  7190. export class BoundingBox implements ICullable {
  7191. /**
  7192. * Gets the 8 vectors representing the bounding box in local space
  7193. */
  7194. readonly vectors: Vector3[];
  7195. /**
  7196. * Gets the center of the bounding box in local space
  7197. */
  7198. readonly center: Vector3;
  7199. /**
  7200. * Gets the center of the bounding box in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Gets the extend size in local space
  7205. */
  7206. readonly extendSize: Vector3;
  7207. /**
  7208. * Gets the extend size in world space
  7209. */
  7210. readonly extendSizeWorld: Vector3;
  7211. /**
  7212. * Gets the OBB (object bounding box) directions
  7213. */
  7214. readonly directions: Vector3[];
  7215. /**
  7216. * Gets the 8 vectors representing the bounding box in world space
  7217. */
  7218. readonly vectorsWorld: Vector3[];
  7219. /**
  7220. * Gets the minimum vector in world space
  7221. */
  7222. readonly minimumWorld: Vector3;
  7223. /**
  7224. * Gets the maximum vector in world space
  7225. */
  7226. readonly maximumWorld: Vector3;
  7227. /**
  7228. * Gets the minimum vector in local space
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * Gets the maximum vector in local space
  7233. */
  7234. readonly maximum: Vector3;
  7235. private _worldMatrix;
  7236. private static readonly TmpVector3;
  7237. /**
  7238. * @hidden
  7239. */
  7240. _tag: number;
  7241. /**
  7242. * Creates a new bounding box
  7243. * @param min defines the minimum vector (in local space)
  7244. * @param max defines the maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7248. /**
  7249. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7250. * @param min defines the new minimum vector (in local space)
  7251. * @param max defines the new maximum vector (in local space)
  7252. * @param worldMatrix defines the new world matrix
  7253. */
  7254. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Scale the current bounding box by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding box
  7259. */
  7260. scale(factor: number): BoundingBox;
  7261. /**
  7262. * Gets the world matrix of the bounding box
  7263. * @returns a matrix
  7264. */
  7265. getWorldMatrix(): DeepImmutable<Matrix>;
  7266. /** @hidden */
  7267. _update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Tests if the bounding box is intersecting the frustum planes
  7270. * @param frustumPlanes defines the frustum planes to test
  7271. * @returns true if there is an intersection
  7272. */
  7273. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /**
  7275. * Tests if the bounding box is entirely inside the frustum planes
  7276. * @param frustumPlanes defines the frustum planes to test
  7277. * @returns true if there is an inclusion
  7278. */
  7279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7280. /**
  7281. * Tests if a point is inside the bounding box
  7282. * @param point defines the point to test
  7283. * @returns true if the point is inside the bounding box
  7284. */
  7285. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7286. /**
  7287. * Tests if the bounding box intersects with a bounding sphere
  7288. * @param sphere defines the sphere to test
  7289. * @returns true if there is an intersection
  7290. */
  7291. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7292. /**
  7293. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7294. * @param min defines the min vector to use
  7295. * @param max defines the max vector to use
  7296. * @returns true if there is an intersection
  7297. */
  7298. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7299. /**
  7300. * Tests if two bounding boxes are intersections
  7301. * @param box0 defines the first box to test
  7302. * @param box1 defines the second box to test
  7303. * @returns true if there is an intersection
  7304. */
  7305. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7306. /**
  7307. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7308. * @param minPoint defines the minimum vector of the bounding box
  7309. * @param maxPoint defines the maximum vector of the bounding box
  7310. * @param sphereCenter defines the sphere center
  7311. * @param sphereRadius defines the sphere radius
  7312. * @returns true if there is an intersection
  7313. */
  7314. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7315. /**
  7316. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7317. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7318. * @param frustumPlanes defines the frustum planes to test
  7319. * @return true if there is an inclusion
  7320. */
  7321. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /**
  7323. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7324. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7325. * @param frustumPlanes defines the frustum planes to test
  7326. * @return true if there is an intersection
  7327. */
  7328. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7329. }
  7330. }
  7331. declare module "babylonjs/Collisions/collider" {
  7332. import { Nullable, IndicesArray } from "babylonjs/types";
  7333. import { Vector3, Plane } from "babylonjs/Maths/math";
  7334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7335. /** @hidden */
  7336. export class Collider {
  7337. /** Define if a collision was found */
  7338. collisionFound: boolean;
  7339. /**
  7340. * Define last intersection point in local space
  7341. */
  7342. intersectionPoint: Vector3;
  7343. /**
  7344. * Define last collided mesh
  7345. */
  7346. collidedMesh: Nullable<AbstractMesh>;
  7347. private _collisionPoint;
  7348. private _planeIntersectionPoint;
  7349. private _tempVector;
  7350. private _tempVector2;
  7351. private _tempVector3;
  7352. private _tempVector4;
  7353. private _edge;
  7354. private _baseToVertex;
  7355. private _destinationPoint;
  7356. private _slidePlaneNormal;
  7357. private _displacementVector;
  7358. /** @hidden */
  7359. _radius: Vector3;
  7360. /** @hidden */
  7361. _retry: number;
  7362. private _velocity;
  7363. private _basePoint;
  7364. private _epsilon;
  7365. /** @hidden */
  7366. _velocityWorldLength: number;
  7367. /** @hidden */
  7368. _basePointWorld: Vector3;
  7369. private _velocityWorld;
  7370. private _normalizedVelocity;
  7371. /** @hidden */
  7372. _initialVelocity: Vector3;
  7373. /** @hidden */
  7374. _initialPosition: Vector3;
  7375. private _nearestDistance;
  7376. private _collisionMask;
  7377. collisionMask: number;
  7378. /**
  7379. * Gets the plane normal used to compute the sliding response (in local space)
  7380. */
  7381. readonly slidePlaneNormal: Vector3;
  7382. /** @hidden */
  7383. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7384. /** @hidden */
  7385. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7386. /** @hidden */
  7387. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7388. /** @hidden */
  7389. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7390. /** @hidden */
  7391. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7392. /** @hidden */
  7393. _getResponse(pos: Vector3, vel: Vector3): void;
  7394. }
  7395. }
  7396. declare module "babylonjs/Culling/boundingInfo" {
  7397. import { DeepImmutable } from "babylonjs/types";
  7398. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7399. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7400. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7401. import { Collider } from "babylonjs/Collisions/collider";
  7402. /**
  7403. * Interface for cullable objects
  7404. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7405. */
  7406. export interface ICullable {
  7407. /**
  7408. * Checks if the object or part of the object is in the frustum
  7409. * @param frustumPlanes Camera near/planes
  7410. * @returns true if the object is in frustum otherwise false
  7411. */
  7412. isInFrustum(frustumPlanes: Plane[]): boolean;
  7413. /**
  7414. * Checks if a cullable object (mesh...) is in the camera frustum
  7415. * Unlike isInFrustum this cheks the full bounding box
  7416. * @param frustumPlanes Camera near/planes
  7417. * @returns true if the object is in frustum otherwise false
  7418. */
  7419. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7420. }
  7421. /**
  7422. * Info for a bounding data of a mesh
  7423. */
  7424. export class BoundingInfo implements ICullable {
  7425. /**
  7426. * Bounding box for the mesh
  7427. */
  7428. readonly boundingBox: BoundingBox;
  7429. /**
  7430. * Bounding sphere for the mesh
  7431. */
  7432. readonly boundingSphere: BoundingSphere;
  7433. private _isLocked;
  7434. private static readonly TmpVector3;
  7435. /**
  7436. * Constructs bounding info
  7437. * @param minimum min vector of the bounding box/sphere
  7438. * @param maximum max vector of the bounding box/sphere
  7439. * @param worldMatrix defines the new world matrix
  7440. */
  7441. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7442. /**
  7443. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7444. * @param min defines the new minimum vector (in local space)
  7445. * @param max defines the new maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7449. /**
  7450. * min vector of the bounding box/sphere
  7451. */
  7452. readonly minimum: Vector3;
  7453. /**
  7454. * max vector of the bounding box/sphere
  7455. */
  7456. readonly maximum: Vector3;
  7457. /**
  7458. * If the info is locked and won't be updated to avoid perf overhead
  7459. */
  7460. isLocked: boolean;
  7461. /**
  7462. * Updates the bounding sphere and box
  7463. * @param world world matrix to be used to update
  7464. */
  7465. update(world: DeepImmutable<Matrix>): void;
  7466. /**
  7467. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7468. * @param center New center of the bounding info
  7469. * @param extend New extend of the bounding info
  7470. * @returns the current bounding info
  7471. */
  7472. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7473. /**
  7474. * Scale the current bounding info by applying a scale factor
  7475. * @param factor defines the scale factor to apply
  7476. * @returns the current bounding info
  7477. */
  7478. scale(factor: number): BoundingInfo;
  7479. /**
  7480. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7481. * @param frustumPlanes defines the frustum to test
  7482. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7483. * @returns true if the bounding info is in the frustum planes
  7484. */
  7485. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7486. /**
  7487. * Gets the world distance between the min and max points of the bounding box
  7488. */
  7489. readonly diagonalLength: number;
  7490. /**
  7491. * Checks if a cullable object (mesh...) is in the camera frustum
  7492. * Unlike isInFrustum this cheks the full bounding box
  7493. * @param frustumPlanes Camera near/planes
  7494. * @returns true if the object is in frustum otherwise false
  7495. */
  7496. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7497. /** @hidden */
  7498. _checkCollision(collider: Collider): boolean;
  7499. /**
  7500. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7501. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7502. * @param point the point to check intersection with
  7503. * @returns if the point intersects
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7508. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7509. * @param boundingInfo the bounding info to check intersection with
  7510. * @param precise if the intersection should be done using OBB
  7511. * @returns if the bounding info intersects
  7512. */
  7513. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/smartArray" {
  7517. /**
  7518. * Defines an array and its length.
  7519. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7520. */
  7521. export interface ISmartArrayLike<T> {
  7522. /**
  7523. * The data of the array.
  7524. */
  7525. data: Array<T>;
  7526. /**
  7527. * The active length of the array.
  7528. */
  7529. length: number;
  7530. }
  7531. /**
  7532. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7533. */
  7534. export class SmartArray<T> implements ISmartArrayLike<T> {
  7535. /**
  7536. * The full set of data from the array.
  7537. */
  7538. data: Array<T>;
  7539. /**
  7540. * The active length of the array.
  7541. */
  7542. length: number;
  7543. protected _id: number;
  7544. /**
  7545. * Instantiates a Smart Array.
  7546. * @param capacity defines the default capacity of the array.
  7547. */
  7548. constructor(capacity: number);
  7549. /**
  7550. * Pushes a value at the end of the active data.
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Iterates over the active data and apply the lambda to them.
  7556. * @param func defines the action to apply on each value.
  7557. */
  7558. forEach(func: (content: T) => void): void;
  7559. /**
  7560. * Sorts the full sets of data.
  7561. * @param compareFn defines the comparison function to apply.
  7562. */
  7563. sort(compareFn: (a: T, b: T) => number): void;
  7564. /**
  7565. * Resets the active data to an empty array.
  7566. */
  7567. reset(): void;
  7568. /**
  7569. * Releases all the data from the array as well as the array.
  7570. */
  7571. dispose(): void;
  7572. /**
  7573. * Concats the active data with a given array.
  7574. * @param array defines the data to concatenate with.
  7575. */
  7576. concat(array: any): void;
  7577. /**
  7578. * Returns the position of a value in the active data.
  7579. * @param value defines the value to find the index for
  7580. * @returns the index if found in the active data otherwise -1
  7581. */
  7582. indexOf(value: T): number;
  7583. /**
  7584. * Returns whether an element is part of the active data.
  7585. * @param value defines the value to look for
  7586. * @returns true if found in the active data otherwise false
  7587. */
  7588. contains(value: T): boolean;
  7589. private static _GlobalId;
  7590. }
  7591. /**
  7592. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7593. * The data in this array can only be present once
  7594. */
  7595. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7596. private _duplicateId;
  7597. /**
  7598. * Pushes a value at the end of the active data.
  7599. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7600. * @param value defines the object to push in the array.
  7601. */
  7602. push(value: T): void;
  7603. /**
  7604. * Pushes a value at the end of the active data.
  7605. * If the data is already present, it won t be added again
  7606. * @param value defines the object to push in the array.
  7607. * @returns true if added false if it was already present
  7608. */
  7609. pushNoDuplicate(value: T): boolean;
  7610. /**
  7611. * Resets the active data to an empty array.
  7612. */
  7613. reset(): void;
  7614. /**
  7615. * Concats the active data with a given array.
  7616. * This ensures no dupplicate will be present in the result.
  7617. * @param array defines the data to concatenate with.
  7618. */
  7619. concatWithNoDuplicate(array: any): void;
  7620. }
  7621. }
  7622. declare module "babylonjs/Misc/iInspectable" {
  7623. /**
  7624. * Enum that determines the text-wrapping mode to use.
  7625. */
  7626. export enum InspectableType {
  7627. /**
  7628. * Checkbox for booleans
  7629. */
  7630. Checkbox = 0,
  7631. /**
  7632. * Sliders for numbers
  7633. */
  7634. Slider = 1,
  7635. /**
  7636. * Vector3
  7637. */
  7638. Vector3 = 2,
  7639. /**
  7640. * Quaternions
  7641. */
  7642. Quaternion = 3,
  7643. /**
  7644. * Color3
  7645. */
  7646. Color3 = 4
  7647. }
  7648. /**
  7649. * Interface used to define custom inspectable properties.
  7650. * This interface is used by the inspector to display custom property grids
  7651. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7652. */
  7653. export interface IInspectable {
  7654. /**
  7655. * Gets the label to display
  7656. */
  7657. label: string;
  7658. /**
  7659. * Gets the name of the property to edit
  7660. */
  7661. propertyName: string;
  7662. /**
  7663. * Gets the type of the editor to use
  7664. */
  7665. type: InspectableType;
  7666. /**
  7667. * Gets the minimum value of the property when using in "slider" mode
  7668. */
  7669. min?: number;
  7670. /**
  7671. * Gets the maximum value of the property when using in "slider" mode
  7672. */
  7673. max?: number;
  7674. /**
  7675. * Gets the setp to use when using in "slider" mode
  7676. */
  7677. step?: number;
  7678. }
  7679. }
  7680. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7681. import { Nullable } from "babylonjs/types";
  7682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7683. /**
  7684. * This represents the required contract to create a new type of texture loader.
  7685. */
  7686. export interface IInternalTextureLoader {
  7687. /**
  7688. * Defines wether the loader supports cascade loading the different faces.
  7689. */
  7690. supportCascades: boolean;
  7691. /**
  7692. * This returns if the loader support the current file information.
  7693. * @param extension defines the file extension of the file being loaded
  7694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7695. * @param fallback defines the fallback internal texture if any
  7696. * @param isBase64 defines whether the texture is encoded as a base64
  7697. * @param isBuffer defines whether the texture data are stored as a buffer
  7698. * @returns true if the loader can load the specified file
  7699. */
  7700. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7701. /**
  7702. * Transform the url before loading if required.
  7703. * @param rootUrl the url of the texture
  7704. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7705. * @returns the transformed texture
  7706. */
  7707. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7708. /**
  7709. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7710. * @param rootUrl the url of the texture
  7711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7712. * @returns the fallback texture
  7713. */
  7714. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7715. /**
  7716. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7717. * @param data contains the texture data
  7718. * @param texture defines the BabylonJS internal texture
  7719. * @param createPolynomials will be true if polynomials have been requested
  7720. * @param onLoad defines the callback to trigger once the texture is ready
  7721. * @param onError defines the callback to trigger in case of error
  7722. */
  7723. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7724. /**
  7725. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7726. * @param data contains the texture data
  7727. * @param texture defines the BabylonJS internal texture
  7728. * @param callback defines the method to call once ready to upload
  7729. */
  7730. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7731. }
  7732. }
  7733. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7735. import { Nullable } from "babylonjs/types";
  7736. import { Scene } from "babylonjs/scene";
  7737. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7738. module "babylonjs/Engines/engine" {
  7739. interface Engine {
  7740. /**
  7741. * Creates a depth stencil cube texture.
  7742. * This is only available in WebGL 2.
  7743. * @param size The size of face edge in the cube texture.
  7744. * @param options The options defining the cube texture.
  7745. * @returns The cube texture
  7746. */
  7747. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7748. /**
  7749. * Creates a cube texture
  7750. * @param rootUrl defines the url where the files to load is located
  7751. * @param scene defines the current scene
  7752. * @param files defines the list of files to load (1 per face)
  7753. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7754. * @param onLoad defines an optional callback raised when the texture is loaded
  7755. * @param onError defines an optional callback raised if there is an issue to load the texture
  7756. * @param format defines the format of the data
  7757. * @param forcedExtension defines the extension to use to pick the right loader
  7758. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7762. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7763. * @returns the cube texture as an InternalTexture
  7764. */
  7765. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7766. /**
  7767. * Creates a cube texture
  7768. * @param rootUrl defines the url where the files to load is located
  7769. * @param scene defines the current scene
  7770. * @param files defines the list of files to load (1 per face)
  7771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7772. * @param onLoad defines an optional callback raised when the texture is loaded
  7773. * @param onError defines an optional callback raised if there is an issue to load the texture
  7774. * @param format defines the format of the data
  7775. * @param forcedExtension defines the extension to use to pick the right loader
  7776. * @returns the cube texture as an InternalTexture
  7777. */
  7778. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7779. /**
  7780. * Creates a cube texture
  7781. * @param rootUrl defines the url where the files to load is located
  7782. * @param scene defines the current scene
  7783. * @param files defines the list of files to load (1 per face)
  7784. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7785. * @param onLoad defines an optional callback raised when the texture is loaded
  7786. * @param onError defines an optional callback raised if there is an issue to load the texture
  7787. * @param format defines the format of the data
  7788. * @param forcedExtension defines the extension to use to pick the right loader
  7789. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7790. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7791. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7792. * @returns the cube texture as an InternalTexture
  7793. */
  7794. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7795. /** @hidden */
  7796. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7797. /** @hidden */
  7798. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7799. /** @hidden */
  7800. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7803. }
  7804. }
  7805. }
  7806. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7807. import { Nullable } from "babylonjs/types";
  7808. import { Scene } from "babylonjs/scene";
  7809. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7811. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7812. /**
  7813. * Class for creating a cube texture
  7814. */
  7815. export class CubeTexture extends BaseTexture {
  7816. private _delayedOnLoad;
  7817. /**
  7818. * The url of the texture
  7819. */
  7820. url: string;
  7821. /**
  7822. * Gets or sets the center of the bounding box associated with the cube texture.
  7823. * It must define where the camera used to render the texture was set
  7824. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7825. */
  7826. boundingBoxPosition: Vector3;
  7827. private _boundingBoxSize;
  7828. /**
  7829. * Gets or sets the size of the bounding box associated with the cube texture
  7830. * When defined, the cubemap will switch to local mode
  7831. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7832. * @example https://www.babylonjs-playground.com/#RNASML
  7833. */
  7834. /**
  7835. * Returns the bounding box size
  7836. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7837. */
  7838. boundingBoxSize: Vector3;
  7839. protected _rotationY: number;
  7840. /**
  7841. * Sets texture matrix rotation angle around Y axis in radians.
  7842. */
  7843. /**
  7844. * Gets texture matrix rotation angle around Y axis radians.
  7845. */
  7846. rotationY: number;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. readonly noMipmap: boolean;
  7851. private _noMipmap;
  7852. private _files;
  7853. private _extensions;
  7854. private _textureMatrix;
  7855. private _format;
  7856. private _createPolynomials;
  7857. /** @hidden */
  7858. _prefiltered: boolean;
  7859. /**
  7860. * Creates a cube texture from an array of image urls
  7861. * @param files defines an array of image urls
  7862. * @param scene defines the hosting scene
  7863. * @param noMipmap specifies if mip maps are not used
  7864. * @returns a cube texture
  7865. */
  7866. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7867. /**
  7868. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7869. * @param url defines the url of the prefiltered texture
  7870. * @param scene defines the scene the texture is attached to
  7871. * @param forcedExtension defines the extension of the file if different from the url
  7872. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7873. * @return the prefiltered texture
  7874. */
  7875. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7876. /**
  7877. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7878. * as prefiltered data.
  7879. * @param rootUrl defines the url of the texture or the root name of the six images
  7880. * @param scene defines the scene the texture is attached to
  7881. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7882. * @param noMipmap defines if mipmaps should be created or not
  7883. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7884. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7885. * @param onError defines a callback triggered in case of error during load
  7886. * @param format defines the internal format to use for the texture once loaded
  7887. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7888. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7889. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7890. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7891. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7892. * @return the cube texture
  7893. */
  7894. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7895. /**
  7896. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7897. */
  7898. readonly isPrefiltered: boolean;
  7899. /**
  7900. * Get the current class name of the texture useful for serialization or dynamic coding.
  7901. * @returns "CubeTexture"
  7902. */
  7903. getClassName(): string;
  7904. /**
  7905. * Update the url (and optional buffer) of this texture if url was null during construction.
  7906. * @param url the url of the texture
  7907. * @param forcedExtension defines the extension to use
  7908. * @param onLoad callback called when the texture is loaded (defaults to null)
  7909. */
  7910. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7911. /**
  7912. * Delays loading of the cube texture
  7913. * @param forcedExtension defines the extension to use
  7914. */
  7915. delayLoad(forcedExtension?: string): void;
  7916. /**
  7917. * Returns the reflection texture matrix
  7918. * @returns the reflection texture matrix
  7919. */
  7920. getReflectionTextureMatrix(): Matrix;
  7921. /**
  7922. * Sets the reflection texture matrix
  7923. * @param value Reflection texture matrix
  7924. */
  7925. setReflectionTextureMatrix(value: Matrix): void;
  7926. /**
  7927. * Parses text to create a cube texture
  7928. * @param parsedTexture define the serialized text to read from
  7929. * @param scene defines the hosting scene
  7930. * @param rootUrl defines the root url of the cube texture
  7931. * @returns a cube texture
  7932. */
  7933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7934. /**
  7935. * Makes a clone, or deep copy, of the cube texture
  7936. * @returns a new cube texture
  7937. */
  7938. clone(): CubeTexture;
  7939. }
  7940. }
  7941. declare module "babylonjs/Shaders/postprocess.vertex" {
  7942. /** @hidden */
  7943. export var postprocessVertexShader: {
  7944. name: string;
  7945. shader: string;
  7946. };
  7947. }
  7948. declare module "babylonjs/Cameras/targetCamera" {
  7949. import { Nullable } from "babylonjs/types";
  7950. import { Camera } from "babylonjs/Cameras/camera";
  7951. import { Scene } from "babylonjs/scene";
  7952. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7953. /**
  7954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7955. * This is the base of the follow, arc rotate cameras and Free camera
  7956. * @see http://doc.babylonjs.com/features/cameras
  7957. */
  7958. export class TargetCamera extends Camera {
  7959. private static _RigCamTransformMatrix;
  7960. private static _TargetTransformMatrix;
  7961. private static _TargetFocalPoint;
  7962. /**
  7963. * Define the current direction the camera is moving to
  7964. */
  7965. cameraDirection: Vector3;
  7966. /**
  7967. * Define the current rotation the camera is rotating to
  7968. */
  7969. cameraRotation: Vector2;
  7970. /**
  7971. * When set, the up vector of the camera will be updated by the rotation of the camera
  7972. */
  7973. updateUpVectorFromRotation: boolean;
  7974. private _tmpQuaternion;
  7975. /**
  7976. * Define the current rotation of the camera
  7977. */
  7978. rotation: Vector3;
  7979. /**
  7980. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7981. */
  7982. rotationQuaternion: Quaternion;
  7983. /**
  7984. * Define the current speed of the camera
  7985. */
  7986. speed: number;
  7987. /**
  7988. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7989. * around all axis.
  7990. */
  7991. noRotationConstraint: boolean;
  7992. /**
  7993. * Define the current target of the camera as an object or a position.
  7994. */
  7995. lockedTarget: any;
  7996. /** @hidden */
  7997. _currentTarget: Vector3;
  7998. /** @hidden */
  7999. _initialFocalDistance: number;
  8000. /** @hidden */
  8001. _viewMatrix: Matrix;
  8002. /** @hidden */
  8003. _camMatrix: Matrix;
  8004. /** @hidden */
  8005. _cameraTransformMatrix: Matrix;
  8006. /** @hidden */
  8007. _cameraRotationMatrix: Matrix;
  8008. /** @hidden */
  8009. _referencePoint: Vector3;
  8010. /** @hidden */
  8011. _transformedReferencePoint: Vector3;
  8012. protected _globalCurrentTarget: Vector3;
  8013. protected _globalCurrentUpVector: Vector3;
  8014. /** @hidden */
  8015. _reset: () => void;
  8016. private _defaultUp;
  8017. /**
  8018. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8019. * This is the base of the follow, arc rotate cameras and Free camera
  8020. * @see http://doc.babylonjs.com/features/cameras
  8021. * @param name Defines the name of the camera in the scene
  8022. * @param position Defines the start position of the camera in the scene
  8023. * @param scene Defines the scene the camera belongs to
  8024. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8025. */
  8026. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8027. /**
  8028. * Gets the position in front of the camera at a given distance.
  8029. * @param distance The distance from the camera we want the position to be
  8030. * @returns the position
  8031. */
  8032. getFrontPosition(distance: number): Vector3;
  8033. /** @hidden */
  8034. _getLockedTargetPosition(): Nullable<Vector3>;
  8035. private _storedPosition;
  8036. private _storedRotation;
  8037. private _storedRotationQuaternion;
  8038. /**
  8039. * Store current camera state of the camera (fov, position, rotation, etc..)
  8040. * @returns the camera
  8041. */
  8042. storeState(): Camera;
  8043. /**
  8044. * Restored camera state. You must call storeState() first
  8045. * @returns whether it was successful or not
  8046. * @hidden
  8047. */
  8048. _restoreStateValues(): boolean;
  8049. /** @hidden */
  8050. _initCache(): void;
  8051. /** @hidden */
  8052. _updateCache(ignoreParentClass?: boolean): void;
  8053. /** @hidden */
  8054. _isSynchronizedViewMatrix(): boolean;
  8055. /** @hidden */
  8056. _computeLocalCameraSpeed(): number;
  8057. /**
  8058. * Defines the target the camera should look at.
  8059. * This will automatically adapt alpha beta and radius to fit within the new target.
  8060. * @param target Defines the new target as a Vector or a mesh
  8061. */
  8062. setTarget(target: Vector3): void;
  8063. /**
  8064. * Return the current target position of the camera. This value is expressed in local space.
  8065. * @returns the target position
  8066. */
  8067. getTarget(): Vector3;
  8068. /** @hidden */
  8069. _decideIfNeedsToMove(): boolean;
  8070. /** @hidden */
  8071. _updatePosition(): void;
  8072. /** @hidden */
  8073. _checkInputs(): void;
  8074. protected _updateCameraRotationMatrix(): void;
  8075. /**
  8076. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8077. * @returns the current camera
  8078. */
  8079. private _rotateUpVectorWithCameraRotationMatrix;
  8080. private _cachedRotationZ;
  8081. private _cachedQuaternionRotationZ;
  8082. /** @hidden */
  8083. _getViewMatrix(): Matrix;
  8084. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8085. /**
  8086. * @hidden
  8087. */
  8088. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8089. /**
  8090. * @hidden
  8091. */
  8092. _updateRigCameras(): void;
  8093. private _getRigCamPositionAndTarget;
  8094. /**
  8095. * Gets the current object class name.
  8096. * @return the class name
  8097. */
  8098. getClassName(): string;
  8099. }
  8100. }
  8101. declare module "babylonjs/Cameras/cameraInputsManager" {
  8102. import { Nullable } from "babylonjs/types";
  8103. import { Camera } from "babylonjs/Cameras/camera";
  8104. /**
  8105. * @ignore
  8106. * This is a list of all the different input types that are available in the application.
  8107. * Fo instance: ArcRotateCameraGamepadInput...
  8108. */
  8109. export var CameraInputTypes: {};
  8110. /**
  8111. * This is the contract to implement in order to create a new input class.
  8112. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8113. */
  8114. export interface ICameraInput<TCamera extends Camera> {
  8115. /**
  8116. * Defines the camera the input is attached to.
  8117. */
  8118. camera: Nullable<TCamera>;
  8119. /**
  8120. * Gets the class name of the current intput.
  8121. * @returns the class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Get the friendly name associated with the input class.
  8126. * @returns the input friendly name
  8127. */
  8128. getSimpleName(): string;
  8129. /**
  8130. * Attach the input controls to a specific dom element to get the input from.
  8131. * @param element Defines the element the controls should be listened from
  8132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8133. */
  8134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8135. /**
  8136. * Detach the current controls from the specified dom element.
  8137. * @param element Defines the element to stop listening the inputs from
  8138. */
  8139. detachControl(element: Nullable<HTMLElement>): void;
  8140. /**
  8141. * Update the current camera state depending on the inputs that have been used this frame.
  8142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8143. */
  8144. checkInputs?: () => void;
  8145. }
  8146. /**
  8147. * Represents a map of input types to input instance or input index to input instance.
  8148. */
  8149. export interface CameraInputsMap<TCamera extends Camera> {
  8150. /**
  8151. * Accessor to the input by input type.
  8152. */
  8153. [name: string]: ICameraInput<TCamera>;
  8154. /**
  8155. * Accessor to the input by input index.
  8156. */
  8157. [idx: number]: ICameraInput<TCamera>;
  8158. }
  8159. /**
  8160. * This represents the input manager used within a camera.
  8161. * It helps dealing with all the different kind of input attached to a camera.
  8162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8163. */
  8164. export class CameraInputsManager<TCamera extends Camera> {
  8165. /**
  8166. * Defines the list of inputs attahed to the camera.
  8167. */
  8168. attached: CameraInputsMap<TCamera>;
  8169. /**
  8170. * Defines the dom element the camera is collecting inputs from.
  8171. * This is null if the controls have not been attached.
  8172. */
  8173. attachedElement: Nullable<HTMLElement>;
  8174. /**
  8175. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8176. */
  8177. noPreventDefault: boolean;
  8178. /**
  8179. * Defined the camera the input manager belongs to.
  8180. */
  8181. camera: TCamera;
  8182. /**
  8183. * Update the current camera state depending on the inputs that have been used this frame.
  8184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8185. */
  8186. checkInputs: () => void;
  8187. /**
  8188. * Instantiate a new Camera Input Manager.
  8189. * @param camera Defines the camera the input manager blongs to
  8190. */
  8191. constructor(camera: TCamera);
  8192. /**
  8193. * Add an input method to a camera
  8194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8195. * @param input camera input method
  8196. */
  8197. add(input: ICameraInput<TCamera>): void;
  8198. /**
  8199. * Remove a specific input method from a camera
  8200. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8201. * @param inputToRemove camera input method
  8202. */
  8203. remove(inputToRemove: ICameraInput<TCamera>): void;
  8204. /**
  8205. * Remove a specific input type from a camera
  8206. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8207. * @param inputType the type of the input to remove
  8208. */
  8209. removeByType(inputType: string): void;
  8210. private _addCheckInputs;
  8211. /**
  8212. * Attach the input controls to the currently attached dom element to listen the events from.
  8213. * @param input Defines the input to attach
  8214. */
  8215. attachInput(input: ICameraInput<TCamera>): void;
  8216. /**
  8217. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8218. * @param element Defines the dom element to collect the events from
  8219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8220. */
  8221. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8222. /**
  8223. * Detach the current manager inputs controls from a specific dom element.
  8224. * @param element Defines the dom element to collect the events from
  8225. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8226. */
  8227. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8228. /**
  8229. * Rebuild the dynamic inputCheck function from the current list of
  8230. * defined inputs in the manager.
  8231. */
  8232. rebuildInputCheck(): void;
  8233. /**
  8234. * Remove all attached input methods from a camera
  8235. */
  8236. clear(): void;
  8237. /**
  8238. * Serialize the current input manager attached to a camera.
  8239. * This ensures than once parsed,
  8240. * the input associated to the camera will be identical to the current ones
  8241. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8242. */
  8243. serialize(serializedCamera: any): void;
  8244. /**
  8245. * Parses an input manager serialized JSON to restore the previous list of inputs
  8246. * and states associated to a camera.
  8247. * @param parsedCamera Defines the JSON to parse
  8248. */
  8249. parse(parsedCamera: any): void;
  8250. }
  8251. }
  8252. declare module "babylonjs/Events/keyboardEvents" {
  8253. /**
  8254. * Gather the list of keyboard event types as constants.
  8255. */
  8256. export class KeyboardEventTypes {
  8257. /**
  8258. * The keydown event is fired when a key becomes active (pressed).
  8259. */
  8260. static readonly KEYDOWN: number;
  8261. /**
  8262. * The keyup event is fired when a key has been released.
  8263. */
  8264. static readonly KEYUP: number;
  8265. }
  8266. /**
  8267. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8268. */
  8269. export class KeyboardInfo {
  8270. /**
  8271. * Defines the type of event (KeyboardEventTypes)
  8272. */
  8273. type: number;
  8274. /**
  8275. * Defines the related dom event
  8276. */
  8277. event: KeyboardEvent;
  8278. /**
  8279. * Instantiates a new keyboard info.
  8280. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8281. * @param type Defines the type of event (KeyboardEventTypes)
  8282. * @param event Defines the related dom event
  8283. */
  8284. constructor(
  8285. /**
  8286. * Defines the type of event (KeyboardEventTypes)
  8287. */
  8288. type: number,
  8289. /**
  8290. * Defines the related dom event
  8291. */
  8292. event: KeyboardEvent);
  8293. }
  8294. /**
  8295. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8296. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8297. */
  8298. export class KeyboardInfoPre extends KeyboardInfo {
  8299. /**
  8300. * Defines the type of event (KeyboardEventTypes)
  8301. */
  8302. type: number;
  8303. /**
  8304. * Defines the related dom event
  8305. */
  8306. event: KeyboardEvent;
  8307. /**
  8308. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8309. */
  8310. skipOnPointerObservable: boolean;
  8311. /**
  8312. * Instantiates a new keyboard pre info.
  8313. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8314. * @param type Defines the type of event (KeyboardEventTypes)
  8315. * @param event Defines the related dom event
  8316. */
  8317. constructor(
  8318. /**
  8319. * Defines the type of event (KeyboardEventTypes)
  8320. */
  8321. type: number,
  8322. /**
  8323. * Defines the related dom event
  8324. */
  8325. event: KeyboardEvent);
  8326. }
  8327. }
  8328. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8329. import { Nullable } from "babylonjs/types";
  8330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8331. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8332. /**
  8333. * Manage the keyboard inputs to control the movement of a free camera.
  8334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8335. */
  8336. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8337. /**
  8338. * Defines the camera the input is attached to.
  8339. */
  8340. camera: FreeCamera;
  8341. /**
  8342. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8343. */
  8344. keysUp: number[];
  8345. /**
  8346. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8347. */
  8348. keysDown: number[];
  8349. /**
  8350. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8351. */
  8352. keysLeft: number[];
  8353. /**
  8354. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8355. */
  8356. keysRight: number[];
  8357. private _keys;
  8358. private _onCanvasBlurObserver;
  8359. private _onKeyboardObserver;
  8360. private _engine;
  8361. private _scene;
  8362. /**
  8363. * Attach the input controls to a specific dom element to get the input from.
  8364. * @param element Defines the element the controls should be listened from
  8365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8366. */
  8367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8368. /**
  8369. * Detach the current controls from the specified dom element.
  8370. * @param element Defines the element to stop listening the inputs from
  8371. */
  8372. detachControl(element: Nullable<HTMLElement>): void;
  8373. /**
  8374. * Update the current camera state depending on the inputs that have been used this frame.
  8375. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8376. */
  8377. checkInputs(): void;
  8378. /**
  8379. * Gets the class name of the current intput.
  8380. * @returns the class name
  8381. */
  8382. getClassName(): string;
  8383. /** @hidden */
  8384. _onLostFocus(): void;
  8385. /**
  8386. * Get the friendly name associated with the input class.
  8387. * @returns the input friendly name
  8388. */
  8389. getSimpleName(): string;
  8390. }
  8391. }
  8392. declare module "babylonjs/Materials/multiMaterial" {
  8393. import { Nullable } from "babylonjs/types";
  8394. import { Scene } from "babylonjs/scene";
  8395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8396. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8398. import { Material } from "babylonjs/Materials/material";
  8399. /**
  8400. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8401. * separate meshes. This can be use to improve performances.
  8402. * @see http://doc.babylonjs.com/how_to/multi_materials
  8403. */
  8404. export class MultiMaterial extends Material {
  8405. private _subMaterials;
  8406. /**
  8407. * Gets or Sets the list of Materials used within the multi material.
  8408. * They need to be ordered according to the submeshes order in the associated mesh
  8409. */
  8410. subMaterials: Nullable<Material>[];
  8411. /**
  8412. * Function used to align with Node.getChildren()
  8413. * @returns the list of Materials used within the multi material
  8414. */
  8415. getChildren(): Nullable<Material>[];
  8416. /**
  8417. * Instantiates a new Multi Material
  8418. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8419. * separate meshes. This can be use to improve performances.
  8420. * @see http://doc.babylonjs.com/how_to/multi_materials
  8421. * @param name Define the name in the scene
  8422. * @param scene Define the scene the material belongs to
  8423. */
  8424. constructor(name: string, scene: Scene);
  8425. private _hookArray;
  8426. /**
  8427. * Get one of the submaterial by its index in the submaterials array
  8428. * @param index The index to look the sub material at
  8429. * @returns The Material if the index has been defined
  8430. */
  8431. getSubMaterial(index: number): Nullable<Material>;
  8432. /**
  8433. * Get the list of active textures for the whole sub materials list.
  8434. * @returns All the textures that will be used during the rendering
  8435. */
  8436. getActiveTextures(): BaseTexture[];
  8437. /**
  8438. * Gets the current class name of the material e.g. "MultiMaterial"
  8439. * Mainly use in serialization.
  8440. * @returns the class name
  8441. */
  8442. getClassName(): string;
  8443. /**
  8444. * Checks if the material is ready to render the requested sub mesh
  8445. * @param mesh Define the mesh the submesh belongs to
  8446. * @param subMesh Define the sub mesh to look readyness for
  8447. * @param useInstances Define whether or not the material is used with instances
  8448. * @returns true if ready, otherwise false
  8449. */
  8450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8451. /**
  8452. * Clones the current material and its related sub materials
  8453. * @param name Define the name of the newly cloned material
  8454. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8455. * @returns the cloned material
  8456. */
  8457. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8458. /**
  8459. * Serializes the materials into a JSON representation.
  8460. * @returns the JSON representation
  8461. */
  8462. serialize(): any;
  8463. /**
  8464. * Dispose the material and release its associated resources
  8465. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  8466. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  8467. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  8468. */
  8469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8470. /**
  8471. * Creates a MultiMaterial from parsed MultiMaterial data.
  8472. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8473. * @param scene defines the hosting scene
  8474. * @returns a new MultiMaterial
  8475. */
  8476. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8477. }
  8478. }
  8479. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8480. /**
  8481. * Class used to represent data loading progression
  8482. */
  8483. export class SceneLoaderFlags {
  8484. private static _ForceFullSceneLoadingForIncremental;
  8485. private static _ShowLoadingScreen;
  8486. private static _CleanBoneMatrixWeights;
  8487. private static _loggingLevel;
  8488. /**
  8489. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8490. */
  8491. static ForceFullSceneLoadingForIncremental: boolean;
  8492. /**
  8493. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8494. */
  8495. static ShowLoadingScreen: boolean;
  8496. /**
  8497. * Defines the current logging level (while loading the scene)
  8498. * @ignorenaming
  8499. */
  8500. static loggingLevel: number;
  8501. /**
  8502. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8503. */
  8504. static CleanBoneMatrixWeights: boolean;
  8505. }
  8506. }
  8507. declare module "babylonjs/Meshes/transformNode" {
  8508. import { DeepImmutable } from "babylonjs/types";
  8509. import { Observable } from "babylonjs/Misc/observable";
  8510. import { Nullable } from "babylonjs/types";
  8511. import { Camera } from "babylonjs/Cameras/camera";
  8512. import { Scene } from "babylonjs/scene";
  8513. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8514. import { Node } from "babylonjs/node";
  8515. import { Bone } from "babylonjs/Bones/bone";
  8516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8517. /**
  8518. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  8519. * @see https://doc.babylonjs.com/how_to/transformnode
  8520. */
  8521. export class TransformNode extends Node {
  8522. /**
  8523. * Object will not rotate to face the camera
  8524. */
  8525. static BILLBOARDMODE_NONE: number;
  8526. /**
  8527. * Object will rotate to face the camera but only on the x axis
  8528. */
  8529. static BILLBOARDMODE_X: number;
  8530. /**
  8531. * Object will rotate to face the camera but only on the y axis
  8532. */
  8533. static BILLBOARDMODE_Y: number;
  8534. /**
  8535. * Object will rotate to face the camera but only on the z axis
  8536. */
  8537. static BILLBOARDMODE_Z: number;
  8538. /**
  8539. * Object will rotate to face the camera
  8540. */
  8541. static BILLBOARDMODE_ALL: number;
  8542. private _forward;
  8543. private _forwardInverted;
  8544. private _up;
  8545. private _right;
  8546. private _rightInverted;
  8547. private _position;
  8548. private _rotation;
  8549. private _rotationQuaternion;
  8550. protected _scaling: Vector3;
  8551. protected _isDirty: boolean;
  8552. private _transformToBoneReferal;
  8553. private _billboardMode;
  8554. /**
  8555. * Gets or sets the billboard mode. Default is 0.
  8556. *
  8557. * | Value | Type | Description |
  8558. * | --- | --- | --- |
  8559. * | 0 | BILLBOARDMODE_NONE | |
  8560. * | 1 | BILLBOARDMODE_X | |
  8561. * | 2 | BILLBOARDMODE_Y | |
  8562. * | 4 | BILLBOARDMODE_Z | |
  8563. * | 7 | BILLBOARDMODE_ALL | |
  8564. *
  8565. */
  8566. billboardMode: number;
  8567. private _preserveParentRotationForBillboard;
  8568. /**
  8569. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8570. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8571. */
  8572. preserveParentRotationForBillboard: boolean;
  8573. /**
  8574. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  8575. */
  8576. scalingDeterminant: number;
  8577. private _infiniteDistance;
  8578. /**
  8579. * Gets or sets the distance of the object to max, often used by skybox
  8580. */
  8581. infiniteDistance: boolean;
  8582. /**
  8583. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8584. * By default the system will update normals to compensate
  8585. */
  8586. ignoreNonUniformScaling: boolean;
  8587. /**
  8588. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  8589. */
  8590. reIntegrateRotationIntoRotationQuaternion: boolean;
  8591. /** @hidden */
  8592. _poseMatrix: Nullable<Matrix>;
  8593. /** @hidden */
  8594. _localMatrix: Matrix;
  8595. private _usePivotMatrix;
  8596. private _absolutePosition;
  8597. private _pivotMatrix;
  8598. private _pivotMatrixInverse;
  8599. protected _postMultiplyPivotMatrix: boolean;
  8600. protected _isWorldMatrixFrozen: boolean;
  8601. /** @hidden */
  8602. _indexInSceneTransformNodesArray: number;
  8603. /**
  8604. * An event triggered after the world matrix is updated
  8605. */
  8606. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8607. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8608. /**
  8609. * Gets a string identifying the name of the class
  8610. * @returns "TransformNode" string
  8611. */
  8612. getClassName(): string;
  8613. /**
  8614. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8615. */
  8616. position: Vector3;
  8617. /**
  8618. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  8619. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8620. */
  8621. rotation: Vector3;
  8622. /**
  8623. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  8624. */
  8625. scaling: Vector3;
  8626. /**
  8627. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  8628. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8629. */
  8630. rotationQuaternion: Nullable<Quaternion>;
  8631. /**
  8632. * The forward direction of that transform in world space.
  8633. */
  8634. readonly forward: Vector3;
  8635. /**
  8636. * The up direction of that transform in world space.
  8637. */
  8638. readonly up: Vector3;
  8639. /**
  8640. * The right direction of that transform in world space.
  8641. */
  8642. readonly right: Vector3;
  8643. /**
  8644. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8645. * @param matrix the matrix to copy the pose from
  8646. * @returns this TransformNode.
  8647. */
  8648. updatePoseMatrix(matrix: Matrix): TransformNode;
  8649. /**
  8650. * Returns the mesh Pose matrix.
  8651. * @returns the pose matrix
  8652. */
  8653. getPoseMatrix(): Matrix;
  8654. /** @hidden */
  8655. _isSynchronized(): boolean;
  8656. /** @hidden */
  8657. _initCache(): void;
  8658. /**
  8659. * Flag the transform node as dirty (Forcing it to update everything)
  8660. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8661. * @returns this transform node
  8662. */
  8663. markAsDirty(property: string): TransformNode;
  8664. /**
  8665. * Returns the current mesh absolute position.
  8666. * Returns a Vector3.
  8667. */
  8668. readonly absolutePosition: Vector3;
  8669. /**
  8670. * Sets a new matrix to apply before all other transformation
  8671. * @param matrix defines the transform matrix
  8672. * @returns the current TransformNode
  8673. */
  8674. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8675. /**
  8676. * Sets a new pivot matrix to the current node
  8677. * @param matrix defines the new pivot matrix to use
  8678. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  8679. * @returns the current TransformNode
  8680. */
  8681. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8682. /**
  8683. * Returns the mesh pivot matrix.
  8684. * Default : Identity.
  8685. * @returns the matrix
  8686. */
  8687. getPivotMatrix(): Matrix;
  8688. /**
  8689. * Prevents the World matrix to be computed any longer.
  8690. * @returns the TransformNode.
  8691. */
  8692. freezeWorldMatrix(): TransformNode;
  8693. /**
  8694. * Allows back the World matrix computation.
  8695. * @returns the TransformNode.
  8696. */
  8697. unfreezeWorldMatrix(): this;
  8698. /**
  8699. * True if the World matrix has been frozen.
  8700. */
  8701. readonly isWorldMatrixFrozen: boolean;
  8702. /**
  8703. * Retuns the mesh absolute position in the World.
  8704. * @returns a Vector3.
  8705. */
  8706. getAbsolutePosition(): Vector3;
  8707. /**
  8708. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8709. * @param absolutePosition the absolute position to set
  8710. * @returns the TransformNode.
  8711. */
  8712. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8713. /**
  8714. * Sets the mesh position in its local space.
  8715. * @param vector3 the position to set in localspace
  8716. * @returns the TransformNode.
  8717. */
  8718. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8719. /**
  8720. * Returns the mesh position in the local space from the current World matrix values.
  8721. * @returns a new Vector3.
  8722. */
  8723. getPositionExpressedInLocalSpace(): Vector3;
  8724. /**
  8725. * Translates the mesh along the passed Vector3 in its local space.
  8726. * @param vector3 the distance to translate in localspace
  8727. * @returns the TransformNode.
  8728. */
  8729. locallyTranslate(vector3: Vector3): TransformNode;
  8730. private static _lookAtVectorCache;
  8731. /**
  8732. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8733. * @param targetPoint the position (must be in same space as current mesh) to look at
  8734. * @param yawCor optional yaw (y-axis) correction in radians
  8735. * @param pitchCor optional pitch (x-axis) correction in radians
  8736. * @param rollCor optional roll (z-axis) correction in radians
  8737. * @param space the choosen space of the target
  8738. * @returns the TransformNode.
  8739. */
  8740. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8741. /**
  8742. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8743. * This Vector3 is expressed in the World space.
  8744. * @param localAxis axis to rotate
  8745. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. */
  8747. getDirection(localAxis: Vector3): Vector3;
  8748. /**
  8749. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8750. * localAxis is expressed in the mesh local space.
  8751. * result is computed in the Wordl space from the mesh World matrix.
  8752. * @param localAxis axis to rotate
  8753. * @param result the resulting transformnode
  8754. * @returns this TransformNode.
  8755. */
  8756. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8757. /**
  8758. * Sets this transform node rotation to the given local axis.
  8759. * @param localAxis the axis in local space
  8760. * @param yawCor optional yaw (y-axis) correction in radians
  8761. * @param pitchCor optional pitch (x-axis) correction in radians
  8762. * @param rollCor optional roll (z-axis) correction in radians
  8763. * @returns this TransformNode
  8764. */
  8765. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8766. /**
  8767. * Sets a new pivot point to the current node
  8768. * @param point defines the new pivot point to use
  8769. * @param space defines if the point is in world or local space (local by default)
  8770. * @returns the current TransformNode
  8771. */
  8772. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8773. /**
  8774. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8775. * @returns the pivot point
  8776. */
  8777. getPivotPoint(): Vector3;
  8778. /**
  8779. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8780. * @param result the vector3 to store the result
  8781. * @returns this TransformNode.
  8782. */
  8783. getPivotPointToRef(result: Vector3): TransformNode;
  8784. /**
  8785. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8786. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8787. */
  8788. getAbsolutePivotPoint(): Vector3;
  8789. /**
  8790. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8791. * @param result vector3 to store the result
  8792. * @returns this TransformNode.
  8793. */
  8794. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8795. /**
  8796. * Defines the passed node as the parent of the current node.
  8797. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8798. * @see https://doc.babylonjs.com/how_to/parenting
  8799. * @param node the node ot set as the parent
  8800. * @returns this TransformNode.
  8801. */
  8802. setParent(node: Nullable<Node>): TransformNode;
  8803. private _nonUniformScaling;
  8804. /**
  8805. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8806. */
  8807. readonly nonUniformScaling: boolean;
  8808. /** @hidden */
  8809. _updateNonUniformScalingState(value: boolean): boolean;
  8810. /**
  8811. * Attach the current TransformNode to another TransformNode associated with a bone
  8812. * @param bone Bone affecting the TransformNode
  8813. * @param affectedTransformNode TransformNode associated with the bone
  8814. * @returns this object
  8815. */
  8816. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8817. /**
  8818. * Detach the transform node if its associated with a bone
  8819. * @returns this object
  8820. */
  8821. detachFromBone(): TransformNode;
  8822. private static _rotationAxisCache;
  8823. /**
  8824. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8825. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8826. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8827. * The passed axis is also normalized.
  8828. * @param axis the axis to rotate around
  8829. * @param amount the amount to rotate in radians
  8830. * @param space Space to rotate in (Default: local)
  8831. * @returns the TransformNode.
  8832. */
  8833. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8834. /**
  8835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8836. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8837. * The passed axis is also normalized. .
  8838. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8839. * @param point the point to rotate around
  8840. * @param axis the axis to rotate around
  8841. * @param amount the amount to rotate in radians
  8842. * @returns the TransformNode
  8843. */
  8844. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8845. /**
  8846. * Translates the mesh along the axis vector for the passed distance in the given space.
  8847. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8848. * @param axis the axis to translate in
  8849. * @param distance the distance to translate
  8850. * @param space Space to rotate in (Default: local)
  8851. * @returns the TransformNode.
  8852. */
  8853. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8854. /**
  8855. * Adds a rotation step to the mesh current rotation.
  8856. * x, y, z are Euler angles expressed in radians.
  8857. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8858. * This means this rotation is made in the mesh local space only.
  8859. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8860. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8861. * ```javascript
  8862. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8863. * ```
  8864. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8865. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  8866. * @param x Rotation to add
  8867. * @param y Rotation to add
  8868. * @param z Rotation to add
  8869. * @returns the TransformNode.
  8870. */
  8871. addRotation(x: number, y: number, z: number): TransformNode;
  8872. /**
  8873. * @hidden
  8874. */
  8875. protected _getEffectiveParent(): Nullable<Node>;
  8876. /**
  8877. * Computes the world matrix of the node
  8878. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8879. * @returns the world matrix
  8880. */
  8881. computeWorldMatrix(force?: boolean): Matrix;
  8882. protected _afterComputeWorldMatrix(): void;
  8883. /**
  8884. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8885. * @param func callback function to add
  8886. *
  8887. * @returns the TransformNode.
  8888. */
  8889. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8890. /**
  8891. * Removes a registered callback function.
  8892. * @param func callback function to remove
  8893. * @returns the TransformNode.
  8894. */
  8895. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8896. /**
  8897. * Gets the position of the current mesh in camera space
  8898. * @param camera defines the camera to use
  8899. * @returns a position
  8900. */
  8901. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8902. /**
  8903. * Returns the distance from the mesh to the active camera
  8904. * @param camera defines the camera to use
  8905. * @returns the distance
  8906. */
  8907. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8908. /**
  8909. * Clone the current transform node
  8910. * @param name Name of the new clone
  8911. * @param newParent New parent for the clone
  8912. * @param doNotCloneChildren Do not clone children hierarchy
  8913. * @returns the new transform node
  8914. */
  8915. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8916. /**
  8917. * Serializes the objects information.
  8918. * @param currentSerializationObject defines the object to serialize in
  8919. * @returns the serialized object
  8920. */
  8921. serialize(currentSerializationObject?: any): any;
  8922. /**
  8923. * Returns a new TransformNode object parsed from the source provided.
  8924. * @param parsedTransformNode is the source.
  8925. * @param scene the scne the object belongs to
  8926. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8927. * @returns a new TransformNode object parsed from the source provided.
  8928. */
  8929. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8930. /**
  8931. * Get all child-transformNodes of this node
  8932. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  8933. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  8934. * @returns an array of TransformNode
  8935. */
  8936. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8937. /**
  8938. * Releases resources associated with this transform node.
  8939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8941. */
  8942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8943. /**
  8944. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8945. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8946. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8947. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8948. * @returns the current mesh
  8949. */
  8950. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8951. }
  8952. }
  8953. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8954. /**
  8955. * Class used to override all child animations of a given target
  8956. */
  8957. export class AnimationPropertiesOverride {
  8958. /**
  8959. * Gets or sets a value indicating if animation blending must be used
  8960. */
  8961. enableBlending: boolean;
  8962. /**
  8963. * Gets or sets the blending speed to use when enableBlending is true
  8964. */
  8965. blendingSpeed: number;
  8966. /**
  8967. * Gets or sets the default loop mode to use
  8968. */
  8969. loopMode: number;
  8970. }
  8971. }
  8972. declare module "babylonjs/Bones/bone" {
  8973. import { Skeleton } from "babylonjs/Bones/skeleton";
  8974. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8975. import { Nullable } from "babylonjs/types";
  8976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8978. import { Node } from "babylonjs/node";
  8979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8980. /**
  8981. * Class used to store bone information
  8982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8983. */
  8984. export class Bone extends Node {
  8985. /**
  8986. * defines the bone name
  8987. */
  8988. name: string;
  8989. private static _tmpVecs;
  8990. private static _tmpQuat;
  8991. private static _tmpMats;
  8992. /**
  8993. * Gets the list of child bones
  8994. */
  8995. children: Bone[];
  8996. /** Gets the animations associated with this bone */
  8997. animations: import("babylonjs/Animations/animation").Animation[];
  8998. /**
  8999. * Gets or sets bone length
  9000. */
  9001. length: number;
  9002. /**
  9003. * @hidden Internal only
  9004. * Set this value to map this bone to a different index in the transform matrices
  9005. * Set this value to -1 to exclude the bone from the transform matrices
  9006. */
  9007. _index: Nullable<number>;
  9008. private _skeleton;
  9009. private _localMatrix;
  9010. private _restPose;
  9011. private _baseMatrix;
  9012. private _absoluteTransform;
  9013. private _invertedAbsoluteTransform;
  9014. private _parent;
  9015. private _scalingDeterminant;
  9016. private _worldTransform;
  9017. private _localScaling;
  9018. private _localRotation;
  9019. private _localPosition;
  9020. private _needToDecompose;
  9021. private _needToCompose;
  9022. /** @hidden */
  9023. _linkedTransformNode: Nullable<TransformNode>;
  9024. /** @hidden */
  9025. _waitingTransformNodeId: Nullable<string>;
  9026. /** @hidden */
  9027. /** @hidden */
  9028. _matrix: Matrix;
  9029. /**
  9030. * Create a new bone
  9031. * @param name defines the bone name
  9032. * @param skeleton defines the parent skeleton
  9033. * @param parentBone defines the parent (can be null if the bone is the root)
  9034. * @param localMatrix defines the local matrix
  9035. * @param restPose defines the rest pose matrix
  9036. * @param baseMatrix defines the base matrix
  9037. * @param index defines index of the bone in the hiearchy
  9038. */
  9039. constructor(
  9040. /**
  9041. * defines the bone name
  9042. */
  9043. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9044. /**
  9045. * Gets the current object class name.
  9046. * @return the class name
  9047. */
  9048. getClassName(): string;
  9049. /**
  9050. * Gets the parent skeleton
  9051. * @returns a skeleton
  9052. */
  9053. getSkeleton(): Skeleton;
  9054. /**
  9055. * Gets parent bone
  9056. * @returns a bone or null if the bone is the root of the bone hierarchy
  9057. */
  9058. getParent(): Nullable<Bone>;
  9059. /**
  9060. * Returns an array containing the root bones
  9061. * @returns an array containing the root bones
  9062. */
  9063. getChildren(): Array<Bone>;
  9064. /**
  9065. * Sets the parent bone
  9066. * @param parent defines the parent (can be null if the bone is the root)
  9067. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9068. */
  9069. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9070. /**
  9071. * Gets the local matrix
  9072. * @returns a matrix
  9073. */
  9074. getLocalMatrix(): Matrix;
  9075. /**
  9076. * Gets the base matrix (initial matrix which remains unchanged)
  9077. * @returns a matrix
  9078. */
  9079. getBaseMatrix(): Matrix;
  9080. /**
  9081. * Gets the rest pose matrix
  9082. * @returns a matrix
  9083. */
  9084. getRestPose(): Matrix;
  9085. /**
  9086. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9087. */
  9088. getWorldMatrix(): Matrix;
  9089. /**
  9090. * Sets the local matrix to rest pose matrix
  9091. */
  9092. returnToRest(): void;
  9093. /**
  9094. * Gets the inverse of the absolute transform matrix.
  9095. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9096. * @returns a matrix
  9097. */
  9098. getInvertedAbsoluteTransform(): Matrix;
  9099. /**
  9100. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9101. * @returns a matrix
  9102. */
  9103. getAbsoluteTransform(): Matrix;
  9104. /**
  9105. * Links with the given transform node.
  9106. * The local matrix of this bone is copied from the transform node every frame.
  9107. * @param transformNode defines the transform node to link to
  9108. */
  9109. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9110. /** Gets or sets current position (in local space) */
  9111. position: Vector3;
  9112. /** Gets or sets current rotation (in local space) */
  9113. rotation: Vector3;
  9114. /** Gets or sets current rotation quaternion (in local space) */
  9115. rotationQuaternion: Quaternion;
  9116. /** Gets or sets current scaling (in local space) */
  9117. scaling: Vector3;
  9118. /**
  9119. * Gets the animation properties override
  9120. */
  9121. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9122. private _decompose;
  9123. private _compose;
  9124. /**
  9125. * Update the base and local matrices
  9126. * @param matrix defines the new base or local matrix
  9127. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9128. * @param updateLocalMatrix defines if the local matrix should be updated
  9129. */
  9130. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9131. /** @hidden */
  9132. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9133. /**
  9134. * Flag the bone as dirty (Forcing it to update everything)
  9135. */
  9136. markAsDirty(): void;
  9137. /** @hidden */
  9138. _markAsDirtyAndCompose(): void;
  9139. private _markAsDirtyAndDecompose;
  9140. /**
  9141. * Translate the bone in local or world space
  9142. * @param vec The amount to translate the bone
  9143. * @param space The space that the translation is in
  9144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9145. */
  9146. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9147. /**
  9148. * Set the postion of the bone in local or world space
  9149. * @param position The position to set the bone
  9150. * @param space The space that the position is in
  9151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9152. */
  9153. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9154. /**
  9155. * Set the absolute position of the bone (world space)
  9156. * @param position The position to set the bone
  9157. * @param mesh The mesh that this bone is attached to
  9158. */
  9159. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9160. /**
  9161. * Scale the bone on the x, y and z axes (in local space)
  9162. * @param x The amount to scale the bone on the x axis
  9163. * @param y The amount to scale the bone on the y axis
  9164. * @param z The amount to scale the bone on the z axis
  9165. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9166. */
  9167. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9168. /**
  9169. * Set the bone scaling in local space
  9170. * @param scale defines the scaling vector
  9171. */
  9172. setScale(scale: Vector3): void;
  9173. /**
  9174. * Gets the current scaling in local space
  9175. * @returns the current scaling vector
  9176. */
  9177. getScale(): Vector3;
  9178. /**
  9179. * Gets the current scaling in local space and stores it in a target vector
  9180. * @param result defines the target vector
  9181. */
  9182. getScaleToRef(result: Vector3): void;
  9183. /**
  9184. * Set the yaw, pitch, and roll of the bone in local or world space
  9185. * @param yaw The rotation of the bone on the y axis
  9186. * @param pitch The rotation of the bone on the x axis
  9187. * @param roll The rotation of the bone on the z axis
  9188. * @param space The space that the axes of rotation are in
  9189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9190. */
  9191. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9192. /**
  9193. * Add a rotation to the bone on an axis in local or world space
  9194. * @param axis The axis to rotate the bone on
  9195. * @param amount The amount to rotate the bone
  9196. * @param space The space that the axis is in
  9197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9198. */
  9199. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9200. /**
  9201. * Set the rotation of the bone to a particular axis angle in local or world space
  9202. * @param axis The axis to rotate the bone on
  9203. * @param angle The angle that the bone should be rotated to
  9204. * @param space The space that the axis is in
  9205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9206. */
  9207. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9208. /**
  9209. * Set the euler rotation of the bone in local of world space
  9210. * @param rotation The euler rotation that the bone should be set to
  9211. * @param space The space that the rotation is in
  9212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9213. */
  9214. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9215. /**
  9216. * Set the quaternion rotation of the bone in local of world space
  9217. * @param quat The quaternion rotation that the bone should be set to
  9218. * @param space The space that the rotation is in
  9219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9220. */
  9221. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9222. /**
  9223. * Set the rotation matrix of the bone in local of world space
  9224. * @param rotMat The rotation matrix that the bone should be set to
  9225. * @param space The space that the rotation is in
  9226. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9227. */
  9228. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9229. private _rotateWithMatrix;
  9230. private _getNegativeRotationToRef;
  9231. /**
  9232. * Get the position of the bone in local or world space
  9233. * @param space The space that the returned position is in
  9234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9235. * @returns The position of the bone
  9236. */
  9237. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9238. /**
  9239. * Copy the position of the bone to a vector3 in local or world space
  9240. * @param space The space that the returned position is in
  9241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9242. * @param result The vector3 to copy the position to
  9243. */
  9244. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9245. /**
  9246. * Get the absolute position of the bone (world space)
  9247. * @param mesh The mesh that this bone is attached to
  9248. * @returns The absolute position of the bone
  9249. */
  9250. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9251. /**
  9252. * Copy the absolute position of the bone (world space) to the result param
  9253. * @param mesh The mesh that this bone is attached to
  9254. * @param result The vector3 to copy the absolute position to
  9255. */
  9256. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9257. /**
  9258. * Compute the absolute transforms of this bone and its children
  9259. */
  9260. computeAbsoluteTransforms(): void;
  9261. /**
  9262. * Get the world direction from an axis that is in the local space of the bone
  9263. * @param localAxis The local direction that is used to compute the world direction
  9264. * @param mesh The mesh that this bone is attached to
  9265. * @returns The world direction
  9266. */
  9267. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9268. /**
  9269. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9270. * @param localAxis The local direction that is used to compute the world direction
  9271. * @param mesh The mesh that this bone is attached to
  9272. * @param result The vector3 that the world direction will be copied to
  9273. */
  9274. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9275. /**
  9276. * Get the euler rotation of the bone in local or world space
  9277. * @param space The space that the rotation should be in
  9278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9279. * @returns The euler rotation
  9280. */
  9281. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9282. /**
  9283. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9284. * @param space The space that the rotation should be in
  9285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9286. * @param result The vector3 that the rotation should be copied to
  9287. */
  9288. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9289. /**
  9290. * Get the quaternion rotation of the bone in either local or world space
  9291. * @param space The space that the rotation should be in
  9292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9293. * @returns The quaternion rotation
  9294. */
  9295. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9296. /**
  9297. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9298. * @param space The space that the rotation should be in
  9299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9300. * @param result The quaternion that the rotation should be copied to
  9301. */
  9302. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9303. /**
  9304. * Get the rotation matrix of the bone in local or world space
  9305. * @param space The space that the rotation should be in
  9306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9307. * @returns The rotation matrix
  9308. */
  9309. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9310. /**
  9311. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9312. * @param space The space that the rotation should be in
  9313. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9314. * @param result The quaternion that the rotation should be copied to
  9315. */
  9316. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9317. /**
  9318. * Get the world position of a point that is in the local space of the bone
  9319. * @param position The local position
  9320. * @param mesh The mesh that this bone is attached to
  9321. * @returns The world position
  9322. */
  9323. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9324. /**
  9325. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9326. * @param position The local position
  9327. * @param mesh The mesh that this bone is attached to
  9328. * @param result The vector3 that the world position should be copied to
  9329. */
  9330. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9331. /**
  9332. * Get the local position of a point that is in world space
  9333. * @param position The world position
  9334. * @param mesh The mesh that this bone is attached to
  9335. * @returns The local position
  9336. */
  9337. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9338. /**
  9339. * Get the local position of a point that is in world space and copy it to the result param
  9340. * @param position The world position
  9341. * @param mesh The mesh that this bone is attached to
  9342. * @param result The vector3 that the local position should be copied to
  9343. */
  9344. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9345. }
  9346. }
  9347. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9348. import { Nullable } from "babylonjs/types";
  9349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9350. import { Scene } from "babylonjs/scene";
  9351. module "babylonjs/Engines/engine" {
  9352. interface Engine {
  9353. /**
  9354. * Creates a raw texture
  9355. * @param data defines the data to store in the texture
  9356. * @param width defines the width of the texture
  9357. * @param height defines the height of the texture
  9358. * @param format defines the format of the data
  9359. * @param generateMipMaps defines if the engine should generate the mip levels
  9360. * @param invertY defines if data must be stored with Y axis inverted
  9361. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9362. * @param compression defines the compression used (null by default)
  9363. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9364. * @returns the raw texture inside an InternalTexture
  9365. */
  9366. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9367. /**
  9368. * Update a raw texture
  9369. * @param texture defines the texture to update
  9370. * @param data defines the data to store in the texture
  9371. * @param format defines the format of the data
  9372. * @param invertY defines if data must be stored with Y axis inverted
  9373. */
  9374. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9375. /**
  9376. * Update a raw texture
  9377. * @param texture defines the texture to update
  9378. * @param data defines the data to store in the texture
  9379. * @param format defines the format of the data
  9380. * @param invertY defines if data must be stored with Y axis inverted
  9381. * @param compression defines the compression used (null by default)
  9382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9383. */
  9384. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9385. /**
  9386. * Creates a new raw cube texture
  9387. * @param data defines the array of data to use to create each face
  9388. * @param size defines the size of the textures
  9389. * @param format defines the format of the data
  9390. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9391. * @param generateMipMaps defines if the engine should generate the mip levels
  9392. * @param invertY defines if data must be stored with Y axis inverted
  9393. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9394. * @param compression defines the compression used (null by default)
  9395. * @returns the cube texture as an InternalTexture
  9396. */
  9397. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9398. /**
  9399. * Update a raw cube texture
  9400. * @param texture defines the texture to udpdate
  9401. * @param data defines the data to store
  9402. * @param format defines the data format
  9403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9404. * @param invertY defines if data must be stored with Y axis inverted
  9405. */
  9406. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9407. /**
  9408. * Update a raw cube texture
  9409. * @param texture defines the texture to udpdate
  9410. * @param data defines the data to store
  9411. * @param format defines the data format
  9412. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9413. * @param invertY defines if data must be stored with Y axis inverted
  9414. * @param compression defines the compression used (null by default)
  9415. */
  9416. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9417. /**
  9418. * Update a raw cube texture
  9419. * @param texture defines the texture to udpdate
  9420. * @param data defines the data to store
  9421. * @param format defines the data format
  9422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9423. * @param invertY defines if data must be stored with Y axis inverted
  9424. * @param compression defines the compression used (null by default)
  9425. * @param level defines which level of the texture to update
  9426. */
  9427. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9428. /**
  9429. * Creates a new raw cube texture from a specified url
  9430. * @param url defines the url where the data is located
  9431. * @param scene defines the current scene
  9432. * @param size defines the size of the textures
  9433. * @param format defines the format of the data
  9434. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9435. * @param noMipmap defines if the engine should avoid generating the mip levels
  9436. * @param callback defines a callback used to extract texture data from loaded data
  9437. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9438. * @param onLoad defines a callback called when texture is loaded
  9439. * @param onError defines a callback called if there is an error
  9440. * @returns the cube texture as an InternalTexture
  9441. */
  9442. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  9443. /**
  9444. * Creates a new raw cube texture from a specified url
  9445. * @param url defines the url where the data is located
  9446. * @param scene defines the current scene
  9447. * @param size defines the size of the textures
  9448. * @param format defines the format of the data
  9449. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9450. * @param noMipmap defines if the engine should avoid generating the mip levels
  9451. * @param callback defines a callback used to extract texture data from loaded data
  9452. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9453. * @param onLoad defines a callback called when texture is loaded
  9454. * @param onError defines a callback called if there is an error
  9455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9456. * @param invertY defines if data must be stored with Y axis inverted
  9457. * @returns the cube texture as an InternalTexture
  9458. */
  9459. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  9460. /**
  9461. * Creates a new raw 3D texture
  9462. * @param data defines the data used to create the texture
  9463. * @param width defines the width of the texture
  9464. * @param height defines the height of the texture
  9465. * @param depth defines the depth of the texture
  9466. * @param format defines the format of the texture
  9467. * @param generateMipMaps defines if the engine must generate mip levels
  9468. * @param invertY defines if data must be stored with Y axis inverted
  9469. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9470. * @param compression defines the compressed used (can be null)
  9471. * @param textureType defines the compressed used (can be null)
  9472. * @returns a new raw 3D texture (stored in an InternalTexture)
  9473. */
  9474. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9475. /**
  9476. * Update a raw 3D texture
  9477. * @param texture defines the texture to update
  9478. * @param data defines the data to store
  9479. * @param format defines the data format
  9480. * @param invertY defines if data must be stored with Y axis inverted
  9481. */
  9482. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9483. /**
  9484. * Update a raw 3D texture
  9485. * @param texture defines the texture to update
  9486. * @param data defines the data to store
  9487. * @param format defines the data format
  9488. * @param invertY defines if data must be stored with Y axis inverted
  9489. * @param compression defines the used compression (can be null)
  9490. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9491. */
  9492. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9493. }
  9494. }
  9495. }
  9496. declare module "babylonjs/Materials/Textures/rawTexture" {
  9497. import { Scene } from "babylonjs/scene";
  9498. import { Texture } from "babylonjs/Materials/Textures/texture";
  9499. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9500. /**
  9501. * Raw texture can help creating a texture directly from an array of data.
  9502. * This can be super useful if you either get the data from an uncompressed source or
  9503. * if you wish to create your texture pixel by pixel.
  9504. */
  9505. export class RawTexture extends Texture {
  9506. /**
  9507. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9508. */
  9509. format: number;
  9510. private _engine;
  9511. /**
  9512. * Instantiates a new RawTexture.
  9513. * Raw texture can help creating a texture directly from an array of data.
  9514. * This can be super useful if you either get the data from an uncompressed source or
  9515. * if you wish to create your texture pixel by pixel.
  9516. * @param data define the array of data to use to create the texture
  9517. * @param width define the width of the texture
  9518. * @param height define the height of the texture
  9519. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9520. * @param scene define the scene the texture belongs to
  9521. * @param generateMipMaps define whether mip maps should be generated or not
  9522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9524. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9525. */
  9526. constructor(data: ArrayBufferView, width: number, height: number,
  9527. /**
  9528. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9529. */
  9530. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9531. /**
  9532. * Updates the texture underlying data.
  9533. * @param data Define the new data of the texture
  9534. */
  9535. update(data: ArrayBufferView): void;
  9536. /**
  9537. * Creates a luminance texture from some data.
  9538. * @param data Define the texture data
  9539. * @param width Define the width of the texture
  9540. * @param height Define the height of the texture
  9541. * @param scene Define the scene the texture belongs to
  9542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9545. * @returns the luminance texture
  9546. */
  9547. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9548. /**
  9549. * Creates a luminance alpha texture from some data.
  9550. * @param data Define the texture data
  9551. * @param width Define the width of the texture
  9552. * @param height Define the height of the texture
  9553. * @param scene Define the scene the texture belongs to
  9554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9557. * @returns the luminance alpha texture
  9558. */
  9559. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9560. /**
  9561. * Creates an alpha texture from some data.
  9562. * @param data Define the texture data
  9563. * @param width Define the width of the texture
  9564. * @param height Define the height of the texture
  9565. * @param scene Define the scene the texture belongs to
  9566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9569. * @returns the alpha texture
  9570. */
  9571. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9572. /**
  9573. * Creates a RGB texture from some data.
  9574. * @param data Define the texture data
  9575. * @param width Define the width of the texture
  9576. * @param height Define the height of the texture
  9577. * @param scene Define the scene the texture belongs to
  9578. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9579. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9580. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9581. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9582. * @returns the RGB alpha texture
  9583. */
  9584. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9585. /**
  9586. * Creates a RGBA texture from some data.
  9587. * @param data Define the texture data
  9588. * @param width Define the width of the texture
  9589. * @param height Define the height of the texture
  9590. * @param scene Define the scene the texture belongs to
  9591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9594. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9595. * @returns the RGBA texture
  9596. */
  9597. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9598. /**
  9599. * Creates a R texture from some data.
  9600. * @param data Define the texture data
  9601. * @param width Define the width of the texture
  9602. * @param height Define the height of the texture
  9603. * @param scene Define the scene the texture belongs to
  9604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9607. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9608. * @returns the R texture
  9609. */
  9610. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9611. }
  9612. }
  9613. declare module "babylonjs/Animations/runtimeAnimation" {
  9614. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9615. import { Animatable } from "babylonjs/Animations/animatable";
  9616. import { Scene } from "babylonjs/scene";
  9617. /**
  9618. * Defines a runtime animation
  9619. */
  9620. export class RuntimeAnimation {
  9621. private _events;
  9622. /**
  9623. * The current frame of the runtime animation
  9624. */
  9625. private _currentFrame;
  9626. /**
  9627. * The animation used by the runtime animation
  9628. */
  9629. private _animation;
  9630. /**
  9631. * The target of the runtime animation
  9632. */
  9633. private _target;
  9634. /**
  9635. * The initiating animatable
  9636. */
  9637. private _host;
  9638. /**
  9639. * The original value of the runtime animation
  9640. */
  9641. private _originalValue;
  9642. /**
  9643. * The original blend value of the runtime animation
  9644. */
  9645. private _originalBlendValue;
  9646. /**
  9647. * The offsets cache of the runtime animation
  9648. */
  9649. private _offsetsCache;
  9650. /**
  9651. * The high limits cache of the runtime animation
  9652. */
  9653. private _highLimitsCache;
  9654. /**
  9655. * Specifies if the runtime animation has been stopped
  9656. */
  9657. private _stopped;
  9658. /**
  9659. * The blending factor of the runtime animation
  9660. */
  9661. private _blendingFactor;
  9662. /**
  9663. * The BabylonJS scene
  9664. */
  9665. private _scene;
  9666. /**
  9667. * The current value of the runtime animation
  9668. */
  9669. private _currentValue;
  9670. /** @hidden */
  9671. _animationState: _IAnimationState;
  9672. /**
  9673. * The active target of the runtime animation
  9674. */
  9675. private _activeTargets;
  9676. private _currentActiveTarget;
  9677. private _directTarget;
  9678. /**
  9679. * The target path of the runtime animation
  9680. */
  9681. private _targetPath;
  9682. /**
  9683. * The weight of the runtime animation
  9684. */
  9685. private _weight;
  9686. /**
  9687. * The ratio offset of the runtime animation
  9688. */
  9689. private _ratioOffset;
  9690. /**
  9691. * The previous delay of the runtime animation
  9692. */
  9693. private _previousDelay;
  9694. /**
  9695. * The previous ratio of the runtime animation
  9696. */
  9697. private _previousRatio;
  9698. private _enableBlending;
  9699. private _keys;
  9700. private _minFrame;
  9701. private _maxFrame;
  9702. private _minValue;
  9703. private _maxValue;
  9704. private _targetIsArray;
  9705. /**
  9706. * Gets the current frame of the runtime animation
  9707. */
  9708. readonly currentFrame: number;
  9709. /**
  9710. * Gets the weight of the runtime animation
  9711. */
  9712. readonly weight: number;
  9713. /**
  9714. * Gets the current value of the runtime animation
  9715. */
  9716. readonly currentValue: any;
  9717. /**
  9718. * Gets the target path of the runtime animation
  9719. */
  9720. readonly targetPath: string;
  9721. /**
  9722. * Gets the actual target of the runtime animation
  9723. */
  9724. readonly target: any;
  9725. /** @hidden */
  9726. _onLoop: () => void;
  9727. /**
  9728. * Create a new RuntimeAnimation object
  9729. * @param target defines the target of the animation
  9730. * @param animation defines the source animation object
  9731. * @param scene defines the hosting scene
  9732. * @param host defines the initiating Animatable
  9733. */
  9734. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9735. private _preparePath;
  9736. /**
  9737. * Gets the animation from the runtime animation
  9738. */
  9739. readonly animation: Animation;
  9740. /**
  9741. * Resets the runtime animation to the beginning
  9742. * @param restoreOriginal defines whether to restore the target property to the original value
  9743. */
  9744. reset(restoreOriginal?: boolean): void;
  9745. /**
  9746. * Specifies if the runtime animation is stopped
  9747. * @returns Boolean specifying if the runtime animation is stopped
  9748. */
  9749. isStopped(): boolean;
  9750. /**
  9751. * Disposes of the runtime animation
  9752. */
  9753. dispose(): void;
  9754. /**
  9755. * Apply the interpolated value to the target
  9756. * @param currentValue defines the value computed by the animation
  9757. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9758. */
  9759. setValue(currentValue: any, weight: number): void;
  9760. private _getOriginalValues;
  9761. private _setValue;
  9762. /**
  9763. * Gets the loop pmode of the runtime animation
  9764. * @returns Loop Mode
  9765. */
  9766. private _getCorrectLoopMode;
  9767. /**
  9768. * Move the current animation to a given frame
  9769. * @param frame defines the frame to move to
  9770. */
  9771. goToFrame(frame: number): void;
  9772. /**
  9773. * @hidden Internal use only
  9774. */
  9775. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9776. /**
  9777. * Execute the current animation
  9778. * @param delay defines the delay to add to the current frame
  9779. * @param from defines the lower bound of the animation range
  9780. * @param to defines the upper bound of the animation range
  9781. * @param loop defines if the current animation must loop
  9782. * @param speedRatio defines the current speed ratio
  9783. * @param weight defines the weight of the animation (default is -1 so no weight)
  9784. * @param onLoop optional callback called when animation loops
  9785. * @returns a boolean indicating if the animation is running
  9786. */
  9787. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9788. }
  9789. }
  9790. declare module "babylonjs/Animations/animatable" {
  9791. import { Animation } from "babylonjs/Animations/animation";
  9792. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9793. import { Nullable } from "babylonjs/types";
  9794. import { Observable } from "babylonjs/Misc/observable";
  9795. import { Scene } from "babylonjs/scene";
  9796. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9797. import { Node } from "babylonjs/node";
  9798. /**
  9799. * Class used to store an actual running animation
  9800. */
  9801. export class Animatable {
  9802. /** defines the target object */
  9803. target: any;
  9804. /** defines the starting frame number (default is 0) */
  9805. fromFrame: number;
  9806. /** defines the ending frame number (default is 100) */
  9807. toFrame: number;
  9808. /** defines if the animation must loop (default is false) */
  9809. loopAnimation: boolean;
  9810. /** defines a callback to call when animation ends if it is not looping */
  9811. onAnimationEnd?: (() => void) | null | undefined;
  9812. /** defines a callback to call when animation loops */
  9813. onAnimationLoop?: (() => void) | null | undefined;
  9814. private _localDelayOffset;
  9815. private _pausedDelay;
  9816. private _runtimeAnimations;
  9817. private _paused;
  9818. private _scene;
  9819. private _speedRatio;
  9820. private _weight;
  9821. private _syncRoot;
  9822. /**
  9823. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9824. * This will only apply for non looping animation (default is true)
  9825. */
  9826. disposeOnEnd: boolean;
  9827. /**
  9828. * Gets a boolean indicating if the animation has started
  9829. */
  9830. animationStarted: boolean;
  9831. /**
  9832. * Observer raised when the animation ends
  9833. */
  9834. onAnimationEndObservable: Observable<Animatable>;
  9835. /**
  9836. * Observer raised when the animation loops
  9837. */
  9838. onAnimationLoopObservable: Observable<Animatable>;
  9839. /**
  9840. * Gets the root Animatable used to synchronize and normalize animations
  9841. */
  9842. readonly syncRoot: Nullable<Animatable>;
  9843. /**
  9844. * Gets the current frame of the first RuntimeAnimation
  9845. * Used to synchronize Animatables
  9846. */
  9847. readonly masterFrame: number;
  9848. /**
  9849. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9850. */
  9851. weight: number;
  9852. /**
  9853. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9854. */
  9855. speedRatio: number;
  9856. /**
  9857. * Creates a new Animatable
  9858. * @param scene defines the hosting scene
  9859. * @param target defines the target object
  9860. * @param fromFrame defines the starting frame number (default is 0)
  9861. * @param toFrame defines the ending frame number (default is 100)
  9862. * @param loopAnimation defines if the animation must loop (default is false)
  9863. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9864. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9865. * @param animations defines a group of animation to add to the new Animatable
  9866. * @param onAnimationLoop defines a callback to call when animation loops
  9867. */
  9868. constructor(scene: Scene,
  9869. /** defines the target object */
  9870. target: any,
  9871. /** defines the starting frame number (default is 0) */
  9872. fromFrame?: number,
  9873. /** defines the ending frame number (default is 100) */
  9874. toFrame?: number,
  9875. /** defines if the animation must loop (default is false) */
  9876. loopAnimation?: boolean, speedRatio?: number,
  9877. /** defines a callback to call when animation ends if it is not looping */
  9878. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9879. /** defines a callback to call when animation loops */
  9880. onAnimationLoop?: (() => void) | null | undefined);
  9881. /**
  9882. * Synchronize and normalize current Animatable with a source Animatable
  9883. * This is useful when using animation weights and when animations are not of the same length
  9884. * @param root defines the root Animatable to synchronize with
  9885. * @returns the current Animatable
  9886. */
  9887. syncWith(root: Animatable): Animatable;
  9888. /**
  9889. * Gets the list of runtime animations
  9890. * @returns an array of RuntimeAnimation
  9891. */
  9892. getAnimations(): RuntimeAnimation[];
  9893. /**
  9894. * Adds more animations to the current animatable
  9895. * @param target defines the target of the animations
  9896. * @param animations defines the new animations to add
  9897. */
  9898. appendAnimations(target: any, animations: Animation[]): void;
  9899. /**
  9900. * Gets the source animation for a specific property
  9901. * @param property defines the propertyu to look for
  9902. * @returns null or the source animation for the given property
  9903. */
  9904. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9905. /**
  9906. * Gets the runtime animation for a specific property
  9907. * @param property defines the propertyu to look for
  9908. * @returns null or the runtime animation for the given property
  9909. */
  9910. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9911. /**
  9912. * Resets the animatable to its original state
  9913. */
  9914. reset(): void;
  9915. /**
  9916. * Allows the animatable to blend with current running animations
  9917. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9918. * @param blendingSpeed defines the blending speed to use
  9919. */
  9920. enableBlending(blendingSpeed: number): void;
  9921. /**
  9922. * Disable animation blending
  9923. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9924. */
  9925. disableBlending(): void;
  9926. /**
  9927. * Jump directly to a given frame
  9928. * @param frame defines the frame to jump to
  9929. */
  9930. goToFrame(frame: number): void;
  9931. /**
  9932. * Pause the animation
  9933. */
  9934. pause(): void;
  9935. /**
  9936. * Restart the animation
  9937. */
  9938. restart(): void;
  9939. private _raiseOnAnimationEnd;
  9940. /**
  9941. * Stop and delete the current animation
  9942. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9943. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  9944. */
  9945. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9946. /**
  9947. * Wait asynchronously for the animation to end
  9948. * @returns a promise which will be fullfilled when the animation ends
  9949. */
  9950. waitAsync(): Promise<Animatable>;
  9951. /** @hidden */
  9952. _animate(delay: number): boolean;
  9953. }
  9954. module "babylonjs/scene" {
  9955. interface Scene {
  9956. /** @hidden */
  9957. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9958. /** @hidden */
  9959. _processLateAnimationBindingsForMatrices(holder: {
  9960. totalWeight: number;
  9961. animations: RuntimeAnimation[];
  9962. originalValue: Matrix;
  9963. }): any;
  9964. /** @hidden */
  9965. _processLateAnimationBindingsForQuaternions(holder: {
  9966. totalWeight: number;
  9967. animations: RuntimeAnimation[];
  9968. originalValue: Quaternion;
  9969. }, refQuaternion: Quaternion): Quaternion;
  9970. /** @hidden */
  9971. _processLateAnimationBindings(): void;
  9972. /**
  9973. * Will start the animation sequence of a given target
  9974. * @param target defines the target
  9975. * @param from defines from which frame should animation start
  9976. * @param to defines until which frame should animation run.
  9977. * @param weight defines the weight to apply to the animation (1.0 by default)
  9978. * @param loop defines if the animation loops
  9979. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9980. * @param onAnimationEnd defines the function to be executed when the animation ends
  9981. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9982. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9983. * @param onAnimationLoop defines the callback to call when an animation loops
  9984. * @returns the animatable object created for this animation
  9985. */
  9986. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9987. /**
  9988. * Will start the animation sequence of a given target
  9989. * @param target defines the target
  9990. * @param from defines from which frame should animation start
  9991. * @param to defines until which frame should animation run.
  9992. * @param loop defines if the animation loops
  9993. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9994. * @param onAnimationEnd defines the function to be executed when the animation ends
  9995. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9996. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9997. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9998. * @param onAnimationLoop defines the callback to call when an animation loops
  9999. * @returns the animatable object created for this animation
  10000. */
  10001. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10002. /**
  10003. * Will start the animation sequence of a given target and its hierarchy
  10004. * @param target defines the target
  10005. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  10006. * @param from defines from which frame should animation start
  10007. * @param to defines until which frame should animation run.
  10008. * @param loop defines if the animation loops
  10009. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10010. * @param onAnimationEnd defines the function to be executed when the animation ends
  10011. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10012. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10013. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10014. * @param onAnimationLoop defines the callback to call when an animation loops
  10015. * @returns the list of created animatables
  10016. */
  10017. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  10018. /**
  10019. * Begin a new animation on a given node
  10020. * @param target defines the target where the animation will take place
  10021. * @param animations defines the list of animations to start
  10022. * @param from defines the initial value
  10023. * @param to defines the final value
  10024. * @param loop defines if you want animation to loop (off by default)
  10025. * @param speedRatio defines the speed ratio to apply to all animations
  10026. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10027. * @param onAnimationLoop defines the callback to call when an animation loops
  10028. * @returns the list of created animatables
  10029. */
  10030. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10031. /**
  10032. * Begin a new animation on a given node and its hierarchy
  10033. * @param target defines the root node where the animation will take place
  10034. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  10035. * @param animations defines the list of animations to start
  10036. * @param from defines the initial value
  10037. * @param to defines the final value
  10038. * @param loop defines if you want animation to loop (off by default)
  10039. * @param speedRatio defines the speed ratio to apply to all animations
  10040. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10041. * @param onAnimationLoop defines the callback to call when an animation loops
  10042. * @returns the list of animatables created for all nodes
  10043. */
  10044. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10045. /**
  10046. * Gets the animatable associated with a specific target
  10047. * @param target defines the target of the animatable
  10048. * @returns the required animatable if found
  10049. */
  10050. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10051. /**
  10052. * Gets all animatables associated with a given target
  10053. * @param target defines the target to look animatables for
  10054. * @returns an array of Animatables
  10055. */
  10056. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10057. /**
  10058. * Stops and removes all animations that have been applied to the scene
  10059. */
  10060. stopAllAnimations(): void;
  10061. }
  10062. }
  10063. module "babylonjs/Bones/bone" {
  10064. interface Bone {
  10065. /**
  10066. * Copy an animation range from another bone
  10067. * @param source defines the source bone
  10068. * @param rangeName defines the range name to copy
  10069. * @param frameOffset defines the frame offset
  10070. * @param rescaleAsRequired defines if rescaling must be applied if required
  10071. * @param skelDimensionsRatio defines the scaling ratio
  10072. * @returns true if operation was successful
  10073. */
  10074. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10075. }
  10076. }
  10077. }
  10078. declare module "babylonjs/Bones/skeleton" {
  10079. import { Bone } from "babylonjs/Bones/bone";
  10080. import { IAnimatable } from "babylonjs/Misc/tools";
  10081. import { Observable } from "babylonjs/Misc/observable";
  10082. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10083. import { Scene } from "babylonjs/scene";
  10084. import { Nullable } from "babylonjs/types";
  10085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10086. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10087. import { Animatable } from "babylonjs/Animations/animatable";
  10088. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10089. import { Animation } from "babylonjs/Animations/animation";
  10090. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10091. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10092. /**
  10093. * Class used to handle skinning animations
  10094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10095. */
  10096. export class Skeleton implements IAnimatable {
  10097. /** defines the skeleton name */
  10098. name: string;
  10099. /** defines the skeleton Id */
  10100. id: string;
  10101. /**
  10102. * Defines the list of child bones
  10103. */
  10104. bones: Bone[];
  10105. /**
  10106. * Defines an estimate of the dimension of the skeleton at rest
  10107. */
  10108. dimensionsAtRest: Vector3;
  10109. /**
  10110. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10111. */
  10112. needInitialSkinMatrix: boolean;
  10113. /**
  10114. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10115. */
  10116. overrideMesh: Nullable<AbstractMesh>;
  10117. /**
  10118. * Gets the list of animations attached to this skeleton
  10119. */
  10120. animations: Array<Animation>;
  10121. private _scene;
  10122. private _isDirty;
  10123. private _transformMatrices;
  10124. private _transformMatrixTexture;
  10125. private _meshesWithPoseMatrix;
  10126. private _animatables;
  10127. private _identity;
  10128. private _synchronizedWithMesh;
  10129. private _ranges;
  10130. private _lastAbsoluteTransformsUpdateId;
  10131. private _canUseTextureForBones;
  10132. private _uniqueId;
  10133. /** @hidden */
  10134. _numBonesWithLinkedTransformNode: number;
  10135. /** @hidden */
  10136. _hasWaitingData: Nullable<boolean>;
  10137. /**
  10138. * Specifies if the skeleton should be serialized
  10139. */
  10140. doNotSerialize: boolean;
  10141. private _useTextureToStoreBoneMatrices;
  10142. /**
  10143. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10144. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  10145. */
  10146. useTextureToStoreBoneMatrices: boolean;
  10147. private _animationPropertiesOverride;
  10148. /**
  10149. * Gets or sets the animation properties override
  10150. */
  10151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10152. /**
  10153. * List of inspectable custom properties (used by the Inspector)
  10154. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10155. */
  10156. inspectableCustomProperties: IInspectable[];
  10157. /**
  10158. * An observable triggered before computing the skeleton's matrices
  10159. */
  10160. onBeforeComputeObservable: Observable<Skeleton>;
  10161. /**
  10162. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10163. */
  10164. readonly isUsingTextureForMatrices: boolean;
  10165. /**
  10166. * Gets the unique ID of this skeleton
  10167. */
  10168. readonly uniqueId: number;
  10169. /**
  10170. * Creates a new skeleton
  10171. * @param name defines the skeleton name
  10172. * @param id defines the skeleton Id
  10173. * @param scene defines the hosting scene
  10174. */
  10175. constructor(
  10176. /** defines the skeleton name */
  10177. name: string,
  10178. /** defines the skeleton Id */
  10179. id: string, scene: Scene);
  10180. /**
  10181. * Gets the current object class name.
  10182. * @return the class name
  10183. */
  10184. getClassName(): string;
  10185. /**
  10186. * Returns an array containing the root bones
  10187. * @returns an array containing the root bones
  10188. */
  10189. getChildren(): Array<Bone>;
  10190. /**
  10191. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10192. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10193. * @returns a Float32Array containing matrices data
  10194. */
  10195. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10196. /**
  10197. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10198. * @returns a raw texture containing the data
  10199. */
  10200. getTransformMatrixTexture(): Nullable<RawTexture>;
  10201. /**
  10202. * Gets the current hosting scene
  10203. * @returns a scene object
  10204. */
  10205. getScene(): Scene;
  10206. /**
  10207. * Gets a string representing the current skeleton data
  10208. * @param fullDetails defines a boolean indicating if we want a verbose version
  10209. * @returns a string representing the current skeleton data
  10210. */
  10211. toString(fullDetails?: boolean): string;
  10212. /**
  10213. * Get bone's index searching by name
  10214. * @param name defines bone's name to search for
  10215. * @return the indice of the bone. Returns -1 if not found
  10216. */
  10217. getBoneIndexByName(name: string): number;
  10218. /**
  10219. * Creater a new animation range
  10220. * @param name defines the name of the range
  10221. * @param from defines the start key
  10222. * @param to defines the end key
  10223. */
  10224. createAnimationRange(name: string, from: number, to: number): void;
  10225. /**
  10226. * Delete a specific animation range
  10227. * @param name defines the name of the range
  10228. * @param deleteFrames defines if frames must be removed as well
  10229. */
  10230. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10231. /**
  10232. * Gets a specific animation range
  10233. * @param name defines the name of the range to look for
  10234. * @returns the requested animation range or null if not found
  10235. */
  10236. getAnimationRange(name: string): Nullable<AnimationRange>;
  10237. /**
  10238. * Gets the list of all animation ranges defined on this skeleton
  10239. * @returns an array
  10240. */
  10241. getAnimationRanges(): Nullable<AnimationRange>[];
  10242. /**
  10243. * Copy animation range from a source skeleton.
  10244. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10245. * @param source defines the source skeleton
  10246. * @param name defines the name of the range to copy
  10247. * @param rescaleAsRequired defines if rescaling must be applied if required
  10248. * @returns true if operation was successful
  10249. */
  10250. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10251. /**
  10252. * Forces the skeleton to go to rest pose
  10253. */
  10254. returnToRest(): void;
  10255. private _getHighestAnimationFrame;
  10256. /**
  10257. * Begin a specific animation range
  10258. * @param name defines the name of the range to start
  10259. * @param loop defines if looping must be turned on (false by default)
  10260. * @param speedRatio defines the speed ratio to apply (1 by default)
  10261. * @param onAnimationEnd defines a callback which will be called when animation will end
  10262. * @returns a new animatable
  10263. */
  10264. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10265. /** @hidden */
  10266. _markAsDirty(): void;
  10267. /** @hidden */
  10268. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10269. /** @hidden */
  10270. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10271. private _computeTransformMatrices;
  10272. /**
  10273. * Build all resources required to render a skeleton
  10274. */
  10275. prepare(): void;
  10276. /**
  10277. * Gets the list of animatables currently running for this skeleton
  10278. * @returns an array of animatables
  10279. */
  10280. getAnimatables(): IAnimatable[];
  10281. /**
  10282. * Clone the current skeleton
  10283. * @param name defines the name of the new skeleton
  10284. * @param id defines the id of the new skeleton
  10285. * @returns the new skeleton
  10286. */
  10287. clone(name: string, id: string): Skeleton;
  10288. /**
  10289. * Enable animation blending for this skeleton
  10290. * @param blendingSpeed defines the blending speed to apply
  10291. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10292. */
  10293. enableBlending(blendingSpeed?: number): void;
  10294. /**
  10295. * Releases all resources associated with the current skeleton
  10296. */
  10297. dispose(): void;
  10298. /**
  10299. * Serialize the skeleton in a JSON object
  10300. * @returns a JSON object
  10301. */
  10302. serialize(): any;
  10303. /**
  10304. * Creates a new skeleton from serialized data
  10305. * @param parsedSkeleton defines the serialized data
  10306. * @param scene defines the hosting scene
  10307. * @returns a new skeleton
  10308. */
  10309. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10310. /**
  10311. * Compute all node absolute transforms
  10312. * @param forceUpdate defines if computation must be done even if cache is up to date
  10313. */
  10314. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10315. /**
  10316. * Gets the root pose matrix
  10317. * @returns a matrix
  10318. */
  10319. getPoseMatrix(): Nullable<Matrix>;
  10320. /**
  10321. * Sorts bones per internal index
  10322. */
  10323. sortBones(): void;
  10324. private _sortBones;
  10325. }
  10326. }
  10327. declare module "babylonjs/Morph/morphTarget" {
  10328. import { IAnimatable } from "babylonjs/Misc/tools";
  10329. import { Observable } from "babylonjs/Misc/observable";
  10330. import { Nullable, FloatArray } from "babylonjs/types";
  10331. import { Scene } from "babylonjs/scene";
  10332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10333. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10334. /**
  10335. * Defines a target to use with MorphTargetManager
  10336. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10337. */
  10338. export class MorphTarget implements IAnimatable {
  10339. /** defines the name of the target */
  10340. name: string;
  10341. /**
  10342. * Gets or sets the list of animations
  10343. */
  10344. animations: import("babylonjs/Animations/animation").Animation[];
  10345. private _scene;
  10346. private _positions;
  10347. private _normals;
  10348. private _tangents;
  10349. private _influence;
  10350. /**
  10351. * Observable raised when the influence changes
  10352. */
  10353. onInfluenceChanged: Observable<boolean>;
  10354. /** @hidden */
  10355. _onDataLayoutChanged: Observable<void>;
  10356. /**
  10357. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10358. */
  10359. influence: number;
  10360. /**
  10361. * Gets or sets the id of the morph Target
  10362. */
  10363. id: string;
  10364. private _animationPropertiesOverride;
  10365. /**
  10366. * Gets or sets the animation properties override
  10367. */
  10368. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10369. /**
  10370. * Creates a new MorphTarget
  10371. * @param name defines the name of the target
  10372. * @param influence defines the influence to use
  10373. * @param scene defines the scene the morphtarget belongs to
  10374. */
  10375. constructor(
  10376. /** defines the name of the target */
  10377. name: string, influence?: number, scene?: Nullable<Scene>);
  10378. /**
  10379. * Gets a boolean defining if the target contains position data
  10380. */
  10381. readonly hasPositions: boolean;
  10382. /**
  10383. * Gets a boolean defining if the target contains normal data
  10384. */
  10385. readonly hasNormals: boolean;
  10386. /**
  10387. * Gets a boolean defining if the target contains tangent data
  10388. */
  10389. readonly hasTangents: boolean;
  10390. /**
  10391. * Affects position data to this target
  10392. * @param data defines the position data to use
  10393. */
  10394. setPositions(data: Nullable<FloatArray>): void;
  10395. /**
  10396. * Gets the position data stored in this target
  10397. * @returns a FloatArray containing the position data (or null if not present)
  10398. */
  10399. getPositions(): Nullable<FloatArray>;
  10400. /**
  10401. * Affects normal data to this target
  10402. * @param data defines the normal data to use
  10403. */
  10404. setNormals(data: Nullable<FloatArray>): void;
  10405. /**
  10406. * Gets the normal data stored in this target
  10407. * @returns a FloatArray containing the normal data (or null if not present)
  10408. */
  10409. getNormals(): Nullable<FloatArray>;
  10410. /**
  10411. * Affects tangent data to this target
  10412. * @param data defines the tangent data to use
  10413. */
  10414. setTangents(data: Nullable<FloatArray>): void;
  10415. /**
  10416. * Gets the tangent data stored in this target
  10417. * @returns a FloatArray containing the tangent data (or null if not present)
  10418. */
  10419. getTangents(): Nullable<FloatArray>;
  10420. /**
  10421. * Serializes the current target into a Serialization object
  10422. * @returns the serialized object
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Returns the string "MorphTarget"
  10427. * @returns "MorphTarget"
  10428. */
  10429. getClassName(): string;
  10430. /**
  10431. * Creates a new target from serialized data
  10432. * @param serializationObject defines the serialized data to use
  10433. * @returns a new MorphTarget
  10434. */
  10435. static Parse(serializationObject: any): MorphTarget;
  10436. /**
  10437. * Creates a MorphTarget from mesh data
  10438. * @param mesh defines the source mesh
  10439. * @param name defines the name to use for the new target
  10440. * @param influence defines the influence to attach to the target
  10441. * @returns a new MorphTarget
  10442. */
  10443. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10444. }
  10445. }
  10446. declare module "babylonjs/Morph/morphTargetManager" {
  10447. import { Nullable } from "babylonjs/types";
  10448. import { Scene } from "babylonjs/scene";
  10449. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10450. /**
  10451. * This class is used to deform meshes using morphing between different targets
  10452. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10453. */
  10454. export class MorphTargetManager {
  10455. private _targets;
  10456. private _targetInfluenceChangedObservers;
  10457. private _targetDataLayoutChangedObservers;
  10458. private _activeTargets;
  10459. private _scene;
  10460. private _influences;
  10461. private _supportsNormals;
  10462. private _supportsTangents;
  10463. private _vertexCount;
  10464. private _uniqueId;
  10465. private _tempInfluences;
  10466. /**
  10467. * Creates a new MorphTargetManager
  10468. * @param scene defines the current scene
  10469. */
  10470. constructor(scene?: Nullable<Scene>);
  10471. /**
  10472. * Gets the unique ID of this manager
  10473. */
  10474. readonly uniqueId: number;
  10475. /**
  10476. * Gets the number of vertices handled by this manager
  10477. */
  10478. readonly vertexCount: number;
  10479. /**
  10480. * Gets a boolean indicating if this manager supports morphing of normals
  10481. */
  10482. readonly supportsNormals: boolean;
  10483. /**
  10484. * Gets a boolean indicating if this manager supports morphing of tangents
  10485. */
  10486. readonly supportsTangents: boolean;
  10487. /**
  10488. * Gets the number of targets stored in this manager
  10489. */
  10490. readonly numTargets: number;
  10491. /**
  10492. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10493. */
  10494. readonly numInfluencers: number;
  10495. /**
  10496. * Gets the list of influences (one per target)
  10497. */
  10498. readonly influences: Float32Array;
  10499. /**
  10500. * Gets the active target at specified index. An active target is a target with an influence > 0
  10501. * @param index defines the index to check
  10502. * @returns the requested target
  10503. */
  10504. getActiveTarget(index: number): MorphTarget;
  10505. /**
  10506. * Gets the target at specified index
  10507. * @param index defines the index to check
  10508. * @returns the requested target
  10509. */
  10510. getTarget(index: number): MorphTarget;
  10511. /**
  10512. * Add a new target to this manager
  10513. * @param target defines the target to add
  10514. */
  10515. addTarget(target: MorphTarget): void;
  10516. /**
  10517. * Removes a target from the manager
  10518. * @param target defines the target to remove
  10519. */
  10520. removeTarget(target: MorphTarget): void;
  10521. /**
  10522. * Serializes the current manager into a Serialization object
  10523. * @returns the serialized object
  10524. */
  10525. serialize(): any;
  10526. private _syncActiveTargets;
  10527. /**
  10528. * Syncrhonize the targets with all the meshes using this morph target manager
  10529. */
  10530. synchronize(): void;
  10531. /**
  10532. * Creates a new MorphTargetManager from serialized data
  10533. * @param serializationObject defines the serialized data
  10534. * @param scene defines the hosting scene
  10535. * @returns the new MorphTargetManager
  10536. */
  10537. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10538. }
  10539. }
  10540. declare module "babylonjs/sceneComponent" {
  10541. import { Scene } from "babylonjs/scene";
  10542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10544. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10545. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10546. import { Nullable } from "babylonjs/types";
  10547. import { Camera } from "babylonjs/Cameras/camera";
  10548. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10549. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10550. import { AbstractScene } from "babylonjs/abstractScene";
  10551. /**
  10552. * Groups all the scene component constants in one place to ease maintenance.
  10553. * @hidden
  10554. */
  10555. export class SceneComponentConstants {
  10556. static readonly NAME_EFFECTLAYER: string;
  10557. static readonly NAME_LAYER: string;
  10558. static readonly NAME_LENSFLARESYSTEM: string;
  10559. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10560. static readonly NAME_PARTICLESYSTEM: string;
  10561. static readonly NAME_GAMEPAD: string;
  10562. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10563. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10564. static readonly NAME_DEPTHRENDERER: string;
  10565. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10566. static readonly NAME_SPRITE: string;
  10567. static readonly NAME_OUTLINERENDERER: string;
  10568. static readonly NAME_PROCEDURALTEXTURE: string;
  10569. static readonly NAME_SHADOWGENERATOR: string;
  10570. static readonly NAME_OCTREE: string;
  10571. static readonly NAME_PHYSICSENGINE: string;
  10572. static readonly NAME_AUDIO: string;
  10573. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10574. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10575. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10576. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10577. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10578. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10579. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10580. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10581. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10582. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10583. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10584. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10585. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10586. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10587. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10588. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10589. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10590. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10591. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10592. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10593. static readonly STEP_AFTERRENDER_AUDIO: number;
  10594. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10595. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10596. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10597. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10598. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10599. static readonly STEP_POINTERMOVE_SPRITE: number;
  10600. static readonly STEP_POINTERDOWN_SPRITE: number;
  10601. static readonly STEP_POINTERUP_SPRITE: number;
  10602. }
  10603. /**
  10604. * This represents a scene component.
  10605. *
  10606. * This is used to decouple the dependency the scene is having on the different workloads like
  10607. * layers, post processes...
  10608. */
  10609. export interface ISceneComponent {
  10610. /**
  10611. * The name of the component. Each component must have a unique name.
  10612. */
  10613. name: string;
  10614. /**
  10615. * The scene the component belongs to.
  10616. */
  10617. scene: Scene;
  10618. /**
  10619. * Register the component to one instance of a scene.
  10620. */
  10621. register(): void;
  10622. /**
  10623. * Rebuilds the elements related to this component in case of
  10624. * context lost for instance.
  10625. */
  10626. rebuild(): void;
  10627. /**
  10628. * Disposes the component and the associated ressources.
  10629. */
  10630. dispose(): void;
  10631. }
  10632. /**
  10633. * This represents a SERIALIZABLE scene component.
  10634. *
  10635. * This extends Scene Component to add Serialization methods on top.
  10636. */
  10637. export interface ISceneSerializableComponent extends ISceneComponent {
  10638. /**
  10639. * Adds all the elements from the container to the scene
  10640. * @param container the container holding the elements
  10641. */
  10642. addFromContainer(container: AbstractScene): void;
  10643. /**
  10644. * Removes all the elements in the container from the scene
  10645. * @param container contains the elements to remove
  10646. * @param dispose if the removed element should be disposed (default: false)
  10647. */
  10648. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10649. /**
  10650. * Serializes the component data to the specified json object
  10651. * @param serializationObject The object to serialize to
  10652. */
  10653. serialize(serializationObject: any): void;
  10654. }
  10655. /**
  10656. * Strong typing of a Mesh related stage step action
  10657. */
  10658. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10659. /**
  10660. * Strong typing of a Evaluate Sub Mesh related stage step action
  10661. */
  10662. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10663. /**
  10664. * Strong typing of a Active Mesh related stage step action
  10665. */
  10666. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10667. /**
  10668. * Strong typing of a Camera related stage step action
  10669. */
  10670. export type CameraStageAction = (camera: Camera) => void;
  10671. /**
  10672. * Strong typing of a Camera Frame buffer related stage step action
  10673. */
  10674. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10675. /**
  10676. * Strong typing of a Render Target related stage step action
  10677. */
  10678. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10679. /**
  10680. * Strong typing of a RenderingGroup related stage step action
  10681. */
  10682. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10683. /**
  10684. * Strong typing of a Mesh Render related stage step action
  10685. */
  10686. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10687. /**
  10688. * Strong typing of a simple stage step action
  10689. */
  10690. export type SimpleStageAction = () => void;
  10691. /**
  10692. * Strong typing of a render target action.
  10693. */
  10694. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10695. /**
  10696. * Strong typing of a pointer move action.
  10697. */
  10698. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10699. /**
  10700. * Strong typing of a pointer up/down action.
  10701. */
  10702. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10703. /**
  10704. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10705. * @hidden
  10706. */
  10707. export class Stage<T extends Function> extends Array<{
  10708. index: number;
  10709. component: ISceneComponent;
  10710. action: T;
  10711. }> {
  10712. /**
  10713. * Hide ctor from the rest of the world.
  10714. * @param items The items to add.
  10715. */
  10716. private constructor();
  10717. /**
  10718. * Creates a new Stage.
  10719. * @returns A new instance of a Stage
  10720. */
  10721. static Create<T extends Function>(): Stage<T>;
  10722. /**
  10723. * Registers a step in an ordered way in the targeted stage.
  10724. * @param index Defines the position to register the step in
  10725. * @param component Defines the component attached to the step
  10726. * @param action Defines the action to launch during the step
  10727. */
  10728. registerStep(index: number, component: ISceneComponent, action: T): void;
  10729. /**
  10730. * Clears all the steps from the stage.
  10731. */
  10732. clear(): void;
  10733. }
  10734. }
  10735. declare module "babylonjs/Meshes/meshLODLevel" {
  10736. import { Mesh } from "babylonjs/Meshes/mesh";
  10737. import { Nullable } from "babylonjs/types";
  10738. /**
  10739. * Class used to represent a specific level of detail of a mesh
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10741. */
  10742. export class MeshLODLevel {
  10743. /** Defines the distance where this level should star being displayed */
  10744. distance: number;
  10745. /** Defines the mesh to use to render this level */
  10746. mesh: Nullable<Mesh>;
  10747. /**
  10748. * Creates a new LOD level
  10749. * @param distance defines the distance where this level should star being displayed
  10750. * @param mesh defines the mesh to use to render this level
  10751. */
  10752. constructor(
  10753. /** Defines the distance where this level should star being displayed */
  10754. distance: number,
  10755. /** Defines the mesh to use to render this level */
  10756. mesh: Nullable<Mesh>);
  10757. }
  10758. }
  10759. declare module "babylonjs/Lights/shadowLight" {
  10760. import { Camera } from "babylonjs/Cameras/camera";
  10761. import { Scene } from "babylonjs/scene";
  10762. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10764. import { Light } from "babylonjs/Lights/light";
  10765. /**
  10766. * Interface describing all the common properties and methods a shadow light needs to implement.
  10767. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10768. * as well as binding the different shadow properties to the effects.
  10769. */
  10770. export interface IShadowLight extends Light {
  10771. /**
  10772. * The light id in the scene (used in scene.findLighById for instance)
  10773. */
  10774. id: string;
  10775. /**
  10776. * The position the shdow will be casted from.
  10777. */
  10778. position: Vector3;
  10779. /**
  10780. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10781. */
  10782. direction: Vector3;
  10783. /**
  10784. * The transformed position. Position of the light in world space taking parenting in account.
  10785. */
  10786. transformedPosition: Vector3;
  10787. /**
  10788. * The transformed direction. Direction of the light in world space taking parenting in account.
  10789. */
  10790. transformedDirection: Vector3;
  10791. /**
  10792. * The friendly name of the light in the scene.
  10793. */
  10794. name: string;
  10795. /**
  10796. * Defines the shadow projection clipping minimum z value.
  10797. */
  10798. shadowMinZ: number;
  10799. /**
  10800. * Defines the shadow projection clipping maximum z value.
  10801. */
  10802. shadowMaxZ: number;
  10803. /**
  10804. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10805. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10806. */
  10807. computeTransformedInformation(): boolean;
  10808. /**
  10809. * Gets the scene the light belongs to.
  10810. * @returns The scene
  10811. */
  10812. getScene(): Scene;
  10813. /**
  10814. * Callback defining a custom Projection Matrix Builder.
  10815. * This can be used to override the default projection matrix computation.
  10816. */
  10817. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10818. /**
  10819. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10820. * @param matrix The materix to updated with the projection information
  10821. * @param viewMatrix The transform matrix of the light
  10822. * @param renderList The list of mesh to render in the map
  10823. * @returns The current light
  10824. */
  10825. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10826. /**
  10827. * Gets the current depth scale used in ESM.
  10828. * @returns The scale
  10829. */
  10830. getDepthScale(): number;
  10831. /**
  10832. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10833. * @returns true if a cube texture needs to be use
  10834. */
  10835. needCube(): boolean;
  10836. /**
  10837. * Detects if the projection matrix requires to be recomputed this frame.
  10838. * @returns true if it requires to be recomputed otherwise, false.
  10839. */
  10840. needProjectionMatrixCompute(): boolean;
  10841. /**
  10842. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10843. */
  10844. forceProjectionMatrixCompute(): void;
  10845. /**
  10846. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10847. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10848. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10849. */
  10850. getShadowDirection(faceIndex?: number): Vector3;
  10851. /**
  10852. * Gets the minZ used for shadow according to both the scene and the light.
  10853. * @param activeCamera The camera we are returning the min for
  10854. * @returns the depth min z
  10855. */
  10856. getDepthMinZ(activeCamera: Camera): number;
  10857. /**
  10858. * Gets the maxZ used for shadow according to both the scene and the light.
  10859. * @param activeCamera The camera we are returning the max for
  10860. * @returns the depth max z
  10861. */
  10862. getDepthMaxZ(activeCamera: Camera): number;
  10863. }
  10864. /**
  10865. * Base implementation IShadowLight
  10866. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10867. */
  10868. export abstract class ShadowLight extends Light implements IShadowLight {
  10869. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10870. protected _position: Vector3;
  10871. protected _setPosition(value: Vector3): void;
  10872. /**
  10873. * Sets the position the shadow will be casted from. Also use as the light position for both
  10874. * point and spot lights.
  10875. */
  10876. /**
  10877. * Sets the position the shadow will be casted from. Also use as the light position for both
  10878. * point and spot lights.
  10879. */
  10880. position: Vector3;
  10881. protected _direction: Vector3;
  10882. protected _setDirection(value: Vector3): void;
  10883. /**
  10884. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10885. * Also use as the light direction on spot and directional lights.
  10886. */
  10887. /**
  10888. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10889. * Also use as the light direction on spot and directional lights.
  10890. */
  10891. direction: Vector3;
  10892. private _shadowMinZ;
  10893. /**
  10894. * Gets the shadow projection clipping minimum z value.
  10895. */
  10896. /**
  10897. * Sets the shadow projection clipping minimum z value.
  10898. */
  10899. shadowMinZ: number;
  10900. private _shadowMaxZ;
  10901. /**
  10902. * Sets the shadow projection clipping maximum z value.
  10903. */
  10904. /**
  10905. * Gets the shadow projection clipping maximum z value.
  10906. */
  10907. shadowMaxZ: number;
  10908. /**
  10909. * Callback defining a custom Projection Matrix Builder.
  10910. * This can be used to override the default projection matrix computation.
  10911. */
  10912. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10913. /**
  10914. * The transformed position. Position of the light in world space taking parenting in account.
  10915. */
  10916. transformedPosition: Vector3;
  10917. /**
  10918. * The transformed direction. Direction of the light in world space taking parenting in account.
  10919. */
  10920. transformedDirection: Vector3;
  10921. private _needProjectionMatrixCompute;
  10922. /**
  10923. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10924. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10925. */
  10926. computeTransformedInformation(): boolean;
  10927. /**
  10928. * Return the depth scale used for the shadow map.
  10929. * @returns the depth scale.
  10930. */
  10931. getDepthScale(): number;
  10932. /**
  10933. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10934. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10935. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10936. */
  10937. getShadowDirection(faceIndex?: number): Vector3;
  10938. /**
  10939. * Returns the ShadowLight absolute position in the World.
  10940. * @returns the position vector in world space
  10941. */
  10942. getAbsolutePosition(): Vector3;
  10943. /**
  10944. * Sets the ShadowLight direction toward the passed target.
  10945. * @param target The point to target in local space
  10946. * @returns the updated ShadowLight direction
  10947. */
  10948. setDirectionToTarget(target: Vector3): Vector3;
  10949. /**
  10950. * Returns the light rotation in euler definition.
  10951. * @returns the x y z rotation in local space.
  10952. */
  10953. getRotation(): Vector3;
  10954. /**
  10955. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10956. * @returns true if a cube texture needs to be use
  10957. */
  10958. needCube(): boolean;
  10959. /**
  10960. * Detects if the projection matrix requires to be recomputed this frame.
  10961. * @returns true if it requires to be recomputed otherwise, false.
  10962. */
  10963. needProjectionMatrixCompute(): boolean;
  10964. /**
  10965. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10966. */
  10967. forceProjectionMatrixCompute(): void;
  10968. /** @hidden */
  10969. _initCache(): void;
  10970. /** @hidden */
  10971. _isSynchronized(): boolean;
  10972. /**
  10973. * Computes the world matrix of the node
  10974. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10975. * @returns the world matrix
  10976. */
  10977. computeWorldMatrix(force?: boolean): Matrix;
  10978. /**
  10979. * Gets the minZ used for shadow according to both the scene and the light.
  10980. * @param activeCamera The camera we are returning the min for
  10981. * @returns the depth min z
  10982. */
  10983. getDepthMinZ(activeCamera: Camera): number;
  10984. /**
  10985. * Gets the maxZ used for shadow according to both the scene and the light.
  10986. * @param activeCamera The camera we are returning the max for
  10987. * @returns the depth max z
  10988. */
  10989. getDepthMaxZ(activeCamera: Camera): number;
  10990. /**
  10991. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10992. * @param matrix The materix to updated with the projection information
  10993. * @param viewMatrix The transform matrix of the light
  10994. * @param renderList The list of mesh to render in the map
  10995. * @returns The current light
  10996. */
  10997. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10998. }
  10999. }
  11000. declare module "babylonjs/Materials/materialHelper" {
  11001. import { Nullable } from "babylonjs/types";
  11002. import { Scene } from "babylonjs/scene";
  11003. import { Engine } from "babylonjs/Engines/engine";
  11004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11005. import { Light } from "babylonjs/Lights/light";
  11006. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11007. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11009. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11010. /**
  11011. * "Static Class" containing the most commonly used helper while dealing with material for
  11012. * rendering purpose.
  11013. *
  11014. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11015. *
  11016. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11017. */
  11018. export class MaterialHelper {
  11019. /**
  11020. * Bind the current view position to an effect.
  11021. * @param effect The effect to be bound
  11022. * @param scene The scene the eyes position is used from
  11023. */
  11024. static BindEyePosition(effect: Effect, scene: Scene): void;
  11025. /**
  11026. * Helps preparing the defines values about the UVs in used in the effect.
  11027. * UVs are shared as much as we can accross channels in the shaders.
  11028. * @param texture The texture we are preparing the UVs for
  11029. * @param defines The defines to update
  11030. * @param key The channel key "diffuse", "specular"... used in the shader
  11031. */
  11032. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11033. /**
  11034. * Binds a texture matrix value to its corrsponding uniform
  11035. * @param texture The texture to bind the matrix for
  11036. * @param uniformBuffer The uniform buffer receivin the data
  11037. * @param key The channel key "diffuse", "specular"... used in the shader
  11038. */
  11039. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11040. /**
  11041. * Gets the current status of the fog (should it be enabled?)
  11042. * @param mesh defines the mesh to evaluate for fog support
  11043. * @param scene defines the hosting scene
  11044. * @returns true if fog must be enabled
  11045. */
  11046. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11047. /**
  11048. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11049. * @param mesh defines the current mesh
  11050. * @param scene defines the current scene
  11051. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11052. * @param pointsCloud defines if point cloud rendering has to be turned on
  11053. * @param fogEnabled defines if fog has to be turned on
  11054. * @param alphaTest defines if alpha testing has to be turned on
  11055. * @param defines defines the current list of defines
  11056. */
  11057. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11058. /**
  11059. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11060. * @param scene defines the current scene
  11061. * @param engine defines the current engine
  11062. * @param defines specifies the list of active defines
  11063. * @param useInstances defines if instances have to be turned on
  11064. * @param useClipPlane defines if clip plane have to be turned on
  11065. */
  11066. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11067. /**
  11068. * Prepares the defines for bones
  11069. * @param mesh The mesh containing the geometry data we will draw
  11070. * @param defines The defines to update
  11071. */
  11072. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11073. /**
  11074. * Prepares the defines for morph targets
  11075. * @param mesh The mesh containing the geometry data we will draw
  11076. * @param defines The defines to update
  11077. */
  11078. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11079. /**
  11080. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11081. * @param mesh The mesh containing the geometry data we will draw
  11082. * @param defines The defines to update
  11083. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11084. * @param useBones Precise whether bones should be used or not (override mesh info)
  11085. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11086. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11087. * @returns false if defines are considered not dirty and have not been checked
  11088. */
  11089. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11090. /**
  11091. * Prepares the defines related to multiview
  11092. * @param scene The scene we are intending to draw
  11093. * @param defines The defines to update
  11094. */
  11095. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11096. /**
  11097. * Prepares the defines related to the light information passed in parameter
  11098. * @param scene The scene we are intending to draw
  11099. * @param mesh The mesh the effect is compiling for
  11100. * @param defines The defines to update
  11101. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11102. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11103. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11104. * @returns true if normals will be required for the rest of the effect
  11105. */
  11106. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11107. /**
  11108. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  11109. * that won t be acctive due to defines being turned off.
  11110. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11111. * @param samplersList The samplers list
  11112. * @param defines The defines helping in the list generation
  11113. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11114. */
  11115. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11116. /**
  11117. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11118. * @param defines The defines to update while falling back
  11119. * @param fallbacks The authorized effect fallbacks
  11120. * @param maxSimultaneousLights The maximum number of lights allowed
  11121. * @param rank the current rank of the Effect
  11122. * @returns The newly affected rank
  11123. */
  11124. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11125. /**
  11126. * Prepares the list of attributes required for morph targets according to the effect defines.
  11127. * @param attribs The current list of supported attribs
  11128. * @param mesh The mesh to prepare the morph targets attributes for
  11129. * @param defines The current Defines of the effect
  11130. */
  11131. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11132. /**
  11133. * Prepares the list of attributes required for bones according to the effect defines.
  11134. * @param attribs The current list of supported attribs
  11135. * @param mesh The mesh to prepare the bones attributes for
  11136. * @param defines The current Defines of the effect
  11137. * @param fallbacks The current efffect fallback strategy
  11138. */
  11139. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11140. /**
  11141. * Check and prepare the list of attributes required for instances according to the effect defines.
  11142. * @param attribs The current list of supported attribs
  11143. * @param defines The current MaterialDefines of the effect
  11144. */
  11145. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11146. /**
  11147. * Add the list of attributes required for instances to the attribs array.
  11148. * @param attribs The current list of supported attribs
  11149. */
  11150. static PushAttributesForInstances(attribs: string[]): void;
  11151. /**
  11152. * Binds the light shadow information to the effect for the given mesh.
  11153. * @param light The light containing the generator
  11154. * @param scene The scene the lights belongs to
  11155. * @param mesh The mesh we are binding the information to render
  11156. * @param lightIndex The light index in the effect used to render the mesh
  11157. * @param effect The effect we are binding the data to
  11158. */
  11159. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11160. /**
  11161. * Binds the light information to the effect.
  11162. * @param light The light containing the generator
  11163. * @param effect The effect we are binding the data to
  11164. * @param lightIndex The light index in the effect used to render
  11165. */
  11166. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11167. /**
  11168. * Binds the lights information from the scene to the effect for the given mesh.
  11169. * @param scene The scene the lights belongs to
  11170. * @param mesh The mesh we are binding the information to render
  11171. * @param effect The effect we are binding the data to
  11172. * @param defines The generated defines for the effect
  11173. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11174. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11175. */
  11176. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11177. private static _tempFogColor;
  11178. /**
  11179. * Binds the fog information from the scene to the effect for the given mesh.
  11180. * @param scene The scene the lights belongs to
  11181. * @param mesh The mesh we are binding the information to render
  11182. * @param effect The effect we are binding the data to
  11183. * @param linearSpace Defines if the fog effect is applied in linear space
  11184. */
  11185. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11186. /**
  11187. * Binds the bones information from the mesh to the effect.
  11188. * @param mesh The mesh we are binding the information to render
  11189. * @param effect The effect we are binding the data to
  11190. */
  11191. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11192. /**
  11193. * Binds the morph targets information from the mesh to the effect.
  11194. * @param abstractMesh The mesh we are binding the information to render
  11195. * @param effect The effect we are binding the data to
  11196. */
  11197. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11198. /**
  11199. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11200. * @param defines The generated defines used in the effect
  11201. * @param effect The effect we are binding the data to
  11202. * @param scene The scene we are willing to render with logarithmic scale for
  11203. */
  11204. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11205. /**
  11206. * Binds the clip plane information from the scene to the effect.
  11207. * @param scene The scene the clip plane information are extracted from
  11208. * @param effect The effect we are binding the data to
  11209. */
  11210. static BindClipPlane(effect: Effect, scene: Scene): void;
  11211. }
  11212. }
  11213. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11214. /** @hidden */
  11215. export var shadowMapPixelShader: {
  11216. name: string;
  11217. shader: string;
  11218. };
  11219. }
  11220. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11221. /** @hidden */
  11222. export var bonesDeclaration: {
  11223. name: string;
  11224. shader: string;
  11225. };
  11226. }
  11227. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11228. /** @hidden */
  11229. export var morphTargetsVertexGlobalDeclaration: {
  11230. name: string;
  11231. shader: string;
  11232. };
  11233. }
  11234. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11235. /** @hidden */
  11236. export var morphTargetsVertexDeclaration: {
  11237. name: string;
  11238. shader: string;
  11239. };
  11240. }
  11241. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11242. /** @hidden */
  11243. export var instancesDeclaration: {
  11244. name: string;
  11245. shader: string;
  11246. };
  11247. }
  11248. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11249. /** @hidden */
  11250. export var helperFunctions: {
  11251. name: string;
  11252. shader: string;
  11253. };
  11254. }
  11255. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11256. /** @hidden */
  11257. export var morphTargetsVertex: {
  11258. name: string;
  11259. shader: string;
  11260. };
  11261. }
  11262. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11263. /** @hidden */
  11264. export var instancesVertex: {
  11265. name: string;
  11266. shader: string;
  11267. };
  11268. }
  11269. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11270. /** @hidden */
  11271. export var bonesVertex: {
  11272. name: string;
  11273. shader: string;
  11274. };
  11275. }
  11276. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11277. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11278. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11279. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11280. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11282. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11283. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11284. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11285. /** @hidden */
  11286. export var shadowMapVertexShader: {
  11287. name: string;
  11288. shader: string;
  11289. };
  11290. }
  11291. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11292. /** @hidden */
  11293. export var depthBoxBlurPixelShader: {
  11294. name: string;
  11295. shader: string;
  11296. };
  11297. }
  11298. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11299. import { Nullable } from "babylonjs/types";
  11300. import { Scene } from "babylonjs/scene";
  11301. import { Matrix } from "babylonjs/Maths/math";
  11302. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11304. import { Mesh } from "babylonjs/Meshes/mesh";
  11305. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11306. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11307. import { Effect } from "babylonjs/Materials/effect";
  11308. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11309. import "babylonjs/Shaders/shadowMap.fragment";
  11310. import "babylonjs/Shaders/shadowMap.vertex";
  11311. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11312. import { Observable } from "babylonjs/Misc/observable";
  11313. /**
  11314. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11315. */
  11316. export interface ICustomShaderOptions {
  11317. /**
  11318. * Gets or sets the custom shader name to use
  11319. */
  11320. shaderName: string;
  11321. /**
  11322. * The list of attribute names used in the shader
  11323. */
  11324. attributes?: string[];
  11325. /**
  11326. * The list of unifrom names used in the shader
  11327. */
  11328. uniforms?: string[];
  11329. /**
  11330. * The list of sampler names used in the shader
  11331. */
  11332. samplers?: string[];
  11333. /**
  11334. * The list of defines used in the shader
  11335. */
  11336. defines?: string[];
  11337. }
  11338. /**
  11339. * Interface to implement to create a shadow generator compatible with BJS.
  11340. */
  11341. export interface IShadowGenerator {
  11342. /**
  11343. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11344. * @returns The render target texture if present otherwise, null
  11345. */
  11346. getShadowMap(): Nullable<RenderTargetTexture>;
  11347. /**
  11348. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11349. * @returns The render target texture if the shadow map is present otherwise, null
  11350. */
  11351. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11352. /**
  11353. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11354. * @param subMesh The submesh we want to render in the shadow map
  11355. * @param useInstances Defines wether will draw in the map using instances
  11356. * @returns true if ready otherwise, false
  11357. */
  11358. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11359. /**
  11360. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11361. * @param defines Defines of the material we want to update
  11362. * @param lightIndex Index of the light in the enabled light list of the material
  11363. */
  11364. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11365. /**
  11366. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11367. * defined in the generator but impacting the effect).
  11368. * It implies the unifroms available on the materials are the standard BJS ones.
  11369. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11370. * @param effect The effect we are binfing the information for
  11371. */
  11372. bindShadowLight(lightIndex: string, effect: Effect): void;
  11373. /**
  11374. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11375. * (eq to shadow prjection matrix * light transform matrix)
  11376. * @returns The transform matrix used to create the shadow map
  11377. */
  11378. getTransformMatrix(): Matrix;
  11379. /**
  11380. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11381. * Cube and 2D textures for instance.
  11382. */
  11383. recreateShadowMap(): void;
  11384. /**
  11385. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11386. * @param onCompiled Callback triggered at the and of the effects compilation
  11387. * @param options Sets of optional options forcing the compilation with different modes
  11388. */
  11389. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11390. useInstances: boolean;
  11391. }>): void;
  11392. /**
  11393. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11394. * @param options Sets of optional options forcing the compilation with different modes
  11395. * @returns A promise that resolves when the compilation completes
  11396. */
  11397. forceCompilationAsync(options?: Partial<{
  11398. useInstances: boolean;
  11399. }>): Promise<void>;
  11400. /**
  11401. * Serializes the shadow generator setup to a json object.
  11402. * @returns The serialized JSON object
  11403. */
  11404. serialize(): any;
  11405. /**
  11406. * Disposes the Shadow map and related Textures and effects.
  11407. */
  11408. dispose(): void;
  11409. }
  11410. /**
  11411. * Default implementation IShadowGenerator.
  11412. * This is the main object responsible of generating shadows in the framework.
  11413. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11414. */
  11415. export class ShadowGenerator implements IShadowGenerator {
  11416. /**
  11417. * Shadow generator mode None: no filtering applied.
  11418. */
  11419. static readonly FILTER_NONE: number;
  11420. /**
  11421. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11422. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11423. */
  11424. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11425. /**
  11426. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11427. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11428. */
  11429. static readonly FILTER_POISSONSAMPLING: number;
  11430. /**
  11431. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11432. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11433. */
  11434. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11435. /**
  11436. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11437. * edge artifacts on steep falloff.
  11438. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11439. */
  11440. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11441. /**
  11442. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11443. * edge artifacts on steep falloff.
  11444. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11445. */
  11446. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11447. /**
  11448. * Shadow generator mode PCF: Percentage Closer Filtering
  11449. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11450. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11451. */
  11452. static readonly FILTER_PCF: number;
  11453. /**
  11454. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11455. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11456. * Contact Hardening
  11457. */
  11458. static readonly FILTER_PCSS: number;
  11459. /**
  11460. * Reserved for PCF and PCSS
  11461. * Highest Quality.
  11462. *
  11463. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11464. *
  11465. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11466. */
  11467. static readonly QUALITY_HIGH: number;
  11468. /**
  11469. * Reserved for PCF and PCSS
  11470. * Good tradeoff for quality/perf cross devices
  11471. *
  11472. * Execute PCF on a 3*3 kernel.
  11473. *
  11474. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11475. */
  11476. static readonly QUALITY_MEDIUM: number;
  11477. /**
  11478. * Reserved for PCF and PCSS
  11479. * The lowest quality but the fastest.
  11480. *
  11481. * Execute PCF on a 1*1 kernel.
  11482. *
  11483. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11484. */
  11485. static readonly QUALITY_LOW: number;
  11486. /** Gets or sets the custom shader name to use */
  11487. customShaderOptions: ICustomShaderOptions;
  11488. /**
  11489. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11490. */
  11491. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11492. /**
  11493. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11494. */
  11495. onAfterShadowMapRenderObservable: Observable<Effect>;
  11496. /**
  11497. * Observable triggered before a mesh is rendered in the shadow map.
  11498. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11499. */
  11500. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11501. /**
  11502. * Observable triggered after a mesh is rendered in the shadow map.
  11503. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11504. */
  11505. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11506. private _bias;
  11507. /**
  11508. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11509. */
  11510. /**
  11511. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11512. */
  11513. bias: number;
  11514. private _normalBias;
  11515. /**
  11516. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11517. */
  11518. /**
  11519. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11520. */
  11521. normalBias: number;
  11522. private _blurBoxOffset;
  11523. /**
  11524. * Gets the blur box offset: offset applied during the blur pass.
  11525. * Only useful if useKernelBlur = false
  11526. */
  11527. /**
  11528. * Sets the blur box offset: offset applied during the blur pass.
  11529. * Only useful if useKernelBlur = false
  11530. */
  11531. blurBoxOffset: number;
  11532. private _blurScale;
  11533. /**
  11534. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11535. * 2 means half of the size.
  11536. */
  11537. /**
  11538. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11539. * 2 means half of the size.
  11540. */
  11541. blurScale: number;
  11542. private _blurKernel;
  11543. /**
  11544. * Gets the blur kernel: kernel size of the blur pass.
  11545. * Only useful if useKernelBlur = true
  11546. */
  11547. /**
  11548. * Sets the blur kernel: kernel size of the blur pass.
  11549. * Only useful if useKernelBlur = true
  11550. */
  11551. blurKernel: number;
  11552. private _useKernelBlur;
  11553. /**
  11554. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11555. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11556. */
  11557. /**
  11558. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11559. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11560. */
  11561. useKernelBlur: boolean;
  11562. private _depthScale;
  11563. /**
  11564. * Gets the depth scale used in ESM mode.
  11565. */
  11566. /**
  11567. * Sets the depth scale used in ESM mode.
  11568. * This can override the scale stored on the light.
  11569. */
  11570. depthScale: number;
  11571. private _filter;
  11572. /**
  11573. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11574. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11575. */
  11576. /**
  11577. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11578. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11579. */
  11580. filter: number;
  11581. /**
  11582. * Gets if the current filter is set to Poisson Sampling.
  11583. */
  11584. /**
  11585. * Sets the current filter to Poisson Sampling.
  11586. */
  11587. usePoissonSampling: boolean;
  11588. /**
  11589. * Gets if the current filter is set to ESM.
  11590. */
  11591. /**
  11592. * Sets the current filter is to ESM.
  11593. */
  11594. useExponentialShadowMap: boolean;
  11595. /**
  11596. * Gets if the current filter is set to filtered ESM.
  11597. */
  11598. /**
  11599. * Gets if the current filter is set to filtered ESM.
  11600. */
  11601. useBlurExponentialShadowMap: boolean;
  11602. /**
  11603. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11604. * exponential to prevent steep falloff artifacts).
  11605. */
  11606. /**
  11607. * Sets the current filter to "close ESM" (using the inverse of the
  11608. * exponential to prevent steep falloff artifacts).
  11609. */
  11610. useCloseExponentialShadowMap: boolean;
  11611. /**
  11612. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11613. * exponential to prevent steep falloff artifacts).
  11614. */
  11615. /**
  11616. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11617. * exponential to prevent steep falloff artifacts).
  11618. */
  11619. useBlurCloseExponentialShadowMap: boolean;
  11620. /**
  11621. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11622. */
  11623. /**
  11624. * Sets the current filter to "PCF" (percentage closer filtering).
  11625. */
  11626. usePercentageCloserFiltering: boolean;
  11627. private _filteringQuality;
  11628. /**
  11629. * Gets the PCF or PCSS Quality.
  11630. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11631. */
  11632. /**
  11633. * Sets the PCF or PCSS Quality.
  11634. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11635. */
  11636. filteringQuality: number;
  11637. /**
  11638. * Gets if the current filter is set to "PCSS" (contact hardening).
  11639. */
  11640. /**
  11641. * Sets the current filter to "PCSS" (contact hardening).
  11642. */
  11643. useContactHardeningShadow: boolean;
  11644. private _contactHardeningLightSizeUVRatio;
  11645. /**
  11646. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11647. * Using a ratio helps keeping shape stability independently of the map size.
  11648. *
  11649. * It does not account for the light projection as it was having too much
  11650. * instability during the light setup or during light position changes.
  11651. *
  11652. * Only valid if useContactHardeningShadow is true.
  11653. */
  11654. /**
  11655. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11656. * Using a ratio helps keeping shape stability independently of the map size.
  11657. *
  11658. * It does not account for the light projection as it was having too much
  11659. * instability during the light setup or during light position changes.
  11660. *
  11661. * Only valid if useContactHardeningShadow is true.
  11662. */
  11663. contactHardeningLightSizeUVRatio: number;
  11664. private _darkness;
  11665. /** Gets or sets the actual darkness of a shadow */
  11666. darkness: number;
  11667. /**
  11668. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11669. * 0 means strongest and 1 would means no shadow.
  11670. * @returns the darkness.
  11671. */
  11672. getDarkness(): number;
  11673. /**
  11674. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11675. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11676. * @returns the shadow generator allowing fluent coding.
  11677. */
  11678. setDarkness(darkness: number): ShadowGenerator;
  11679. private _transparencyShadow;
  11680. /** Gets or sets the ability to have transparent shadow */
  11681. transparencyShadow: boolean;
  11682. /**
  11683. * Sets the ability to have transparent shadow (boolean).
  11684. * @param transparent True if transparent else False
  11685. * @returns the shadow generator allowing fluent coding
  11686. */
  11687. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11688. private _shadowMap;
  11689. private _shadowMap2;
  11690. /**
  11691. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11692. * @returns The render target texture if present otherwise, null
  11693. */
  11694. getShadowMap(): Nullable<RenderTargetTexture>;
  11695. /**
  11696. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11697. * @returns The render target texture if the shadow map is present otherwise, null
  11698. */
  11699. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11700. /**
  11701. * Gets the class name of that object
  11702. * @returns "ShadowGenerator"
  11703. */
  11704. getClassName(): string;
  11705. /**
  11706. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11707. * @param mesh Mesh to add
  11708. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11709. * @returns the Shadow Generator itself
  11710. */
  11711. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11712. /**
  11713. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11714. * @param mesh Mesh to remove
  11715. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11716. * @returns the Shadow Generator itself
  11717. */
  11718. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11719. /**
  11720. * Controls the extent to which the shadows fade out at the edge of the frustum
  11721. * Used only by directionals and spots
  11722. */
  11723. frustumEdgeFalloff: number;
  11724. private _light;
  11725. /**
  11726. * Returns the associated light object.
  11727. * @returns the light generating the shadow
  11728. */
  11729. getLight(): IShadowLight;
  11730. /**
  11731. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11732. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11733. * It might on the other hand introduce peter panning.
  11734. */
  11735. forceBackFacesOnly: boolean;
  11736. private _scene;
  11737. private _lightDirection;
  11738. private _effect;
  11739. private _viewMatrix;
  11740. private _projectionMatrix;
  11741. private _transformMatrix;
  11742. private _cachedPosition;
  11743. private _cachedDirection;
  11744. private _cachedDefines;
  11745. private _currentRenderID;
  11746. private _boxBlurPostprocess;
  11747. private _kernelBlurXPostprocess;
  11748. private _kernelBlurYPostprocess;
  11749. private _blurPostProcesses;
  11750. private _mapSize;
  11751. private _currentFaceIndex;
  11752. private _currentFaceIndexCache;
  11753. private _textureType;
  11754. private _defaultTextureMatrix;
  11755. /** @hidden */
  11756. static _SceneComponentInitialization: (scene: Scene) => void;
  11757. /**
  11758. * Creates a ShadowGenerator object.
  11759. * A ShadowGenerator is the required tool to use the shadows.
  11760. * Each light casting shadows needs to use its own ShadowGenerator.
  11761. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11762. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11763. * @param light The light object generating the shadows.
  11764. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  11765. */
  11766. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11767. private _initializeGenerator;
  11768. private _initializeShadowMap;
  11769. private _initializeBlurRTTAndPostProcesses;
  11770. private _renderForShadowMap;
  11771. private _renderSubMeshForShadowMap;
  11772. private _applyFilterValues;
  11773. /**
  11774. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11775. * @param onCompiled Callback triggered at the and of the effects compilation
  11776. * @param options Sets of optional options forcing the compilation with different modes
  11777. */
  11778. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11779. useInstances: boolean;
  11780. }>): void;
  11781. /**
  11782. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11783. * @param options Sets of optional options forcing the compilation with different modes
  11784. * @returns A promise that resolves when the compilation completes
  11785. */
  11786. forceCompilationAsync(options?: Partial<{
  11787. useInstances: boolean;
  11788. }>): Promise<void>;
  11789. /**
  11790. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11791. * @param subMesh The submesh we want to render in the shadow map
  11792. * @param useInstances Defines wether will draw in the map using instances
  11793. * @returns true if ready otherwise, false
  11794. */
  11795. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11796. /**
  11797. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11798. * @param defines Defines of the material we want to update
  11799. * @param lightIndex Index of the light in the enabled light list of the material
  11800. */
  11801. prepareDefines(defines: any, lightIndex: number): void;
  11802. /**
  11803. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11804. * defined in the generator but impacting the effect).
  11805. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11806. * @param effect The effect we are binfing the information for
  11807. */
  11808. bindShadowLight(lightIndex: string, effect: Effect): void;
  11809. /**
  11810. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11811. * (eq to shadow prjection matrix * light transform matrix)
  11812. * @returns The transform matrix used to create the shadow map
  11813. */
  11814. getTransformMatrix(): Matrix;
  11815. /**
  11816. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11817. * Cube and 2D textures for instance.
  11818. */
  11819. recreateShadowMap(): void;
  11820. private _disposeBlurPostProcesses;
  11821. private _disposeRTTandPostProcesses;
  11822. /**
  11823. * Disposes the ShadowGenerator.
  11824. * Returns nothing.
  11825. */
  11826. dispose(): void;
  11827. /**
  11828. * Serializes the shadow generator setup to a json object.
  11829. * @returns The serialized JSON object
  11830. */
  11831. serialize(): any;
  11832. /**
  11833. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11834. * @param parsedShadowGenerator The JSON object to parse
  11835. * @param scene The scene to create the shadow map for
  11836. * @returns The parsed shadow generator
  11837. */
  11838. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11839. }
  11840. }
  11841. declare module "babylonjs/Lights/light" {
  11842. import { Nullable } from "babylonjs/types";
  11843. import { Scene } from "babylonjs/scene";
  11844. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11845. import { Node } from "babylonjs/node";
  11846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11847. import { Effect } from "babylonjs/Materials/effect";
  11848. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11849. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11850. /**
  11851. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11852. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11853. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  11854. */
  11855. export abstract class Light extends Node {
  11856. /**
  11857. * Falloff Default: light is falling off following the material specification:
  11858. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11859. */
  11860. static readonly FALLOFF_DEFAULT: number;
  11861. /**
  11862. * Falloff Physical: light is falling off following the inverse squared distance law.
  11863. */
  11864. static readonly FALLOFF_PHYSICAL: number;
  11865. /**
  11866. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11867. * to enhance interoperability with other engines.
  11868. */
  11869. static readonly FALLOFF_GLTF: number;
  11870. /**
  11871. * Falloff Standard: light is falling off like in the standard material
  11872. * to enhance interoperability with other materials.
  11873. */
  11874. static readonly FALLOFF_STANDARD: number;
  11875. /**
  11876. * If every light affecting the material is in this lightmapMode,
  11877. * material.lightmapTexture adds or multiplies
  11878. * (depends on material.useLightmapAsShadowmap)
  11879. * after every other light calculations.
  11880. */
  11881. static readonly LIGHTMAP_DEFAULT: number;
  11882. /**
  11883. * material.lightmapTexture as only diffuse lighting from this light
  11884. * adds only specular lighting from this light
  11885. * adds dynamic shadows
  11886. */
  11887. static readonly LIGHTMAP_SPECULAR: number;
  11888. /**
  11889. * material.lightmapTexture as only lighting
  11890. * no light calculation from this light
  11891. * only adds dynamic shadows from this light
  11892. */
  11893. static readonly LIGHTMAP_SHADOWSONLY: number;
  11894. /**
  11895. * Each light type uses the default quantity according to its type:
  11896. * point/spot lights use luminous intensity
  11897. * directional lights use illuminance
  11898. */
  11899. static readonly INTENSITYMODE_AUTOMATIC: number;
  11900. /**
  11901. * lumen (lm)
  11902. */
  11903. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11904. /**
  11905. * candela (lm/sr)
  11906. */
  11907. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11908. /**
  11909. * lux (lm/m^2)
  11910. */
  11911. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11912. /**
  11913. * nit (cd/m^2)
  11914. */
  11915. static readonly INTENSITYMODE_LUMINANCE: number;
  11916. /**
  11917. * Light type const id of the point light.
  11918. */
  11919. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11920. /**
  11921. * Light type const id of the directional light.
  11922. */
  11923. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11924. /**
  11925. * Light type const id of the spot light.
  11926. */
  11927. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11928. /**
  11929. * Light type const id of the hemispheric light.
  11930. */
  11931. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11932. /**
  11933. * Diffuse gives the basic color to an object.
  11934. */
  11935. diffuse: Color3;
  11936. /**
  11937. * Specular produces a highlight color on an object.
  11938. * Note: This is note affecting PBR materials.
  11939. */
  11940. specular: Color3;
  11941. /**
  11942. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11943. * falling off base on range or angle.
  11944. * This can be set to any values in Light.FALLOFF_x.
  11945. *
  11946. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11947. * other types of materials.
  11948. */
  11949. falloffType: number;
  11950. /**
  11951. * Strength of the light.
  11952. * Note: By default it is define in the framework own unit.
  11953. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11954. */
  11955. intensity: number;
  11956. private _range;
  11957. protected _inverseSquaredRange: number;
  11958. /**
  11959. * Defines how far from the source the light is impacting in scene units.
  11960. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11961. */
  11962. /**
  11963. * Defines how far from the source the light is impacting in scene units.
  11964. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11965. */
  11966. range: number;
  11967. /**
  11968. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11969. * of light.
  11970. */
  11971. private _photometricScale;
  11972. private _intensityMode;
  11973. /**
  11974. * Gets the photometric scale used to interpret the intensity.
  11975. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11976. */
  11977. /**
  11978. * Sets the photometric scale used to interpret the intensity.
  11979. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11980. */
  11981. intensityMode: number;
  11982. private _radius;
  11983. /**
  11984. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11985. */
  11986. /**
  11987. * sets the light radius used by PBR Materials to simulate soft area lights.
  11988. */
  11989. radius: number;
  11990. private _renderPriority;
  11991. /**
  11992. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11993. * exceeding the number allowed of the materials.
  11994. */
  11995. renderPriority: number;
  11996. private _shadowEnabled;
  11997. /**
  11998. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11999. * the current shadow generator.
  12000. */
  12001. /**
  12002. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12003. * the current shadow generator.
  12004. */
  12005. shadowEnabled: boolean;
  12006. private _includedOnlyMeshes;
  12007. /**
  12008. * Gets the only meshes impacted by this light.
  12009. */
  12010. /**
  12011. * Sets the only meshes impacted by this light.
  12012. */
  12013. includedOnlyMeshes: AbstractMesh[];
  12014. private _excludedMeshes;
  12015. /**
  12016. * Gets the meshes not impacted by this light.
  12017. */
  12018. /**
  12019. * Sets the meshes not impacted by this light.
  12020. */
  12021. excludedMeshes: AbstractMesh[];
  12022. private _excludeWithLayerMask;
  12023. /**
  12024. * Gets the layer id use to find what meshes are not impacted by the light.
  12025. * Inactive if 0
  12026. */
  12027. /**
  12028. * Sets the layer id use to find what meshes are not impacted by the light.
  12029. * Inactive if 0
  12030. */
  12031. excludeWithLayerMask: number;
  12032. private _includeOnlyWithLayerMask;
  12033. /**
  12034. * Gets the layer id use to find what meshes are impacted by the light.
  12035. * Inactive if 0
  12036. */
  12037. /**
  12038. * Sets the layer id use to find what meshes are impacted by the light.
  12039. * Inactive if 0
  12040. */
  12041. includeOnlyWithLayerMask: number;
  12042. private _lightmapMode;
  12043. /**
  12044. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12045. */
  12046. /**
  12047. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12048. */
  12049. lightmapMode: number;
  12050. /**
  12051. * Shadow generator associted to the light.
  12052. * @hidden Internal use only.
  12053. */
  12054. _shadowGenerator: Nullable<IShadowGenerator>;
  12055. /**
  12056. * @hidden Internal use only.
  12057. */
  12058. _excludedMeshesIds: string[];
  12059. /**
  12060. * @hidden Internal use only.
  12061. */
  12062. _includedOnlyMeshesIds: string[];
  12063. /**
  12064. * The current light unifom buffer.
  12065. * @hidden Internal use only.
  12066. */
  12067. _uniformBuffer: UniformBuffer;
  12068. /**
  12069. * Creates a Light object in the scene.
  12070. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12071. * @param name The firendly name of the light
  12072. * @param scene The scene the light belongs too
  12073. */
  12074. constructor(name: string, scene: Scene);
  12075. protected abstract _buildUniformLayout(): void;
  12076. /**
  12077. * Sets the passed Effect "effect" with the Light information.
  12078. * @param effect The effect to update
  12079. * @param lightIndex The index of the light in the effect to update
  12080. * @returns The light
  12081. */
  12082. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12083. /**
  12084. * Returns the string "Light".
  12085. * @returns the class name
  12086. */
  12087. getClassName(): string;
  12088. /** @hidden */
  12089. readonly _isLight: boolean;
  12090. /**
  12091. * Converts the light information to a readable string for debug purpose.
  12092. * @param fullDetails Supports for multiple levels of logging within scene loading
  12093. * @returns the human readable light info
  12094. */
  12095. toString(fullDetails?: boolean): string;
  12096. /** @hidden */
  12097. protected _syncParentEnabledState(): void;
  12098. /**
  12099. * Set the enabled state of this node.
  12100. * @param value - the new enabled state
  12101. */
  12102. setEnabled(value: boolean): void;
  12103. /**
  12104. * Returns the Light associated shadow generator if any.
  12105. * @return the associated shadow generator.
  12106. */
  12107. getShadowGenerator(): Nullable<IShadowGenerator>;
  12108. /**
  12109. * Returns a Vector3, the absolute light position in the World.
  12110. * @returns the world space position of the light
  12111. */
  12112. getAbsolutePosition(): Vector3;
  12113. /**
  12114. * Specifies if the light will affect the passed mesh.
  12115. * @param mesh The mesh to test against the light
  12116. * @return true the mesh is affected otherwise, false.
  12117. */
  12118. canAffectMesh(mesh: AbstractMesh): boolean;
  12119. /**
  12120. * Sort function to order lights for rendering.
  12121. * @param a First Light object to compare to second.
  12122. * @param b Second Light object to compare first.
  12123. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12124. */
  12125. static CompareLightsPriority(a: Light, b: Light): number;
  12126. /**
  12127. * Releases resources associated with this node.
  12128. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12129. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12130. */
  12131. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12132. /**
  12133. * Returns the light type ID (integer).
  12134. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12135. */
  12136. getTypeID(): number;
  12137. /**
  12138. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12139. * @returns the scaled intensity in intensity mode unit
  12140. */
  12141. getScaledIntensity(): number;
  12142. /**
  12143. * Returns a new Light object, named "name", from the current one.
  12144. * @param name The name of the cloned light
  12145. * @returns the new created light
  12146. */
  12147. clone(name: string): Nullable<Light>;
  12148. /**
  12149. * Serializes the current light into a Serialization object.
  12150. * @returns the serialized object.
  12151. */
  12152. serialize(): any;
  12153. /**
  12154. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12155. * This new light is named "name" and added to the passed scene.
  12156. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12157. * @param name The friendly name of the light
  12158. * @param scene The scene the new light will belong to
  12159. * @returns the constructor function
  12160. */
  12161. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12162. /**
  12163. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12164. * @param parsedLight The JSON representation of the light
  12165. * @param scene The scene to create the parsed light in
  12166. * @returns the created light after parsing
  12167. */
  12168. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12169. private _hookArrayForExcluded;
  12170. private _hookArrayForIncludedOnly;
  12171. private _resyncMeshes;
  12172. /**
  12173. * Forces the meshes to update their light related information in their rendering used effects
  12174. * @hidden Internal Use Only
  12175. */
  12176. _markMeshesAsLightDirty(): void;
  12177. /**
  12178. * Recomputes the cached photometric scale if needed.
  12179. */
  12180. private _computePhotometricScale;
  12181. /**
  12182. * Returns the Photometric Scale according to the light type and intensity mode.
  12183. */
  12184. private _getPhotometricScale;
  12185. /**
  12186. * Reorder the light in the scene according to their defined priority.
  12187. * @hidden Internal Use Only
  12188. */
  12189. _reorderLightsInScene(): void;
  12190. /**
  12191. * Prepares the list of defines specific to the light type.
  12192. * @param defines the list of defines
  12193. * @param lightIndex defines the index of the light for the effect
  12194. */
  12195. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12196. }
  12197. }
  12198. declare module "babylonjs/Meshes/instancedMesh" {
  12199. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12200. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12201. import { Camera } from "babylonjs/Cameras/camera";
  12202. import { Node } from "babylonjs/node";
  12203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12204. import { Mesh } from "babylonjs/Meshes/mesh";
  12205. import { Material } from "babylonjs/Materials/material";
  12206. import { Skeleton } from "babylonjs/Bones/skeleton";
  12207. import { Light } from "babylonjs/Lights/light";
  12208. /**
  12209. * Creates an instance based on a source mesh.
  12210. */
  12211. export class InstancedMesh extends AbstractMesh {
  12212. private _sourceMesh;
  12213. private _currentLOD;
  12214. /** @hidden */
  12215. _indexInSourceMeshInstanceArray: number;
  12216. constructor(name: string, source: Mesh);
  12217. /**
  12218. * Returns the string "InstancedMesh".
  12219. */
  12220. getClassName(): string;
  12221. /** Gets the list of lights affecting that mesh */
  12222. readonly lightSources: Light[];
  12223. _resyncLightSources(): void;
  12224. _resyncLighSource(light: Light): void;
  12225. _removeLightSource(light: Light): void;
  12226. /**
  12227. * If the source mesh receives shadows
  12228. */
  12229. readonly receiveShadows: boolean;
  12230. /**
  12231. * The material of the source mesh
  12232. */
  12233. readonly material: Nullable<Material>;
  12234. /**
  12235. * Visibility of the source mesh
  12236. */
  12237. readonly visibility: number;
  12238. /**
  12239. * Skeleton of the source mesh
  12240. */
  12241. readonly skeleton: Nullable<Skeleton>;
  12242. /**
  12243. * Rendering ground id of the source mesh
  12244. */
  12245. renderingGroupId: number;
  12246. /**
  12247. * Returns the total number of vertices (integer).
  12248. */
  12249. getTotalVertices(): number;
  12250. /**
  12251. * Returns a positive integer : the total number of indices in this mesh geometry.
  12252. * @returns the numner of indices or zero if the mesh has no geometry.
  12253. */
  12254. getTotalIndices(): number;
  12255. /**
  12256. * The source mesh of the instance
  12257. */
  12258. readonly sourceMesh: Mesh;
  12259. /**
  12260. * Is this node ready to be used/rendered
  12261. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12262. * @return {boolean} is it ready
  12263. */
  12264. isReady(completeCheck?: boolean): boolean;
  12265. /**
  12266. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12267. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12268. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  12269. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12270. */
  12271. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12272. /**
  12273. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12274. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12275. * The `data` are either a numeric array either a Float32Array.
  12276. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12277. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  12278. * Note that a new underlying VertexBuffer object is created each call.
  12279. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12280. *
  12281. * Possible `kind` values :
  12282. * - VertexBuffer.PositionKind
  12283. * - VertexBuffer.UVKind
  12284. * - VertexBuffer.UV2Kind
  12285. * - VertexBuffer.UV3Kind
  12286. * - VertexBuffer.UV4Kind
  12287. * - VertexBuffer.UV5Kind
  12288. * - VertexBuffer.UV6Kind
  12289. * - VertexBuffer.ColorKind
  12290. * - VertexBuffer.MatricesIndicesKind
  12291. * - VertexBuffer.MatricesIndicesExtraKind
  12292. * - VertexBuffer.MatricesWeightsKind
  12293. * - VertexBuffer.MatricesWeightsExtraKind
  12294. *
  12295. * Returns the Mesh.
  12296. */
  12297. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12298. /**
  12299. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12300. * If the mesh has no geometry, it is simply returned as it is.
  12301. * The `data` are either a numeric array either a Float32Array.
  12302. * No new underlying VertexBuffer object is created.
  12303. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12304. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12305. *
  12306. * Possible `kind` values :
  12307. * - VertexBuffer.PositionKind
  12308. * - VertexBuffer.UVKind
  12309. * - VertexBuffer.UV2Kind
  12310. * - VertexBuffer.UV3Kind
  12311. * - VertexBuffer.UV4Kind
  12312. * - VertexBuffer.UV5Kind
  12313. * - VertexBuffer.UV6Kind
  12314. * - VertexBuffer.ColorKind
  12315. * - VertexBuffer.MatricesIndicesKind
  12316. * - VertexBuffer.MatricesIndicesExtraKind
  12317. * - VertexBuffer.MatricesWeightsKind
  12318. * - VertexBuffer.MatricesWeightsExtraKind
  12319. *
  12320. * Returns the Mesh.
  12321. */
  12322. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12323. /**
  12324. * Sets the mesh indices.
  12325. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12326. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12327. * This method creates a new index buffer each call.
  12328. * Returns the Mesh.
  12329. */
  12330. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12331. /**
  12332. * Boolean : True if the mesh owns the requested kind of data.
  12333. */
  12334. isVerticesDataPresent(kind: string): boolean;
  12335. /**
  12336. * Returns an array of indices (IndicesArray).
  12337. */
  12338. getIndices(): Nullable<IndicesArray>;
  12339. readonly _positions: Nullable<Vector3[]>;
  12340. /**
  12341. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12342. * This means the mesh underlying bounding box and sphere are recomputed.
  12343. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12344. * @returns the current mesh
  12345. */
  12346. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12347. /** @hidden */
  12348. _preActivate(): InstancedMesh;
  12349. /** @hidden */
  12350. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12351. /** @hidden */
  12352. _postActivate(): void;
  12353. getWorldMatrix(): Matrix;
  12354. readonly isAnInstance: boolean;
  12355. /**
  12356. * Returns the current associated LOD AbstractMesh.
  12357. */
  12358. getLOD(camera: Camera): AbstractMesh;
  12359. /** @hidden */
  12360. _syncSubMeshes(): InstancedMesh;
  12361. /** @hidden */
  12362. _generatePointsArray(): boolean;
  12363. /**
  12364. * Creates a new InstancedMesh from the current mesh.
  12365. * - name (string) : the cloned mesh name
  12366. * - newParent (optional Node) : the optional Node to parent the clone to.
  12367. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12368. *
  12369. * Returns the clone.
  12370. */
  12371. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12372. /**
  12373. * Disposes the InstancedMesh.
  12374. * Returns nothing.
  12375. */
  12376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12377. }
  12378. }
  12379. declare module "babylonjs/Materials/shaderMaterial" {
  12380. import { Scene } from "babylonjs/scene";
  12381. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12383. import { Mesh } from "babylonjs/Meshes/mesh";
  12384. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12386. import { Texture } from "babylonjs/Materials/Textures/texture";
  12387. import { Material } from "babylonjs/Materials/material";
  12388. /**
  12389. * Defines the options associated with the creation of a shader material.
  12390. */
  12391. export interface IShaderMaterialOptions {
  12392. /**
  12393. * Does the material work in alpha blend mode
  12394. */
  12395. needAlphaBlending: boolean;
  12396. /**
  12397. * Does the material work in alpha test mode
  12398. */
  12399. needAlphaTesting: boolean;
  12400. /**
  12401. * The list of attribute names used in the shader
  12402. */
  12403. attributes: string[];
  12404. /**
  12405. * The list of unifrom names used in the shader
  12406. */
  12407. uniforms: string[];
  12408. /**
  12409. * The list of UBO names used in the shader
  12410. */
  12411. uniformBuffers: string[];
  12412. /**
  12413. * The list of sampler names used in the shader
  12414. */
  12415. samplers: string[];
  12416. /**
  12417. * The list of defines used in the shader
  12418. */
  12419. defines: string[];
  12420. }
  12421. /**
  12422. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  12423. *
  12424. * This returned material effects how the mesh will look based on the code in the shaders.
  12425. *
  12426. * @see http://doc.babylonjs.com/how_to/shader_material
  12427. */
  12428. export class ShaderMaterial extends Material {
  12429. private _shaderPath;
  12430. private _options;
  12431. private _textures;
  12432. private _textureArrays;
  12433. private _floats;
  12434. private _ints;
  12435. private _floatsArrays;
  12436. private _colors3;
  12437. private _colors3Arrays;
  12438. private _colors4;
  12439. private _vectors2;
  12440. private _vectors3;
  12441. private _vectors4;
  12442. private _matrices;
  12443. private _matrices3x3;
  12444. private _matrices2x2;
  12445. private _vectors2Arrays;
  12446. private _vectors3Arrays;
  12447. private _cachedWorldViewMatrix;
  12448. private _cachedWorldViewProjectionMatrix;
  12449. private _renderId;
  12450. /**
  12451. * Instantiate a new shader material.
  12452. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  12453. * This returned material effects how the mesh will look based on the code in the shaders.
  12454. * @see http://doc.babylonjs.com/how_to/shader_material
  12455. * @param name Define the name of the material in the scene
  12456. * @param scene Define the scene the material belongs to
  12457. * @param shaderPath Defines the route to the shader code in one of three ways:
  12458. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12459. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12460. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12461. * @param options Define the options used to create the shader
  12462. */
  12463. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12464. /**
  12465. * Gets the options used to compile the shader.
  12466. * They can be modified to trigger a new compilation
  12467. */
  12468. readonly options: IShaderMaterialOptions;
  12469. /**
  12470. * Gets the current class name of the material e.g. "ShaderMaterial"
  12471. * Mainly use in serialization.
  12472. * @returns the class name
  12473. */
  12474. getClassName(): string;
  12475. /**
  12476. * Specifies if the material will require alpha blending
  12477. * @returns a boolean specifying if alpha blending is needed
  12478. */
  12479. needAlphaBlending(): boolean;
  12480. /**
  12481. * Specifies if this material should be rendered in alpha test mode
  12482. * @returns a boolean specifying if an alpha test is needed.
  12483. */
  12484. needAlphaTesting(): boolean;
  12485. private _checkUniform;
  12486. /**
  12487. * Set a texture in the shader.
  12488. * @param name Define the name of the uniform samplers as defined in the shader
  12489. * @param texture Define the texture to bind to this sampler
  12490. * @return the material itself allowing "fluent" like uniform updates
  12491. */
  12492. setTexture(name: string, texture: Texture): ShaderMaterial;
  12493. /**
  12494. * Set a texture array in the shader.
  12495. * @param name Define the name of the uniform sampler array as defined in the shader
  12496. * @param textures Define the list of textures to bind to this sampler
  12497. * @return the material itself allowing "fluent" like uniform updates
  12498. */
  12499. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12500. /**
  12501. * Set a float in the shader.
  12502. * @param name Define the name of the uniform as defined in the shader
  12503. * @param value Define the value to give to the uniform
  12504. * @return the material itself allowing "fluent" like uniform updates
  12505. */
  12506. setFloat(name: string, value: number): ShaderMaterial;
  12507. /**
  12508. * Set a int in the shader.
  12509. * @param name Define the name of the uniform as defined in the shader
  12510. * @param value Define the value to give to the uniform
  12511. * @return the material itself allowing "fluent" like uniform updates
  12512. */
  12513. setInt(name: string, value: number): ShaderMaterial;
  12514. /**
  12515. * Set an array of floats in the shader.
  12516. * @param name Define the name of the uniform as defined in the shader
  12517. * @param value Define the value to give to the uniform
  12518. * @return the material itself allowing "fluent" like uniform updates
  12519. */
  12520. setFloats(name: string, value: number[]): ShaderMaterial;
  12521. /**
  12522. * Set a vec3 in the shader from a Color3.
  12523. * @param name Define the name of the uniform as defined in the shader
  12524. * @param value Define the value to give to the uniform
  12525. * @return the material itself allowing "fluent" like uniform updates
  12526. */
  12527. setColor3(name: string, value: Color3): ShaderMaterial;
  12528. /**
  12529. * Set a vec3 array in the shader from a Color3 array.
  12530. * @param name Define the name of the uniform as defined in the shader
  12531. * @param value Define the value to give to the uniform
  12532. * @return the material itself allowing "fluent" like uniform updates
  12533. */
  12534. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12535. /**
  12536. * Set a vec4 in the shader from a Color4.
  12537. * @param name Define the name of the uniform as defined in the shader
  12538. * @param value Define the value to give to the uniform
  12539. * @return the material itself allowing "fluent" like uniform updates
  12540. */
  12541. setColor4(name: string, value: Color4): ShaderMaterial;
  12542. /**
  12543. * Set a vec2 in the shader from a Vector2.
  12544. * @param name Define the name of the uniform as defined in the shader
  12545. * @param value Define the value to give to the uniform
  12546. * @return the material itself allowing "fluent" like uniform updates
  12547. */
  12548. setVector2(name: string, value: Vector2): ShaderMaterial;
  12549. /**
  12550. * Set a vec3 in the shader from a Vector3.
  12551. * @param name Define the name of the uniform as defined in the shader
  12552. * @param value Define the value to give to the uniform
  12553. * @return the material itself allowing "fluent" like uniform updates
  12554. */
  12555. setVector3(name: string, value: Vector3): ShaderMaterial;
  12556. /**
  12557. * Set a vec4 in the shader from a Vector4.
  12558. * @param name Define the name of the uniform as defined in the shader
  12559. * @param value Define the value to give to the uniform
  12560. * @return the material itself allowing "fluent" like uniform updates
  12561. */
  12562. setVector4(name: string, value: Vector4): ShaderMaterial;
  12563. /**
  12564. * Set a mat4 in the shader from a Matrix.
  12565. * @param name Define the name of the uniform as defined in the shader
  12566. * @param value Define the value to give to the uniform
  12567. * @return the material itself allowing "fluent" like uniform updates
  12568. */
  12569. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12570. /**
  12571. * Set a mat3 in the shader from a Float32Array.
  12572. * @param name Define the name of the uniform as defined in the shader
  12573. * @param value Define the value to give to the uniform
  12574. * @return the material itself allowing "fluent" like uniform updates
  12575. */
  12576. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12577. /**
  12578. * Set a mat2 in the shader from a Float32Array.
  12579. * @param name Define the name of the uniform as defined in the shader
  12580. * @param value Define the value to give to the uniform
  12581. * @return the material itself allowing "fluent" like uniform updates
  12582. */
  12583. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12584. /**
  12585. * Set a vec2 array in the shader from a number array.
  12586. * @param name Define the name of the uniform as defined in the shader
  12587. * @param value Define the value to give to the uniform
  12588. * @return the material itself allowing "fluent" like uniform updates
  12589. */
  12590. setArray2(name: string, value: number[]): ShaderMaterial;
  12591. /**
  12592. * Set a vec3 array in the shader from a number array.
  12593. * @param name Define the name of the uniform as defined in the shader
  12594. * @param value Define the value to give to the uniform
  12595. * @return the material itself allowing "fluent" like uniform updates
  12596. */
  12597. setArray3(name: string, value: number[]): ShaderMaterial;
  12598. private _checkCache;
  12599. /**
  12600. * Specifies that the submesh is ready to be used
  12601. * @param mesh defines the mesh to check
  12602. * @param subMesh defines which submesh to check
  12603. * @param useInstances specifies that instances should be used
  12604. * @returns a boolean indicating that the submesh is ready or not
  12605. */
  12606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12607. /**
  12608. * Checks if the material is ready to render the requested mesh
  12609. * @param mesh Define the mesh to render
  12610. * @param useInstances Define whether or not the material is used with instances
  12611. * @returns true if ready, otherwise false
  12612. */
  12613. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12614. /**
  12615. * Binds the world matrix to the material
  12616. * @param world defines the world transformation matrix
  12617. */
  12618. bindOnlyWorldMatrix(world: Matrix): void;
  12619. /**
  12620. * Binds the material to the mesh
  12621. * @param world defines the world transformation matrix
  12622. * @param mesh defines the mesh to bind the material to
  12623. */
  12624. bind(world: Matrix, mesh?: Mesh): void;
  12625. /**
  12626. * Gets the active textures from the material
  12627. * @returns an array of textures
  12628. */
  12629. getActiveTextures(): BaseTexture[];
  12630. /**
  12631. * Specifies if the material uses a texture
  12632. * @param texture defines the texture to check against the material
  12633. * @returns a boolean specifying if the material uses the texture
  12634. */
  12635. hasTexture(texture: BaseTexture): boolean;
  12636. /**
  12637. * Makes a duplicate of the material, and gives it a new name
  12638. * @param name defines the new name for the duplicated material
  12639. * @returns the cloned material
  12640. */
  12641. clone(name: string): ShaderMaterial;
  12642. /**
  12643. * Disposes the material
  12644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12647. */
  12648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12649. /**
  12650. * Serializes this material in a JSON representation
  12651. * @returns the serialized material object
  12652. */
  12653. serialize(): any;
  12654. /**
  12655. * Creates a shader material from parsed shader material data
  12656. * @param source defines the JSON represnetation of the material
  12657. * @param scene defines the hosting scene
  12658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12659. * @returns a new material
  12660. */
  12661. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12662. }
  12663. }
  12664. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12665. /** @hidden */
  12666. export var clipPlaneFragmentDeclaration: {
  12667. name: string;
  12668. shader: string;
  12669. };
  12670. }
  12671. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12672. /** @hidden */
  12673. export var clipPlaneFragment: {
  12674. name: string;
  12675. shader: string;
  12676. };
  12677. }
  12678. declare module "babylonjs/Shaders/color.fragment" {
  12679. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12680. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12681. /** @hidden */
  12682. export var colorPixelShader: {
  12683. name: string;
  12684. shader: string;
  12685. };
  12686. }
  12687. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12688. /** @hidden */
  12689. export var clipPlaneVertexDeclaration: {
  12690. name: string;
  12691. shader: string;
  12692. };
  12693. }
  12694. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12695. /** @hidden */
  12696. export var clipPlaneVertex: {
  12697. name: string;
  12698. shader: string;
  12699. };
  12700. }
  12701. declare module "babylonjs/Shaders/color.vertex" {
  12702. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12703. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12704. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12705. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12706. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12707. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12708. /** @hidden */
  12709. export var colorVertexShader: {
  12710. name: string;
  12711. shader: string;
  12712. };
  12713. }
  12714. declare module "babylonjs/Meshes/linesMesh" {
  12715. import { Nullable } from "babylonjs/types";
  12716. import { Scene } from "babylonjs/scene";
  12717. import { Color3 } from "babylonjs/Maths/math";
  12718. import { Node } from "babylonjs/node";
  12719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12720. import { Mesh } from "babylonjs/Meshes/mesh";
  12721. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12722. import { Effect } from "babylonjs/Materials/effect";
  12723. import { Material } from "babylonjs/Materials/material";
  12724. import "babylonjs/Shaders/color.fragment";
  12725. import "babylonjs/Shaders/color.vertex";
  12726. /**
  12727. * Line mesh
  12728. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12729. */
  12730. export class LinesMesh extends Mesh {
  12731. /**
  12732. * If vertex color should be applied to the mesh
  12733. */
  12734. readonly useVertexColor?: boolean | undefined;
  12735. /**
  12736. * If vertex alpha should be applied to the mesh
  12737. */
  12738. readonly useVertexAlpha?: boolean | undefined;
  12739. /**
  12740. * Color of the line (Default: White)
  12741. */
  12742. color: Color3;
  12743. /**
  12744. * Alpha of the line (Default: 1)
  12745. */
  12746. alpha: number;
  12747. /**
  12748. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12749. * This margin is expressed in world space coordinates, so its value may vary.
  12750. * Default value is 0.1
  12751. */
  12752. intersectionThreshold: number;
  12753. private _colorShader;
  12754. private color4;
  12755. /**
  12756. * Creates a new LinesMesh
  12757. * @param name defines the name
  12758. * @param scene defines the hosting scene
  12759. * @param parent defines the parent mesh if any
  12760. * @param source defines the optional source LinesMesh used to clone data from
  12761. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12762. * When false, achieved by calling a clone(), also passing False.
  12763. * This will make creation of children, recursive.
  12764. * @param useVertexColor defines if this LinesMesh supports vertex color
  12765. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12766. */
  12767. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12768. /**
  12769. * If vertex color should be applied to the mesh
  12770. */
  12771. useVertexColor?: boolean | undefined,
  12772. /**
  12773. * If vertex alpha should be applied to the mesh
  12774. */
  12775. useVertexAlpha?: boolean | undefined);
  12776. private _addClipPlaneDefine;
  12777. private _removeClipPlaneDefine;
  12778. isReady(): boolean;
  12779. /**
  12780. * Returns the string "LineMesh"
  12781. */
  12782. getClassName(): string;
  12783. /**
  12784. * @hidden
  12785. */
  12786. /**
  12787. * @hidden
  12788. */
  12789. material: Material;
  12790. /**
  12791. * @hidden
  12792. */
  12793. readonly checkCollisions: boolean;
  12794. /** @hidden */
  12795. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12796. /** @hidden */
  12797. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12798. /**
  12799. * Disposes of the line mesh
  12800. * @param doNotRecurse If children should be disposed
  12801. */
  12802. dispose(doNotRecurse?: boolean): void;
  12803. /**
  12804. * Returns a new LineMesh object cloned from the current one.
  12805. */
  12806. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12807. /**
  12808. * Creates a new InstancedLinesMesh object from the mesh model.
  12809. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12810. * @param name defines the name of the new instance
  12811. * @returns a new InstancedLinesMesh
  12812. */
  12813. createInstance(name: string): InstancedLinesMesh;
  12814. }
  12815. /**
  12816. * Creates an instance based on a source LinesMesh
  12817. */
  12818. export class InstancedLinesMesh extends InstancedMesh {
  12819. /**
  12820. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12821. * This margin is expressed in world space coordinates, so its value may vary.
  12822. * Initilized with the intersectionThreshold value of the source LinesMesh
  12823. */
  12824. intersectionThreshold: number;
  12825. constructor(name: string, source: LinesMesh);
  12826. /**
  12827. * Returns the string "InstancedLinesMesh".
  12828. */
  12829. getClassName(): string;
  12830. }
  12831. }
  12832. declare module "babylonjs/Meshes/groundMesh" {
  12833. import { Scene } from "babylonjs/scene";
  12834. import { Vector3 } from "babylonjs/Maths/math";
  12835. import { Mesh } from "babylonjs/Meshes/mesh";
  12836. /**
  12837. * Mesh representing the gorund
  12838. */
  12839. export class GroundMesh extends Mesh {
  12840. /** If octree should be generated */
  12841. generateOctree: boolean;
  12842. private _heightQuads;
  12843. /** @hidden */
  12844. _subdivisionsX: number;
  12845. /** @hidden */
  12846. _subdivisionsY: number;
  12847. /** @hidden */
  12848. _width: number;
  12849. /** @hidden */
  12850. _height: number;
  12851. /** @hidden */
  12852. _minX: number;
  12853. /** @hidden */
  12854. _maxX: number;
  12855. /** @hidden */
  12856. _minZ: number;
  12857. /** @hidden */
  12858. _maxZ: number;
  12859. constructor(name: string, scene: Scene);
  12860. /**
  12861. * "GroundMesh"
  12862. * @returns "GroundMesh"
  12863. */
  12864. getClassName(): string;
  12865. /**
  12866. * The minimum of x and y subdivisions
  12867. */
  12868. readonly subdivisions: number;
  12869. /**
  12870. * X subdivisions
  12871. */
  12872. readonly subdivisionsX: number;
  12873. /**
  12874. * Y subdivisions
  12875. */
  12876. readonly subdivisionsY: number;
  12877. /**
  12878. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12879. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12880. * @param chunksCount the number of subdivisions for x and y
  12881. * @param octreeBlocksSize (Default: 32)
  12882. */
  12883. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12884. /**
  12885. * Returns a height (y) value in the Worl system :
  12886. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12887. * @param x x coordinate
  12888. * @param z z coordinate
  12889. * @returns the ground y position if (x, z) are outside the ground surface.
  12890. */
  12891. getHeightAtCoordinates(x: number, z: number): number;
  12892. /**
  12893. * Returns a normalized vector (Vector3) orthogonal to the ground
  12894. * at the ground coordinates (x, z) expressed in the World system.
  12895. * @param x x coordinate
  12896. * @param z z coordinate
  12897. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12898. */
  12899. getNormalAtCoordinates(x: number, z: number): Vector3;
  12900. /**
  12901. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12902. * at the ground coordinates (x, z) expressed in the World system.
  12903. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12904. * @param x x coordinate
  12905. * @param z z coordinate
  12906. * @param ref vector to store the result
  12907. * @returns the GroundMesh.
  12908. */
  12909. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12910. /**
  12911. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12912. * if the ground has been updated.
  12913. * This can be used in the render loop.
  12914. * @returns the GroundMesh.
  12915. */
  12916. updateCoordinateHeights(): GroundMesh;
  12917. private _getFacetAt;
  12918. private _initHeightQuads;
  12919. private _computeHeightQuads;
  12920. /**
  12921. * Serializes this ground mesh
  12922. * @param serializationObject object to write serialization to
  12923. */
  12924. serialize(serializationObject: any): void;
  12925. /**
  12926. * Parses a serialized ground mesh
  12927. * @param parsedMesh the serialized mesh
  12928. * @param scene the scene to create the ground mesh in
  12929. * @returns the created ground mesh
  12930. */
  12931. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12932. }
  12933. }
  12934. declare module "babylonjs/Physics/physicsJoint" {
  12935. import { Vector3 } from "babylonjs/Maths/math";
  12936. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  12937. /**
  12938. * Interface for Physics-Joint data
  12939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12940. */
  12941. export interface PhysicsJointData {
  12942. /**
  12943. * The main pivot of the joint
  12944. */
  12945. mainPivot?: Vector3;
  12946. /**
  12947. * The connected pivot of the joint
  12948. */
  12949. connectedPivot?: Vector3;
  12950. /**
  12951. * The main axis of the joint
  12952. */
  12953. mainAxis?: Vector3;
  12954. /**
  12955. * The connected axis of the joint
  12956. */
  12957. connectedAxis?: Vector3;
  12958. /**
  12959. * The collision of the joint
  12960. */
  12961. collision?: boolean;
  12962. /**
  12963. * Native Oimo/Cannon/Energy data
  12964. */
  12965. nativeParams?: any;
  12966. }
  12967. /**
  12968. * This is a holder class for the physics joint created by the physics plugin
  12969. * It holds a set of functions to control the underlying joint
  12970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12971. */
  12972. export class PhysicsJoint {
  12973. /**
  12974. * The type of the physics joint
  12975. */
  12976. type: number;
  12977. /**
  12978. * The data for the physics joint
  12979. */
  12980. jointData: PhysicsJointData;
  12981. private _physicsJoint;
  12982. protected _physicsPlugin: IPhysicsEnginePlugin;
  12983. /**
  12984. * Initializes the physics joint
  12985. * @param type The type of the physics joint
  12986. * @param jointData The data for the physics joint
  12987. */
  12988. constructor(
  12989. /**
  12990. * The type of the physics joint
  12991. */
  12992. type: number,
  12993. /**
  12994. * The data for the physics joint
  12995. */
  12996. jointData: PhysicsJointData);
  12997. /**
  12998. * Gets the physics joint
  12999. */
  13000. /**
  13001. * Sets the physics joint
  13002. */
  13003. physicsJoint: any;
  13004. /**
  13005. * Sets the physics plugin
  13006. */
  13007. physicsPlugin: IPhysicsEnginePlugin;
  13008. /**
  13009. * Execute a function that is physics-plugin specific.
  13010. * @param {Function} func the function that will be executed.
  13011. * It accepts two parameters: the physics world and the physics joint
  13012. */
  13013. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13014. /**
  13015. * Distance-Joint type
  13016. */
  13017. static DistanceJoint: number;
  13018. /**
  13019. * Hinge-Joint type
  13020. */
  13021. static HingeJoint: number;
  13022. /**
  13023. * Ball-and-Socket joint type
  13024. */
  13025. static BallAndSocketJoint: number;
  13026. /**
  13027. * Wheel-Joint type
  13028. */
  13029. static WheelJoint: number;
  13030. /**
  13031. * Slider-Joint type
  13032. */
  13033. static SliderJoint: number;
  13034. /**
  13035. * Prismatic-Joint type
  13036. */
  13037. static PrismaticJoint: number;
  13038. /**
  13039. * Universal-Joint type
  13040. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13041. */
  13042. static UniversalJoint: number;
  13043. /**
  13044. * Hinge-Joint 2 type
  13045. */
  13046. static Hinge2Joint: number;
  13047. /**
  13048. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13049. */
  13050. static PointToPointJoint: number;
  13051. /**
  13052. * Spring-Joint type
  13053. */
  13054. static SpringJoint: number;
  13055. /**
  13056. * Lock-Joint type
  13057. */
  13058. static LockJoint: number;
  13059. }
  13060. /**
  13061. * A class representing a physics distance joint
  13062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13063. */
  13064. export class DistanceJoint extends PhysicsJoint {
  13065. /**
  13066. *
  13067. * @param jointData The data for the Distance-Joint
  13068. */
  13069. constructor(jointData: DistanceJointData);
  13070. /**
  13071. * Update the predefined distance.
  13072. * @param maxDistance The maximum preferred distance
  13073. * @param minDistance The minimum preferred distance
  13074. */
  13075. updateDistance(maxDistance: number, minDistance?: number): void;
  13076. }
  13077. /**
  13078. * Represents a Motor-Enabled Joint
  13079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13080. */
  13081. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13082. /**
  13083. * Initializes the Motor-Enabled Joint
  13084. * @param type The type of the joint
  13085. * @param jointData The physica joint data for the joint
  13086. */
  13087. constructor(type: number, jointData: PhysicsJointData);
  13088. /**
  13089. * Set the motor values.
  13090. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13091. * @param force the force to apply
  13092. * @param maxForce max force for this motor.
  13093. */
  13094. setMotor(force?: number, maxForce?: number): void;
  13095. /**
  13096. * Set the motor's limits.
  13097. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13098. * @param upperLimit The upper limit of the motor
  13099. * @param lowerLimit The lower limit of the motor
  13100. */
  13101. setLimit(upperLimit: number, lowerLimit?: number): void;
  13102. }
  13103. /**
  13104. * This class represents a single physics Hinge-Joint
  13105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13106. */
  13107. export class HingeJoint extends MotorEnabledJoint {
  13108. /**
  13109. * Initializes the Hinge-Joint
  13110. * @param jointData The joint data for the Hinge-Joint
  13111. */
  13112. constructor(jointData: PhysicsJointData);
  13113. /**
  13114. * Set the motor values.
  13115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13116. * @param {number} force the force to apply
  13117. * @param {number} maxForce max force for this motor.
  13118. */
  13119. setMotor(force?: number, maxForce?: number): void;
  13120. /**
  13121. * Set the motor's limits.
  13122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13123. * @param upperLimit The upper limit of the motor
  13124. * @param lowerLimit The lower limit of the motor
  13125. */
  13126. setLimit(upperLimit: number, lowerLimit?: number): void;
  13127. }
  13128. /**
  13129. * This class represents a dual hinge physics joint (same as wheel joint)
  13130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13131. */
  13132. export class Hinge2Joint extends MotorEnabledJoint {
  13133. /**
  13134. * Initializes the Hinge2-Joint
  13135. * @param jointData The joint data for the Hinge2-Joint
  13136. */
  13137. constructor(jointData: PhysicsJointData);
  13138. /**
  13139. * Set the motor values.
  13140. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13141. * @param {number} targetSpeed the speed the motor is to reach
  13142. * @param {number} maxForce max force for this motor.
  13143. * @param {motorIndex} the motor's index, 0 or 1.
  13144. */
  13145. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13146. /**
  13147. * Set the motor limits.
  13148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13149. * @param {number} upperLimit the upper limit
  13150. * @param {number} lowerLimit lower limit
  13151. * @param {motorIndex} the motor's index, 0 or 1.
  13152. */
  13153. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13154. }
  13155. /**
  13156. * Interface for a motor enabled joint
  13157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13158. */
  13159. export interface IMotorEnabledJoint {
  13160. /**
  13161. * Physics joint
  13162. */
  13163. physicsJoint: any;
  13164. /**
  13165. * Sets the motor of the motor-enabled joint
  13166. * @param force The force of the motor
  13167. * @param maxForce The maximum force of the motor
  13168. * @param motorIndex The index of the motor
  13169. */
  13170. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13171. /**
  13172. * Sets the limit of the motor
  13173. * @param upperLimit The upper limit of the motor
  13174. * @param lowerLimit The lower limit of the motor
  13175. * @param motorIndex The index of the motor
  13176. */
  13177. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13178. }
  13179. /**
  13180. * Joint data for a Distance-Joint
  13181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13182. */
  13183. export interface DistanceJointData extends PhysicsJointData {
  13184. /**
  13185. * Max distance the 2 joint objects can be apart
  13186. */
  13187. maxDistance: number;
  13188. }
  13189. /**
  13190. * Joint data from a spring joint
  13191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13192. */
  13193. export interface SpringJointData extends PhysicsJointData {
  13194. /**
  13195. * Length of the spring
  13196. */
  13197. length: number;
  13198. /**
  13199. * Stiffness of the spring
  13200. */
  13201. stiffness: number;
  13202. /**
  13203. * Damping of the spring
  13204. */
  13205. damping: number;
  13206. /** this callback will be called when applying the force to the impostors. */
  13207. forceApplicationCallback: () => void;
  13208. }
  13209. }
  13210. declare module "babylonjs/Physics/physicsRaycastResult" {
  13211. import { Vector3 } from "babylonjs/Maths/math";
  13212. /**
  13213. * Holds the data for the raycast result
  13214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13215. */
  13216. export class PhysicsRaycastResult {
  13217. private _hasHit;
  13218. private _hitDistance;
  13219. private _hitNormalWorld;
  13220. private _hitPointWorld;
  13221. private _rayFromWorld;
  13222. private _rayToWorld;
  13223. /**
  13224. * Gets if there was a hit
  13225. */
  13226. readonly hasHit: boolean;
  13227. /**
  13228. * Gets the distance from the hit
  13229. */
  13230. readonly hitDistance: number;
  13231. /**
  13232. * Gets the hit normal/direction in the world
  13233. */
  13234. readonly hitNormalWorld: Vector3;
  13235. /**
  13236. * Gets the hit point in the world
  13237. */
  13238. readonly hitPointWorld: Vector3;
  13239. /**
  13240. * Gets the ray "start point" of the ray in the world
  13241. */
  13242. readonly rayFromWorld: Vector3;
  13243. /**
  13244. * Gets the ray "end point" of the ray in the world
  13245. */
  13246. readonly rayToWorld: Vector3;
  13247. /**
  13248. * Sets the hit data (normal & point in world space)
  13249. * @param hitNormalWorld defines the normal in world space
  13250. * @param hitPointWorld defines the point in world space
  13251. */
  13252. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13253. /**
  13254. * Sets the distance from the start point to the hit point
  13255. * @param distance
  13256. */
  13257. setHitDistance(distance: number): void;
  13258. /**
  13259. * Calculates the distance manually
  13260. */
  13261. calculateHitDistance(): void;
  13262. /**
  13263. * Resets all the values to default
  13264. * @param from The from point on world space
  13265. * @param to The to point on world space
  13266. */
  13267. reset(from?: Vector3, to?: Vector3): void;
  13268. }
  13269. /**
  13270. * Interface for the size containing width and height
  13271. */
  13272. interface IXYZ {
  13273. /**
  13274. * X
  13275. */
  13276. x: number;
  13277. /**
  13278. * Y
  13279. */
  13280. y: number;
  13281. /**
  13282. * Z
  13283. */
  13284. z: number;
  13285. }
  13286. }
  13287. declare module "babylonjs/Physics/IPhysicsEngine" {
  13288. import { Nullable } from "babylonjs/types";
  13289. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13291. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13292. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13293. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13294. /**
  13295. * Interface used to describe a physics joint
  13296. */
  13297. export interface PhysicsImpostorJoint {
  13298. /** Defines the main impostor to which the joint is linked */
  13299. mainImpostor: PhysicsImpostor;
  13300. /** Defines the impostor that is connected to the main impostor using this joint */
  13301. connectedImpostor: PhysicsImpostor;
  13302. /** Defines the joint itself */
  13303. joint: PhysicsJoint;
  13304. }
  13305. /** @hidden */
  13306. export interface IPhysicsEnginePlugin {
  13307. world: any;
  13308. name: string;
  13309. setGravity(gravity: Vector3): void;
  13310. setTimeStep(timeStep: number): void;
  13311. getTimeStep(): number;
  13312. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13313. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13314. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13315. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13316. removePhysicsBody(impostor: PhysicsImpostor): void;
  13317. generateJoint(joint: PhysicsImpostorJoint): void;
  13318. removeJoint(joint: PhysicsImpostorJoint): void;
  13319. isSupported(): boolean;
  13320. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13321. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13322. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13323. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13324. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13325. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13326. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13327. getBodyMass(impostor: PhysicsImpostor): number;
  13328. getBodyFriction(impostor: PhysicsImpostor): number;
  13329. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13330. getBodyRestitution(impostor: PhysicsImpostor): number;
  13331. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13332. getBodyPressure?(impostor: PhysicsImpostor): number;
  13333. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13334. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13335. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13336. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13337. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13338. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13339. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13340. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13341. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13342. sleepBody(impostor: PhysicsImpostor): void;
  13343. wakeUpBody(impostor: PhysicsImpostor): void;
  13344. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13345. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13346. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13347. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13348. getRadius(impostor: PhysicsImpostor): number;
  13349. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13350. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13351. dispose(): void;
  13352. }
  13353. /**
  13354. * Interface used to define a physics engine
  13355. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13356. */
  13357. export interface IPhysicsEngine {
  13358. /**
  13359. * Gets the gravity vector used by the simulation
  13360. */
  13361. gravity: Vector3;
  13362. /**
  13363. * Sets the gravity vector used by the simulation
  13364. * @param gravity defines the gravity vector to use
  13365. */
  13366. setGravity(gravity: Vector3): void;
  13367. /**
  13368. * Set the time step of the physics engine.
  13369. * Default is 1/60.
  13370. * To slow it down, enter 1/600 for example.
  13371. * To speed it up, 1/30
  13372. * @param newTimeStep the new timestep to apply to this world.
  13373. */
  13374. setTimeStep(newTimeStep: number): void;
  13375. /**
  13376. * Get the time step of the physics engine.
  13377. * @returns the current time step
  13378. */
  13379. getTimeStep(): number;
  13380. /**
  13381. * Release all resources
  13382. */
  13383. dispose(): void;
  13384. /**
  13385. * Gets the name of the current physics plugin
  13386. * @returns the name of the plugin
  13387. */
  13388. getPhysicsPluginName(): string;
  13389. /**
  13390. * Adding a new impostor for the impostor tracking.
  13391. * This will be done by the impostor itself.
  13392. * @param impostor the impostor to add
  13393. */
  13394. addImpostor(impostor: PhysicsImpostor): void;
  13395. /**
  13396. * Remove an impostor from the engine.
  13397. * This impostor and its mesh will not longer be updated by the physics engine.
  13398. * @param impostor the impostor to remove
  13399. */
  13400. removeImpostor(impostor: PhysicsImpostor): void;
  13401. /**
  13402. * Add a joint to the physics engine
  13403. * @param mainImpostor defines the main impostor to which the joint is added.
  13404. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13405. * @param joint defines the joint that will connect both impostors.
  13406. */
  13407. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13408. /**
  13409. * Removes a joint from the simulation
  13410. * @param mainImpostor defines the impostor used with the joint
  13411. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13412. * @param joint defines the joint to remove
  13413. */
  13414. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13415. /**
  13416. * Gets the current plugin used to run the simulation
  13417. * @returns current plugin
  13418. */
  13419. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13420. /**
  13421. * Gets the list of physic impostors
  13422. * @returns an array of PhysicsImpostor
  13423. */
  13424. getImpostors(): Array<PhysicsImpostor>;
  13425. /**
  13426. * Gets the impostor for a physics enabled object
  13427. * @param object defines the object impersonated by the impostor
  13428. * @returns the PhysicsImpostor or null if not found
  13429. */
  13430. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13431. /**
  13432. * Gets the impostor for a physics body object
  13433. * @param body defines physics body used by the impostor
  13434. * @returns the PhysicsImpostor or null if not found
  13435. */
  13436. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13437. /**
  13438. * Does a raycast in the physics world
  13439. * @param from when should the ray start?
  13440. * @param to when should the ray end?
  13441. * @returns PhysicsRaycastResult
  13442. */
  13443. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13444. /**
  13445. * Called by the scene. No need to call it.
  13446. * @param delta defines the timespam between frames
  13447. */
  13448. _step(delta: number): void;
  13449. }
  13450. }
  13451. declare module "babylonjs/Physics/physicsImpostor" {
  13452. import { Nullable, IndicesArray } from "babylonjs/types";
  13453. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13454. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13456. import { Scene } from "babylonjs/scene";
  13457. import { Bone } from "babylonjs/Bones/bone";
  13458. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13459. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13460. /**
  13461. * The interface for the physics imposter parameters
  13462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13463. */
  13464. export interface PhysicsImpostorParameters {
  13465. /**
  13466. * The mass of the physics imposter
  13467. */
  13468. mass: number;
  13469. /**
  13470. * The friction of the physics imposter
  13471. */
  13472. friction?: number;
  13473. /**
  13474. * The coefficient of restitution of the physics imposter
  13475. */
  13476. restitution?: number;
  13477. /**
  13478. * The native options of the physics imposter
  13479. */
  13480. nativeOptions?: any;
  13481. /**
  13482. * Specifies if the parent should be ignored
  13483. */
  13484. ignoreParent?: boolean;
  13485. /**
  13486. * Specifies if bi-directional transformations should be disabled
  13487. */
  13488. disableBidirectionalTransformation?: boolean;
  13489. /**
  13490. * The pressure inside the physics imposter, soft object only
  13491. */
  13492. pressure?: number;
  13493. /**
  13494. * The stiffness the physics imposter, soft object only
  13495. */
  13496. stiffness?: number;
  13497. /**
  13498. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13499. */
  13500. velocityIterations?: number;
  13501. /**
  13502. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13503. */
  13504. positionIterations?: number;
  13505. /**
  13506. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13507. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13508. * Add to fix multiple points
  13509. */
  13510. fixedPoints?: number;
  13511. /**
  13512. * The collision margin around a soft object
  13513. */
  13514. margin?: number;
  13515. /**
  13516. * The collision margin around a soft object
  13517. */
  13518. damping?: number;
  13519. /**
  13520. * The path for a rope based on an extrusion
  13521. */
  13522. path?: any;
  13523. /**
  13524. * The shape of an extrusion used for a rope based on an extrusion
  13525. */
  13526. shape?: any;
  13527. }
  13528. /**
  13529. * Interface for a physics-enabled object
  13530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13531. */
  13532. export interface IPhysicsEnabledObject {
  13533. /**
  13534. * The position of the physics-enabled object
  13535. */
  13536. position: Vector3;
  13537. /**
  13538. * The rotation of the physics-enabled object
  13539. */
  13540. rotationQuaternion: Nullable<Quaternion>;
  13541. /**
  13542. * The scale of the physics-enabled object
  13543. */
  13544. scaling: Vector3;
  13545. /**
  13546. * The rotation of the physics-enabled object
  13547. */
  13548. rotation?: Vector3;
  13549. /**
  13550. * The parent of the physics-enabled object
  13551. */
  13552. parent?: any;
  13553. /**
  13554. * The bounding info of the physics-enabled object
  13555. * @returns The bounding info of the physics-enabled object
  13556. */
  13557. getBoundingInfo(): BoundingInfo;
  13558. /**
  13559. * Computes the world matrix
  13560. * @param force Specifies if the world matrix should be computed by force
  13561. * @returns A world matrix
  13562. */
  13563. computeWorldMatrix(force: boolean): Matrix;
  13564. /**
  13565. * Gets the world matrix
  13566. * @returns A world matrix
  13567. */
  13568. getWorldMatrix?(): Matrix;
  13569. /**
  13570. * Gets the child meshes
  13571. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13572. * @returns An array of abstract meshes
  13573. */
  13574. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13575. /**
  13576. * Gets the vertex data
  13577. * @param kind The type of vertex data
  13578. * @returns A nullable array of numbers, or a float32 array
  13579. */
  13580. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13581. /**
  13582. * Gets the indices from the mesh
  13583. * @returns A nullable array of index arrays
  13584. */
  13585. getIndices?(): Nullable<IndicesArray>;
  13586. /**
  13587. * Gets the scene from the mesh
  13588. * @returns the indices array or null
  13589. */
  13590. getScene?(): Scene;
  13591. /**
  13592. * Gets the absolute position from the mesh
  13593. * @returns the absolute position
  13594. */
  13595. getAbsolutePosition(): Vector3;
  13596. /**
  13597. * Gets the absolute pivot point from the mesh
  13598. * @returns the absolute pivot point
  13599. */
  13600. getAbsolutePivotPoint(): Vector3;
  13601. /**
  13602. * Rotates the mesh
  13603. * @param axis The axis of rotation
  13604. * @param amount The amount of rotation
  13605. * @param space The space of the rotation
  13606. * @returns The rotation transform node
  13607. */
  13608. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13609. /**
  13610. * Translates the mesh
  13611. * @param axis The axis of translation
  13612. * @param distance The distance of translation
  13613. * @param space The space of the translation
  13614. * @returns The transform node
  13615. */
  13616. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13617. /**
  13618. * Sets the absolute position of the mesh
  13619. * @param absolutePosition The absolute position of the mesh
  13620. * @returns The transform node
  13621. */
  13622. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13623. /**
  13624. * Gets the class name of the mesh
  13625. * @returns The class name
  13626. */
  13627. getClassName(): string;
  13628. }
  13629. /**
  13630. * Represents a physics imposter
  13631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13632. */
  13633. export class PhysicsImpostor {
  13634. /**
  13635. * The physics-enabled object used as the physics imposter
  13636. */
  13637. object: IPhysicsEnabledObject;
  13638. /**
  13639. * The type of the physics imposter
  13640. */
  13641. type: number;
  13642. private _options;
  13643. private _scene?;
  13644. /**
  13645. * The default object size of the imposter
  13646. */
  13647. static DEFAULT_OBJECT_SIZE: Vector3;
  13648. /**
  13649. * The identity quaternion of the imposter
  13650. */
  13651. static IDENTITY_QUATERNION: Quaternion;
  13652. /** @hidden */
  13653. _pluginData: any;
  13654. private _physicsEngine;
  13655. private _physicsBody;
  13656. private _bodyUpdateRequired;
  13657. private _onBeforePhysicsStepCallbacks;
  13658. private _onAfterPhysicsStepCallbacks;
  13659. /** @hidden */
  13660. _onPhysicsCollideCallbacks: Array<{
  13661. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13662. otherImpostors: Array<PhysicsImpostor>;
  13663. }>;
  13664. private _deltaPosition;
  13665. private _deltaRotation;
  13666. private _deltaRotationConjugated;
  13667. /** @hidden */
  13668. _isFromLine: boolean;
  13669. private _parent;
  13670. private _isDisposed;
  13671. private static _tmpVecs;
  13672. private static _tmpQuat;
  13673. /**
  13674. * Specifies if the physics imposter is disposed
  13675. */
  13676. readonly isDisposed: boolean;
  13677. /**
  13678. * Gets the mass of the physics imposter
  13679. */
  13680. mass: number;
  13681. /**
  13682. * Gets the coefficient of friction
  13683. */
  13684. /**
  13685. * Sets the coefficient of friction
  13686. */
  13687. friction: number;
  13688. /**
  13689. * Gets the coefficient of restitution
  13690. */
  13691. /**
  13692. * Sets the coefficient of restitution
  13693. */
  13694. restitution: number;
  13695. /**
  13696. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13697. */
  13698. /**
  13699. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13700. */
  13701. pressure: number;
  13702. /**
  13703. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13704. */
  13705. /**
  13706. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13707. */
  13708. stiffness: number;
  13709. /**
  13710. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13711. */
  13712. /**
  13713. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13714. */
  13715. velocityIterations: number;
  13716. /**
  13717. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13718. */
  13719. /**
  13720. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13721. */
  13722. positionIterations: number;
  13723. /**
  13724. * The unique id of the physics imposter
  13725. * set by the physics engine when adding this impostor to the array
  13726. */
  13727. uniqueId: number;
  13728. /**
  13729. * @hidden
  13730. */
  13731. soft: boolean;
  13732. /**
  13733. * @hidden
  13734. */
  13735. segments: number;
  13736. private _joints;
  13737. /**
  13738. * Initializes the physics imposter
  13739. * @param object The physics-enabled object used as the physics imposter
  13740. * @param type The type of the physics imposter
  13741. * @param _options The options for the physics imposter
  13742. * @param _scene The Babylon scene
  13743. */
  13744. constructor(
  13745. /**
  13746. * The physics-enabled object used as the physics imposter
  13747. */
  13748. object: IPhysicsEnabledObject,
  13749. /**
  13750. * The type of the physics imposter
  13751. */
  13752. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13753. /**
  13754. * This function will completly initialize this impostor.
  13755. * It will create a new body - but only if this mesh has no parent.
  13756. * If it has, this impostor will not be used other than to define the impostor
  13757. * of the child mesh.
  13758. * @hidden
  13759. */
  13760. _init(): void;
  13761. private _getPhysicsParent;
  13762. /**
  13763. * Should a new body be generated.
  13764. * @returns boolean specifying if body initialization is required
  13765. */
  13766. isBodyInitRequired(): boolean;
  13767. /**
  13768. * Sets the updated scaling
  13769. * @param updated Specifies if the scaling is updated
  13770. */
  13771. setScalingUpdated(): void;
  13772. /**
  13773. * Force a regeneration of this or the parent's impostor's body.
  13774. * Use under cautious - This will remove all joints already implemented.
  13775. */
  13776. forceUpdate(): void;
  13777. /**
  13778. * Gets the body that holds this impostor. Either its own, or its parent.
  13779. */
  13780. /**
  13781. * Set the physics body. Used mainly by the physics engine/plugin
  13782. */
  13783. physicsBody: any;
  13784. /**
  13785. * Get the parent of the physics imposter
  13786. * @returns Physics imposter or null
  13787. */
  13788. /**
  13789. * Sets the parent of the physics imposter
  13790. */
  13791. parent: Nullable<PhysicsImpostor>;
  13792. /**
  13793. * Resets the update flags
  13794. */
  13795. resetUpdateFlags(): void;
  13796. /**
  13797. * Gets the object extend size
  13798. * @returns the object extend size
  13799. */
  13800. getObjectExtendSize(): Vector3;
  13801. /**
  13802. * Gets the object center
  13803. * @returns The object center
  13804. */
  13805. getObjectCenter(): Vector3;
  13806. /**
  13807. * Get a specific parametes from the options parameter
  13808. * @param paramName The object parameter name
  13809. * @returns The object parameter
  13810. */
  13811. getParam(paramName: string): any;
  13812. /**
  13813. * Sets a specific parameter in the options given to the physics plugin
  13814. * @param paramName The parameter name
  13815. * @param value The value of the parameter
  13816. */
  13817. setParam(paramName: string, value: number): void;
  13818. /**
  13819. * Specifically change the body's mass option. Won't recreate the physics body object
  13820. * @param mass The mass of the physics imposter
  13821. */
  13822. setMass(mass: number): void;
  13823. /**
  13824. * Gets the linear velocity
  13825. * @returns linear velocity or null
  13826. */
  13827. getLinearVelocity(): Nullable<Vector3>;
  13828. /**
  13829. * Sets the linear velocity
  13830. * @param velocity linear velocity or null
  13831. */
  13832. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13833. /**
  13834. * Gets the angular velocity
  13835. * @returns angular velocity or null
  13836. */
  13837. getAngularVelocity(): Nullable<Vector3>;
  13838. /**
  13839. * Sets the angular velocity
  13840. * @param velocity The velocity or null
  13841. */
  13842. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13843. /**
  13844. * Execute a function with the physics plugin native code
  13845. * Provide a function the will have two variables - the world object and the physics body object
  13846. * @param func The function to execute with the physics plugin native code
  13847. */
  13848. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13849. /**
  13850. * Register a function that will be executed before the physics world is stepping forward
  13851. * @param func The function to execute before the physics world is stepped forward
  13852. */
  13853. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13854. /**
  13855. * Unregister a function that will be executed before the physics world is stepping forward
  13856. * @param func The function to execute before the physics world is stepped forward
  13857. */
  13858. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13859. /**
  13860. * Register a function that will be executed after the physics step
  13861. * @param func The function to execute after physics step
  13862. */
  13863. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13864. /**
  13865. * Unregisters a function that will be executed after the physics step
  13866. * @param func The function to execute after physics step
  13867. */
  13868. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13869. /**
  13870. * register a function that will be executed when this impostor collides against a different body
  13871. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13872. * @param func Callback that is executed on collision
  13873. */
  13874. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13875. /**
  13876. * Unregisters the physics imposter on contact
  13877. * @param collideAgainst The physics object to collide against
  13878. * @param func Callback to execute on collision
  13879. */
  13880. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13881. private _tmpQuat;
  13882. private _tmpQuat2;
  13883. /**
  13884. * Get the parent rotation
  13885. * @returns The parent rotation
  13886. */
  13887. getParentsRotation(): Quaternion;
  13888. /**
  13889. * this function is executed by the physics engine.
  13890. */
  13891. beforeStep: () => void;
  13892. /**
  13893. * this function is executed by the physics engine
  13894. */
  13895. afterStep: () => void;
  13896. /**
  13897. * Legacy collision detection event support
  13898. */
  13899. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13900. /**
  13901. * event and body object due to cannon's event-based architecture.
  13902. */
  13903. onCollide: (e: {
  13904. body: any;
  13905. }) => void;
  13906. /**
  13907. * Apply a force
  13908. * @param force The force to apply
  13909. * @param contactPoint The contact point for the force
  13910. * @returns The physics imposter
  13911. */
  13912. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13913. /**
  13914. * Apply an impulse
  13915. * @param force The impulse force
  13916. * @param contactPoint The contact point for the impulse force
  13917. * @returns The physics imposter
  13918. */
  13919. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13920. /**
  13921. * A help function to create a joint
  13922. * @param otherImpostor A physics imposter used to create a joint
  13923. * @param jointType The type of joint
  13924. * @param jointData The data for the joint
  13925. * @returns The physics imposter
  13926. */
  13927. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13928. /**
  13929. * Add a joint to this impostor with a different impostor
  13930. * @param otherImpostor A physics imposter used to add a joint
  13931. * @param joint The joint to add
  13932. * @returns The physics imposter
  13933. */
  13934. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13935. /**
  13936. * Add an anchor to a cloth impostor
  13937. * @param otherImpostor rigid impostor to anchor to
  13938. * @param width ratio across width from 0 to 1
  13939. * @param height ratio up height from 0 to 1
  13940. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13941. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13942. * @returns impostor the soft imposter
  13943. */
  13944. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13945. /**
  13946. * Add a hook to a rope impostor
  13947. * @param otherImpostor rigid impostor to anchor to
  13948. * @param length ratio across rope from 0 to 1
  13949. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13950. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13951. * @returns impostor the rope imposter
  13952. */
  13953. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13954. /**
  13955. * Will keep this body still, in a sleep mode.
  13956. * @returns the physics imposter
  13957. */
  13958. sleep(): PhysicsImpostor;
  13959. /**
  13960. * Wake the body up.
  13961. * @returns The physics imposter
  13962. */
  13963. wakeUp(): PhysicsImpostor;
  13964. /**
  13965. * Clones the physics imposter
  13966. * @param newObject The physics imposter clones to this physics-enabled object
  13967. * @returns A nullable physics imposter
  13968. */
  13969. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13970. /**
  13971. * Disposes the physics imposter
  13972. */
  13973. dispose(): void;
  13974. /**
  13975. * Sets the delta position
  13976. * @param position The delta position amount
  13977. */
  13978. setDeltaPosition(position: Vector3): void;
  13979. /**
  13980. * Sets the delta rotation
  13981. * @param rotation The delta rotation amount
  13982. */
  13983. setDeltaRotation(rotation: Quaternion): void;
  13984. /**
  13985. * Gets the box size of the physics imposter and stores the result in the input parameter
  13986. * @param result Stores the box size
  13987. * @returns The physics imposter
  13988. */
  13989. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13990. /**
  13991. * Gets the radius of the physics imposter
  13992. * @returns Radius of the physics imposter
  13993. */
  13994. getRadius(): number;
  13995. /**
  13996. * Sync a bone with this impostor
  13997. * @param bone The bone to sync to the impostor.
  13998. * @param boneMesh The mesh that the bone is influencing.
  13999. * @param jointPivot The pivot of the joint / bone in local space.
  14000. * @param distToJoint Optional distance from the impostor to the joint.
  14001. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14002. */
  14003. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14004. /**
  14005. * Sync impostor to a bone
  14006. * @param bone The bone that the impostor will be synced to.
  14007. * @param boneMesh The mesh that the bone is influencing.
  14008. * @param jointPivot The pivot of the joint / bone in local space.
  14009. * @param distToJoint Optional distance from the impostor to the joint.
  14010. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14011. * @param boneAxis Optional vector3 axis the bone is aligned with
  14012. */
  14013. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14014. /**
  14015. * No-Imposter type
  14016. */
  14017. static NoImpostor: number;
  14018. /**
  14019. * Sphere-Imposter type
  14020. */
  14021. static SphereImpostor: number;
  14022. /**
  14023. * Box-Imposter type
  14024. */
  14025. static BoxImpostor: number;
  14026. /**
  14027. * Plane-Imposter type
  14028. */
  14029. static PlaneImpostor: number;
  14030. /**
  14031. * Mesh-imposter type
  14032. */
  14033. static MeshImpostor: number;
  14034. /**
  14035. * Cylinder-Imposter type
  14036. */
  14037. static CylinderImpostor: number;
  14038. /**
  14039. * Particle-Imposter type
  14040. */
  14041. static ParticleImpostor: number;
  14042. /**
  14043. * Heightmap-Imposter type
  14044. */
  14045. static HeightmapImpostor: number;
  14046. /**
  14047. * ConvexHull-Impostor type (Ammo.js plugin only)
  14048. */
  14049. static ConvexHullImpostor: number;
  14050. /**
  14051. * Rope-Imposter type
  14052. */
  14053. static RopeImpostor: number;
  14054. /**
  14055. * Cloth-Imposter type
  14056. */
  14057. static ClothImpostor: number;
  14058. /**
  14059. * Softbody-Imposter type
  14060. */
  14061. static SoftbodyImpostor: number;
  14062. }
  14063. }
  14064. declare module "babylonjs/Meshes/mesh" {
  14065. import { Observable } from "babylonjs/Misc/observable";
  14066. import { IAnimatable } from "babylonjs/Misc/tools";
  14067. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14068. import { Camera } from "babylonjs/Cameras/camera";
  14069. import { Scene } from "babylonjs/scene";
  14070. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14071. import { Engine } from "babylonjs/Engines/engine";
  14072. import { Node } from "babylonjs/node";
  14073. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14074. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14075. import { Buffer } from "babylonjs/Meshes/buffer";
  14076. import { Geometry } from "babylonjs/Meshes/geometry";
  14077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14078. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14079. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14080. import { Effect } from "babylonjs/Materials/effect";
  14081. import { Material } from "babylonjs/Materials/material";
  14082. import { Skeleton } from "babylonjs/Bones/skeleton";
  14083. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14084. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14085. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14086. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14087. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14088. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14089. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14090. /**
  14091. * @hidden
  14092. **/
  14093. export class _CreationDataStorage {
  14094. closePath?: boolean;
  14095. closeArray?: boolean;
  14096. idx: number[];
  14097. dashSize: number;
  14098. gapSize: number;
  14099. path3D: Path3D;
  14100. pathArray: Vector3[][];
  14101. arc: number;
  14102. radius: number;
  14103. cap: number;
  14104. tessellation: number;
  14105. }
  14106. /**
  14107. * @hidden
  14108. **/
  14109. class _InstanceDataStorage {
  14110. visibleInstances: any;
  14111. batchCache: _InstancesBatch;
  14112. instancesBufferSize: number;
  14113. instancesBuffer: Nullable<Buffer>;
  14114. instancesData: Float32Array;
  14115. overridenInstanceCount: number;
  14116. isFrozen: boolean;
  14117. previousBatch: Nullable<_InstancesBatch>;
  14118. hardwareInstancedRendering: boolean;
  14119. sideOrientation: number;
  14120. }
  14121. /**
  14122. * @hidden
  14123. **/
  14124. export class _InstancesBatch {
  14125. mustReturn: boolean;
  14126. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14127. renderSelf: boolean[];
  14128. hardwareInstancedRendering: boolean[];
  14129. }
  14130. /**
  14131. * Class used to represent renderable models
  14132. */
  14133. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14134. /**
  14135. * Mesh side orientation : usually the external or front surface
  14136. */
  14137. static readonly FRONTSIDE: number;
  14138. /**
  14139. * Mesh side orientation : usually the internal or back surface
  14140. */
  14141. static readonly BACKSIDE: number;
  14142. /**
  14143. * Mesh side orientation : both internal and external or front and back surfaces
  14144. */
  14145. static readonly DOUBLESIDE: number;
  14146. /**
  14147. * Mesh side orientation : by default, `FRONTSIDE`
  14148. */
  14149. static readonly DEFAULTSIDE: number;
  14150. /**
  14151. * Mesh cap setting : no cap
  14152. */
  14153. static readonly NO_CAP: number;
  14154. /**
  14155. * Mesh cap setting : one cap at the beginning of the mesh
  14156. */
  14157. static readonly CAP_START: number;
  14158. /**
  14159. * Mesh cap setting : one cap at the end of the mesh
  14160. */
  14161. static readonly CAP_END: number;
  14162. /**
  14163. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14164. */
  14165. static readonly CAP_ALL: number;
  14166. /**
  14167. * Mesh pattern setting : no flip or rotate
  14168. */
  14169. static readonly NO_FLIP: number;
  14170. /**
  14171. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14172. */
  14173. static readonly FLIP_TILE: number;
  14174. /**
  14175. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14176. */
  14177. static readonly ROTATE_TILE: number;
  14178. /**
  14179. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14180. */
  14181. static readonly FLIP_ROW: number;
  14182. /**
  14183. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14184. */
  14185. static readonly ROTATE_ROW: number;
  14186. /**
  14187. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14188. */
  14189. static readonly FLIP_N_ROTATE_TILE: number;
  14190. /**
  14191. * Mesh pattern setting : rotate pattern and rotate
  14192. */
  14193. static readonly FLIP_N_ROTATE_ROW: number;
  14194. /**
  14195. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14196. */
  14197. static readonly CENTER: number;
  14198. /**
  14199. * Mesh tile positioning : part tiles on left
  14200. */
  14201. static readonly LEFT: number;
  14202. /**
  14203. * Mesh tile positioning : part tiles on right
  14204. */
  14205. static readonly RIGHT: number;
  14206. /**
  14207. * Mesh tile positioning : part tiles on top
  14208. */
  14209. static readonly TOP: number;
  14210. /**
  14211. * Mesh tile positioning : part tiles on bottom
  14212. */
  14213. static readonly BOTTOM: number;
  14214. /**
  14215. * Gets the default side orientation.
  14216. * @param orientation the orientation to value to attempt to get
  14217. * @returns the default orientation
  14218. * @hidden
  14219. */
  14220. static _GetDefaultSideOrientation(orientation?: number): number;
  14221. private _internalMeshDataInfo;
  14222. /**
  14223. * An event triggered before rendering the mesh
  14224. */
  14225. readonly onBeforeRenderObservable: Observable<Mesh>;
  14226. /**
  14227. * An event triggered before binding the mesh
  14228. */
  14229. readonly onBeforeBindObservable: Observable<Mesh>;
  14230. /**
  14231. * An event triggered after rendering the mesh
  14232. */
  14233. readonly onAfterRenderObservable: Observable<Mesh>;
  14234. /**
  14235. * An event triggered before drawing the mesh
  14236. */
  14237. readonly onBeforeDrawObservable: Observable<Mesh>;
  14238. private _onBeforeDrawObserver;
  14239. /**
  14240. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14241. */
  14242. onBeforeDraw: () => void;
  14243. /**
  14244. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14245. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14246. */
  14247. delayLoadState: number;
  14248. /**
  14249. * Gets the list of instances created from this mesh
  14250. * it is not supposed to be modified manually.
  14251. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14252. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14253. */
  14254. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14255. /**
  14256. * Gets the file containing delay loading data for this mesh
  14257. */
  14258. delayLoadingFile: string;
  14259. /** @hidden */
  14260. _binaryInfo: any;
  14261. /**
  14262. * User defined function used to change how LOD level selection is done
  14263. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14264. */
  14265. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14266. /**
  14267. * Gets or sets the morph target manager
  14268. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14269. */
  14270. morphTargetManager: Nullable<MorphTargetManager>;
  14271. /** @hidden */
  14272. _creationDataStorage: Nullable<_CreationDataStorage>;
  14273. /** @hidden */
  14274. _geometry: Nullable<Geometry>;
  14275. /** @hidden */
  14276. _delayInfo: Array<string>;
  14277. /** @hidden */
  14278. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14279. /** @hidden */
  14280. _instanceDataStorage: _InstanceDataStorage;
  14281. private _effectiveMaterial;
  14282. /** @hidden */
  14283. _shouldGenerateFlatShading: boolean;
  14284. /** @hidden */
  14285. _originalBuilderSideOrientation: number;
  14286. /**
  14287. * Use this property to change the original side orientation defined at construction time
  14288. */
  14289. overrideMaterialSideOrientation: Nullable<number>;
  14290. /**
  14291. * Gets the source mesh (the one used to clone this one from)
  14292. */
  14293. readonly source: Nullable<Mesh>;
  14294. /**
  14295. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14296. */
  14297. isUnIndexed: boolean;
  14298. /**
  14299. * @constructor
  14300. * @param name The value used by scene.getMeshByName() to do a lookup.
  14301. * @param scene The scene to add this mesh to.
  14302. * @param parent The parent of this mesh, if it has one
  14303. * @param source An optional Mesh from which geometry is shared, cloned.
  14304. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14305. * When false, achieved by calling a clone(), also passing False.
  14306. * This will make creation of children, recursive.
  14307. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14308. */
  14309. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14310. /**
  14311. * Gets the class name
  14312. * @returns the string "Mesh".
  14313. */
  14314. getClassName(): string;
  14315. /** @hidden */
  14316. readonly _isMesh: boolean;
  14317. /**
  14318. * Returns a description of this mesh
  14319. * @param fullDetails define if full details about this mesh must be used
  14320. * @returns a descriptive string representing this mesh
  14321. */
  14322. toString(fullDetails?: boolean): string;
  14323. /** @hidden */
  14324. _unBindEffect(): void;
  14325. /**
  14326. * Gets a boolean indicating if this mesh has LOD
  14327. */
  14328. readonly hasLODLevels: boolean;
  14329. /**
  14330. * Gets the list of MeshLODLevel associated with the current mesh
  14331. * @returns an array of MeshLODLevel
  14332. */
  14333. getLODLevels(): MeshLODLevel[];
  14334. private _sortLODLevels;
  14335. /**
  14336. * Add a mesh as LOD level triggered at the given distance.
  14337. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14338. * @param distance The distance from the center of the object to show this level
  14339. * @param mesh The mesh to be added as LOD level (can be null)
  14340. * @return This mesh (for chaining)
  14341. */
  14342. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14343. /**
  14344. * Returns the LOD level mesh at the passed distance or null if not found.
  14345. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14346. * @param distance The distance from the center of the object to show this level
  14347. * @returns a Mesh or `null`
  14348. */
  14349. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14350. /**
  14351. * Remove a mesh from the LOD array
  14352. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14353. * @param mesh defines the mesh to be removed
  14354. * @return This mesh (for chaining)
  14355. */
  14356. removeLODLevel(mesh: Mesh): Mesh;
  14357. /**
  14358. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14359. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14360. * @param camera defines the camera to use to compute distance
  14361. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14362. * @return This mesh (for chaining)
  14363. */
  14364. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14365. /**
  14366. * Gets the mesh internal Geometry object
  14367. */
  14368. readonly geometry: Nullable<Geometry>;
  14369. /**
  14370. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14371. * @returns the total number of vertices
  14372. */
  14373. getTotalVertices(): number;
  14374. /**
  14375. * Returns the content of an associated vertex buffer
  14376. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14377. * - VertexBuffer.PositionKind
  14378. * - VertexBuffer.UVKind
  14379. * - VertexBuffer.UV2Kind
  14380. * - VertexBuffer.UV3Kind
  14381. * - VertexBuffer.UV4Kind
  14382. * - VertexBuffer.UV5Kind
  14383. * - VertexBuffer.UV6Kind
  14384. * - VertexBuffer.ColorKind
  14385. * - VertexBuffer.MatricesIndicesKind
  14386. * - VertexBuffer.MatricesIndicesExtraKind
  14387. * - VertexBuffer.MatricesWeightsKind
  14388. * - VertexBuffer.MatricesWeightsExtraKind
  14389. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  14390. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14391. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14392. */
  14393. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14394. /**
  14395. * Returns the mesh VertexBuffer object from the requested `kind`
  14396. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14397. * - VertexBuffer.PositionKind
  14398. * - VertexBuffer.NormalKind
  14399. * - VertexBuffer.UVKind
  14400. * - VertexBuffer.UV2Kind
  14401. * - VertexBuffer.UV3Kind
  14402. * - VertexBuffer.UV4Kind
  14403. * - VertexBuffer.UV5Kind
  14404. * - VertexBuffer.UV6Kind
  14405. * - VertexBuffer.ColorKind
  14406. * - VertexBuffer.MatricesIndicesKind
  14407. * - VertexBuffer.MatricesIndicesExtraKind
  14408. * - VertexBuffer.MatricesWeightsKind
  14409. * - VertexBuffer.MatricesWeightsExtraKind
  14410. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14411. */
  14412. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14413. /**
  14414. * Tests if a specific vertex buffer is associated with this mesh
  14415. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14416. * - VertexBuffer.PositionKind
  14417. * - VertexBuffer.NormalKind
  14418. * - VertexBuffer.UVKind
  14419. * - VertexBuffer.UV2Kind
  14420. * - VertexBuffer.UV3Kind
  14421. * - VertexBuffer.UV4Kind
  14422. * - VertexBuffer.UV5Kind
  14423. * - VertexBuffer.UV6Kind
  14424. * - VertexBuffer.ColorKind
  14425. * - VertexBuffer.MatricesIndicesKind
  14426. * - VertexBuffer.MatricesIndicesExtraKind
  14427. * - VertexBuffer.MatricesWeightsKind
  14428. * - VertexBuffer.MatricesWeightsExtraKind
  14429. * @returns a boolean
  14430. */
  14431. isVerticesDataPresent(kind: string): boolean;
  14432. /**
  14433. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14434. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14435. * - VertexBuffer.PositionKind
  14436. * - VertexBuffer.UVKind
  14437. * - VertexBuffer.UV2Kind
  14438. * - VertexBuffer.UV3Kind
  14439. * - VertexBuffer.UV4Kind
  14440. * - VertexBuffer.UV5Kind
  14441. * - VertexBuffer.UV6Kind
  14442. * - VertexBuffer.ColorKind
  14443. * - VertexBuffer.MatricesIndicesKind
  14444. * - VertexBuffer.MatricesIndicesExtraKind
  14445. * - VertexBuffer.MatricesWeightsKind
  14446. * - VertexBuffer.MatricesWeightsExtraKind
  14447. * @returns a boolean
  14448. */
  14449. isVertexBufferUpdatable(kind: string): boolean;
  14450. /**
  14451. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14452. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14453. * - VertexBuffer.PositionKind
  14454. * - VertexBuffer.NormalKind
  14455. * - VertexBuffer.UVKind
  14456. * - VertexBuffer.UV2Kind
  14457. * - VertexBuffer.UV3Kind
  14458. * - VertexBuffer.UV4Kind
  14459. * - VertexBuffer.UV5Kind
  14460. * - VertexBuffer.UV6Kind
  14461. * - VertexBuffer.ColorKind
  14462. * - VertexBuffer.MatricesIndicesKind
  14463. * - VertexBuffer.MatricesIndicesExtraKind
  14464. * - VertexBuffer.MatricesWeightsKind
  14465. * - VertexBuffer.MatricesWeightsExtraKind
  14466. * @returns an array of strings
  14467. */
  14468. getVerticesDataKinds(): string[];
  14469. /**
  14470. * Returns a positive integer : the total number of indices in this mesh geometry.
  14471. * @returns the numner of indices or zero if the mesh has no geometry.
  14472. */
  14473. getTotalIndices(): number;
  14474. /**
  14475. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14476. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  14477. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14478. * @returns the indices array or an empty array if the mesh has no geometry
  14479. */
  14480. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14481. readonly isBlocked: boolean;
  14482. /**
  14483. * Determine if the current mesh is ready to be rendered
  14484. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14485. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14486. * @returns true if all associated assets are ready (material, textures, shaders)
  14487. */
  14488. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14489. /**
  14490. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  14491. */
  14492. readonly areNormalsFrozen: boolean;
  14493. /**
  14494. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  14495. * @returns the current mesh
  14496. */
  14497. freezeNormals(): Mesh;
  14498. /**
  14499. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  14500. * @returns the current mesh
  14501. */
  14502. unfreezeNormals(): Mesh;
  14503. /**
  14504. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14505. */
  14506. overridenInstanceCount: number;
  14507. /** @hidden */
  14508. _preActivate(): Mesh;
  14509. /** @hidden */
  14510. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14511. /** @hidden */
  14512. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14513. /**
  14514. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14515. * This means the mesh underlying bounding box and sphere are recomputed.
  14516. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14517. * @returns the current mesh
  14518. */
  14519. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14520. /** @hidden */
  14521. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14522. /**
  14523. * This function will subdivide the mesh into multiple submeshes
  14524. * @param count defines the expected number of submeshes
  14525. */
  14526. subdivide(count: number): void;
  14527. /**
  14528. * Copy a FloatArray into a specific associated vertex buffer
  14529. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14530. * - VertexBuffer.PositionKind
  14531. * - VertexBuffer.UVKind
  14532. * - VertexBuffer.UV2Kind
  14533. * - VertexBuffer.UV3Kind
  14534. * - VertexBuffer.UV4Kind
  14535. * - VertexBuffer.UV5Kind
  14536. * - VertexBuffer.UV6Kind
  14537. * - VertexBuffer.ColorKind
  14538. * - VertexBuffer.MatricesIndicesKind
  14539. * - VertexBuffer.MatricesIndicesExtraKind
  14540. * - VertexBuffer.MatricesWeightsKind
  14541. * - VertexBuffer.MatricesWeightsExtraKind
  14542. * @param data defines the data source
  14543. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14544. * @param stride defines the data stride size (can be null)
  14545. * @returns the current mesh
  14546. */
  14547. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14548. /**
  14549. * Flags an associated vertex buffer as updatable
  14550. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14551. * - VertexBuffer.PositionKind
  14552. * - VertexBuffer.UVKind
  14553. * - VertexBuffer.UV2Kind
  14554. * - VertexBuffer.UV3Kind
  14555. * - VertexBuffer.UV4Kind
  14556. * - VertexBuffer.UV5Kind
  14557. * - VertexBuffer.UV6Kind
  14558. * - VertexBuffer.ColorKind
  14559. * - VertexBuffer.MatricesIndicesKind
  14560. * - VertexBuffer.MatricesIndicesExtraKind
  14561. * - VertexBuffer.MatricesWeightsKind
  14562. * - VertexBuffer.MatricesWeightsExtraKind
  14563. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14564. */
  14565. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14566. /**
  14567. * Sets the mesh global Vertex Buffer
  14568. * @param buffer defines the buffer to use
  14569. * @returns the current mesh
  14570. */
  14571. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14572. /**
  14573. * Update a specific associated vertex buffer
  14574. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14575. * - VertexBuffer.PositionKind
  14576. * - VertexBuffer.UVKind
  14577. * - VertexBuffer.UV2Kind
  14578. * - VertexBuffer.UV3Kind
  14579. * - VertexBuffer.UV4Kind
  14580. * - VertexBuffer.UV5Kind
  14581. * - VertexBuffer.UV6Kind
  14582. * - VertexBuffer.ColorKind
  14583. * - VertexBuffer.MatricesIndicesKind
  14584. * - VertexBuffer.MatricesIndicesExtraKind
  14585. * - VertexBuffer.MatricesWeightsKind
  14586. * - VertexBuffer.MatricesWeightsExtraKind
  14587. * @param data defines the data source
  14588. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14589. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  14590. * @returns the current mesh
  14591. */
  14592. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14593. /**
  14594. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14595. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14596. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14597. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14598. * @returns the current mesh
  14599. */
  14600. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14601. /**
  14602. * Creates a un-shared specific occurence of the geometry for the mesh.
  14603. * @returns the current mesh
  14604. */
  14605. makeGeometryUnique(): Mesh;
  14606. /**
  14607. * Set the index buffer of this mesh
  14608. * @param indices defines the source data
  14609. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14610. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14611. * @returns the current mesh
  14612. */
  14613. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14614. /**
  14615. * Update the current index buffer
  14616. * @param indices defines the source data
  14617. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14618. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  14619. * @returns the current mesh
  14620. */
  14621. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14622. /**
  14623. * Invert the geometry to move from a right handed system to a left handed one.
  14624. * @returns the current mesh
  14625. */
  14626. toLeftHanded(): Mesh;
  14627. /** @hidden */
  14628. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14629. /** @hidden */
  14630. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14631. /**
  14632. * Registers for this mesh a javascript function called just before the rendering process
  14633. * @param func defines the function to call before rendering this mesh
  14634. * @returns the current mesh
  14635. */
  14636. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14637. /**
  14638. * Disposes a previously registered javascript function called before the rendering
  14639. * @param func defines the function to remove
  14640. * @returns the current mesh
  14641. */
  14642. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14643. /**
  14644. * Registers for this mesh a javascript function called just after the rendering is complete
  14645. * @param func defines the function to call after rendering this mesh
  14646. * @returns the current mesh
  14647. */
  14648. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14649. /**
  14650. * Disposes a previously registered javascript function called after the rendering.
  14651. * @param func defines the function to remove
  14652. * @returns the current mesh
  14653. */
  14654. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14655. /** @hidden */
  14656. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14657. /** @hidden */
  14658. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14659. /** @hidden */
  14660. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14661. /** @hidden */
  14662. _freeze(): void;
  14663. /** @hidden */
  14664. _unFreeze(): void;
  14665. /**
  14666. * 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
  14667. * @param subMesh defines the subMesh to render
  14668. * @param enableAlphaMode defines if alpha mode can be changed
  14669. * @returns the current mesh
  14670. */
  14671. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14672. private _onBeforeDraw;
  14673. /**
  14674. * Renormalize the mesh and patch it up if there are no weights
  14675. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14676. * However in the case of zero weights then we set just a single influence to 1.
  14677. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14678. */
  14679. cleanMatrixWeights(): void;
  14680. private normalizeSkinFourWeights;
  14681. private normalizeSkinWeightsAndExtra;
  14682. /**
  14683. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14684. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14685. * the user know there was an issue with importing the mesh
  14686. * @returns a validation object with skinned, valid and report string
  14687. */
  14688. validateSkinning(): {
  14689. skinned: boolean;
  14690. valid: boolean;
  14691. report: string;
  14692. };
  14693. /** @hidden */
  14694. _checkDelayState(): Mesh;
  14695. private _queueLoad;
  14696. /**
  14697. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14698. * A mesh is in the frustum if its bounding box intersects the frustum
  14699. * @param frustumPlanes defines the frustum to test
  14700. * @returns true if the mesh is in the frustum planes
  14701. */
  14702. isInFrustum(frustumPlanes: Plane[]): boolean;
  14703. /**
  14704. * Sets the mesh material by the material or multiMaterial `id` property
  14705. * @param id is a string identifying the material or the multiMaterial
  14706. * @returns the current mesh
  14707. */
  14708. setMaterialByID(id: string): Mesh;
  14709. /**
  14710. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14711. * @returns an array of IAnimatable
  14712. */
  14713. getAnimatables(): IAnimatable[];
  14714. /**
  14715. * Modifies the mesh geometry according to the passed transformation matrix.
  14716. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14717. * The mesh normals are modified using the same transformation.
  14718. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14719. * @param transform defines the transform matrix to use
  14720. * @see http://doc.babylonjs.com/resources/baking_transformations
  14721. * @returns the current mesh
  14722. */
  14723. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14724. /**
  14725. * Modifies the mesh geometry according to its own current World Matrix.
  14726. * The mesh World Matrix is then reset.
  14727. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14728. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14729. * @see http://doc.babylonjs.com/resources/baking_transformations
  14730. * @returns the current mesh
  14731. */
  14732. bakeCurrentTransformIntoVertices(): Mesh;
  14733. /** @hidden */
  14734. readonly _positions: Nullable<Vector3[]>;
  14735. /** @hidden */
  14736. _resetPointsArrayCache(): Mesh;
  14737. /** @hidden */
  14738. _generatePointsArray(): boolean;
  14739. /**
  14740. * Returns a new Mesh object generated from the current mesh properties.
  14741. * This method must not get confused with createInstance()
  14742. * @param name is a string, the name given to the new mesh
  14743. * @param newParent can be any Node object (default `null`)
  14744. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14745. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14746. * @returns a new mesh
  14747. */
  14748. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14749. /**
  14750. * Releases resources associated with this mesh.
  14751. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14752. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14753. */
  14754. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14755. /**
  14756. * Modifies the mesh geometry according to a displacement map.
  14757. * 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.
  14758. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14759. * @param url is a string, the URL from the image file is to be downloaded.
  14760. * @param minHeight is the lower limit of the displacement.
  14761. * @param maxHeight is the upper limit of the displacement.
  14762. * @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.
  14763. * @param uvOffset is an optional vector2 used to offset UV.
  14764. * @param uvScale is an optional vector2 used to scale UV.
  14765. * @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.
  14766. * @returns the Mesh.
  14767. */
  14768. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14769. /**
  14770. * Modifies the mesh geometry according to a displacementMap buffer.
  14771. * 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.
  14772. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14773. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14774. * @param heightMapWidth is the width of the buffer image.
  14775. * @param heightMapHeight is the height of the buffer image.
  14776. * @param minHeight is the lower limit of the displacement.
  14777. * @param maxHeight is the upper limit of the displacement.
  14778. * @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.
  14779. * @param uvOffset is an optional vector2 used to offset UV.
  14780. * @param uvScale is an optional vector2 used to scale UV.
  14781. * @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.
  14782. * @returns the Mesh.
  14783. */
  14784. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14785. /**
  14786. * Modify the mesh to get a flat shading rendering.
  14787. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14788. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14789. * @returns current mesh
  14790. */
  14791. convertToFlatShadedMesh(): Mesh;
  14792. /**
  14793. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14794. * In other words, more vertices, no more indices and a single bigger VBO.
  14795. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14796. * @returns current mesh
  14797. */
  14798. convertToUnIndexedMesh(): Mesh;
  14799. /**
  14800. * Inverses facet orientations.
  14801. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14802. * @param flipNormals will also inverts the normals
  14803. * @returns current mesh
  14804. */
  14805. flipFaces(flipNormals?: boolean): Mesh;
  14806. /**
  14807. * Increase the number of facets and hence vertices in a mesh
  14808. * Vertex normals are interpolated from existing vertex normals
  14809. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14810. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14811. */
  14812. increaseVertices(numberPerEdge: number): void;
  14813. /**
  14814. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14815. * This will undo any application of covertToFlatShadedMesh
  14816. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14817. */
  14818. forceSharedVertices(): void;
  14819. /** @hidden */
  14820. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14821. /** @hidden */
  14822. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14823. /**
  14824. * Creates a new InstancedMesh object from the mesh model.
  14825. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14826. * @param name defines the name of the new instance
  14827. * @returns a new InstancedMesh
  14828. */
  14829. createInstance(name: string): InstancedMesh;
  14830. /**
  14831. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14832. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14833. * @returns the current mesh
  14834. */
  14835. synchronizeInstances(): Mesh;
  14836. /**
  14837. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14838. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14839. * This should be used together with the simplification to avoid disappearing triangles.
  14840. * @param successCallback an optional success callback to be called after the optimization finished.
  14841. * @returns the current mesh
  14842. */
  14843. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14844. /**
  14845. * Serialize current mesh
  14846. * @param serializationObject defines the object which will receive the serialization data
  14847. */
  14848. serialize(serializationObject: any): void;
  14849. /** @hidden */
  14850. _syncGeometryWithMorphTargetManager(): void;
  14851. /** @hidden */
  14852. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14853. /**
  14854. * Returns a new Mesh object parsed from the source provided.
  14855. * @param parsedMesh is the source
  14856. * @param scene defines the hosting scene
  14857. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14858. * @returns a new Mesh
  14859. */
  14860. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14861. /**
  14862. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14863. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14864. * @param name defines the name of the mesh to create
  14865. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14866. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14867. * @param closePath creates a seam between the first and the last points of each path of the path array
  14868. * @param offset is taken in account only if the `pathArray` is containing a single path
  14869. * @param scene defines the hosting scene
  14870. * @param updatable defines if the mesh must be flagged as updatable
  14871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14872. * @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)
  14873. * @returns a new Mesh
  14874. */
  14875. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14876. /**
  14877. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14878. * @param name defines the name of the mesh to create
  14879. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14880. * @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
  14881. * @param scene defines the hosting scene
  14882. * @param updatable defines if the mesh must be flagged as updatable
  14883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14884. * @returns a new Mesh
  14885. */
  14886. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14887. /**
  14888. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14889. * @param name defines the name of the mesh to create
  14890. * @param size sets the size (float) of each box side (default 1)
  14891. * @param scene defines the hosting scene
  14892. * @param updatable defines if the mesh must be flagged as updatable
  14893. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14894. * @returns a new Mesh
  14895. */
  14896. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14897. /**
  14898. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14899. * @param name defines the name of the mesh to create
  14900. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14901. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14902. * @param scene defines the hosting scene
  14903. * @param updatable defines if the mesh must be flagged as updatable
  14904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14905. * @returns a new Mesh
  14906. */
  14907. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14908. /**
  14909. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14910. * @param name defines the name of the mesh to create
  14911. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14912. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14913. * @param scene defines the hosting scene
  14914. * @returns a new Mesh
  14915. */
  14916. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14917. /**
  14918. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14919. * @param name defines the name of the mesh to create
  14920. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14921. * @param diameterTop set the top cap diameter (floats, default 1)
  14922. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14923. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14924. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14925. * @param scene defines the hosting scene
  14926. * @param updatable defines if the mesh must be flagged as updatable
  14927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14928. * @returns a new Mesh
  14929. */
  14930. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14931. /**
  14932. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14933. * @param name defines the name of the mesh to create
  14934. * @param diameter sets the diameter size (float) of the torus (default 1)
  14935. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14936. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14937. * @param scene defines the hosting scene
  14938. * @param updatable defines if the mesh must be flagged as updatable
  14939. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14940. * @returns a new Mesh
  14941. */
  14942. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14943. /**
  14944. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14945. * @param name defines the name of the mesh to create
  14946. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14947. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14948. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14949. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14950. * @param p the number of windings on X axis (positive integers, default 2)
  14951. * @param q the number of windings on Y axis (positive integers, default 3)
  14952. * @param scene defines the hosting scene
  14953. * @param updatable defines if the mesh must be flagged as updatable
  14954. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14955. * @returns a new Mesh
  14956. */
  14957. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14958. /**
  14959. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14960. * @param name defines the name of the mesh to create
  14961. * @param points is an array successive Vector3
  14962. * @param scene defines the hosting scene
  14963. * @param updatable defines if the mesh must be flagged as updatable
  14964. * @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).
  14965. * @returns a new Mesh
  14966. */
  14967. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14968. /**
  14969. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14970. * @param name defines the name of the mesh to create
  14971. * @param points is an array successive Vector3
  14972. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14973. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14974. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14975. * @param scene defines the hosting scene
  14976. * @param updatable defines if the mesh must be flagged as updatable
  14977. * @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)
  14978. * @returns a new Mesh
  14979. */
  14980. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14981. /**
  14982. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14983. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14984. * 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.
  14985. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14986. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14987. * Remember you can only change the shape positions, not their number when updating a polygon.
  14988. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14989. * @param name defines the name of the mesh to create
  14990. * @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
  14991. * @param scene defines the hosting scene
  14992. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14993. * @param updatable defines if the mesh must be flagged as updatable
  14994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14995. * @param earcutInjection can be used to inject your own earcut reference
  14996. * @returns a new Mesh
  14997. */
  14998. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14999. /**
  15000. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15001. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15002. * @param name defines the name of the mesh to create
  15003. * @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
  15004. * @param depth defines the height of extrusion
  15005. * @param scene defines the hosting scene
  15006. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15007. * @param updatable defines if the mesh must be flagged as updatable
  15008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15009. * @param earcutInjection can be used to inject your own earcut reference
  15010. * @returns a new Mesh
  15011. */
  15012. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15013. /**
  15014. * Creates an extruded shape mesh.
  15015. * 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
  15016. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15017. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15018. * @param name defines the name of the mesh to create
  15019. * @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
  15020. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15021. * @param scale is the value to scale the shape
  15022. * @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
  15023. * @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
  15024. * @param scene defines the hosting scene
  15025. * @param updatable defines if the mesh must be flagged as updatable
  15026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15027. * @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)
  15028. * @returns a new Mesh
  15029. */
  15030. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15031. /**
  15032. * Creates an custom extruded shape mesh.
  15033. * The custom extrusion is a parametric shape.
  15034. * It has no predefined shape. Its final shape will depend on the input parameters.
  15035. * Please consider using the same method from the MeshBuilder class instead
  15036. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15037. * @param name defines the name of the mesh to create
  15038. * @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
  15039. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15040. * @param scaleFunction is a custom Javascript function called on each path point
  15041. * @param rotationFunction is a custom Javascript function called on each path point
  15042. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15043. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15044. * @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
  15045. * @param scene defines the hosting scene
  15046. * @param updatable defines if the mesh must be flagged as updatable
  15047. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15048. * @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)
  15049. * @returns a new Mesh
  15050. */
  15051. 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;
  15052. /**
  15053. * Creates lathe mesh.
  15054. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15055. * Please consider using the same method from the MeshBuilder class instead
  15056. * @param name defines the name of the mesh to create
  15057. * @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
  15058. * @param radius is the radius value of the lathe
  15059. * @param tessellation is the side number of the lathe.
  15060. * @param scene defines the hosting scene
  15061. * @param updatable defines if the mesh must be flagged as updatable
  15062. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15063. * @returns a new Mesh
  15064. */
  15065. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15066. /**
  15067. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15068. * @param name defines the name of the mesh to create
  15069. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15070. * @param scene defines the hosting scene
  15071. * @param updatable defines if the mesh must be flagged as updatable
  15072. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15073. * @returns a new Mesh
  15074. */
  15075. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15076. /**
  15077. * Creates a ground mesh.
  15078. * Please consider using the same method from the MeshBuilder class instead
  15079. * @param name defines the name of the mesh to create
  15080. * @param width set the width of the ground
  15081. * @param height set the height of the ground
  15082. * @param subdivisions sets the number of subdivisions per side
  15083. * @param scene defines the hosting scene
  15084. * @param updatable defines if the mesh must be flagged as updatable
  15085. * @returns a new Mesh
  15086. */
  15087. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15088. /**
  15089. * Creates a tiled ground mesh.
  15090. * Please consider using the same method from the MeshBuilder class instead
  15091. * @param name defines the name of the mesh to create
  15092. * @param xmin set the ground minimum X coordinate
  15093. * @param zmin set the ground minimum Y coordinate
  15094. * @param xmax set the ground maximum X coordinate
  15095. * @param zmax set the ground maximum Z coordinate
  15096. * @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
  15097. * @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
  15098. * @param scene defines the hosting scene
  15099. * @param updatable defines if the mesh must be flagged as updatable
  15100. * @returns a new Mesh
  15101. */
  15102. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15103. w: number;
  15104. h: number;
  15105. }, precision: {
  15106. w: number;
  15107. h: number;
  15108. }, scene: Scene, updatable?: boolean): Mesh;
  15109. /**
  15110. * Creates a ground mesh from a height map.
  15111. * Please consider using the same method from the MeshBuilder class instead
  15112. * @see http://doc.babylonjs.com/babylon101/height_map
  15113. * @param name defines the name of the mesh to create
  15114. * @param url sets the URL of the height map image resource
  15115. * @param width set the ground width size
  15116. * @param height set the ground height size
  15117. * @param subdivisions sets the number of subdivision per side
  15118. * @param minHeight is the minimum altitude on the ground
  15119. * @param maxHeight is the maximum altitude on the ground
  15120. * @param scene defines the hosting scene
  15121. * @param updatable defines if the mesh must be flagged as updatable
  15122. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15123. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15124. * @returns a new Mesh
  15125. */
  15126. 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;
  15127. /**
  15128. * Creates a tube mesh.
  15129. * The tube is a parametric shape.
  15130. * It has no predefined shape. Its final shape will depend on the input parameters.
  15131. * Please consider using the same method from the MeshBuilder class instead
  15132. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15133. * @param name defines the name of the mesh to create
  15134. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15135. * @param radius sets the tube radius size
  15136. * @param tessellation is the number of sides on the tubular surface
  15137. * @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
  15138. * @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
  15139. * @param scene defines the hosting scene
  15140. * @param updatable defines if the mesh must be flagged as updatable
  15141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15142. * @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)
  15143. * @returns a new Mesh
  15144. */
  15145. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15146. (i: number, distance: number): number;
  15147. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15148. /**
  15149. * Creates a polyhedron mesh.
  15150. * Please consider using the same method from the MeshBuilder class instead.
  15151. * * 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
  15152. * * The parameter `size` (positive float, default 1) sets the polygon size
  15153. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15154. * * 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`
  15155. * * 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
  15156. * * 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)`)
  15157. * * 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
  15158. * * 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
  15159. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15160. * * If you create a double-sided mesh, you can choose what parts of 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
  15161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15162. * @param name defines the name of the mesh to create
  15163. * @param options defines the options used to create the mesh
  15164. * @param scene defines the hosting scene
  15165. * @returns a new Mesh
  15166. */
  15167. static CreatePolyhedron(name: string, options: {
  15168. type?: number;
  15169. size?: number;
  15170. sizeX?: number;
  15171. sizeY?: number;
  15172. sizeZ?: number;
  15173. custom?: any;
  15174. faceUV?: Vector4[];
  15175. faceColors?: Color4[];
  15176. updatable?: boolean;
  15177. sideOrientation?: number;
  15178. }, scene: Scene): Mesh;
  15179. /**
  15180. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15181. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15182. * * 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`)
  15183. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15184. * * 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
  15185. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15186. * * If you create a double-sided mesh, you can choose what parts of 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
  15187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15188. * @param name defines the name of the mesh
  15189. * @param options defines the options used to create the mesh
  15190. * @param scene defines the hosting scene
  15191. * @returns a new Mesh
  15192. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15193. */
  15194. static CreateIcoSphere(name: string, options: {
  15195. radius?: number;
  15196. flat?: boolean;
  15197. subdivisions?: number;
  15198. sideOrientation?: number;
  15199. updatable?: boolean;
  15200. }, scene: Scene): Mesh;
  15201. /**
  15202. * Creates a decal mesh.
  15203. * Please consider using the same method from the MeshBuilder class instead.
  15204. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15205. * @param name defines the name of the mesh
  15206. * @param sourceMesh defines the mesh receiving the decal
  15207. * @param position sets the position of the decal in world coordinates
  15208. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15209. * @param size sets the decal scaling
  15210. * @param angle sets the angle to rotate the decal
  15211. * @returns a new Mesh
  15212. */
  15213. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15214. /**
  15215. * Prepare internal position array for software CPU skinning
  15216. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15217. */
  15218. setPositionsForCPUSkinning(): Float32Array;
  15219. /**
  15220. * Prepare internal normal array for software CPU skinning
  15221. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15222. */
  15223. setNormalsForCPUSkinning(): Float32Array;
  15224. /**
  15225. * Updates the vertex buffer by applying transformation from the bones
  15226. * @param skeleton defines the skeleton to apply to current mesh
  15227. * @returns the current mesh
  15228. */
  15229. applySkeleton(skeleton: Skeleton): Mesh;
  15230. /**
  15231. * 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
  15232. * @param meshes defines the list of meshes to scan
  15233. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15234. */
  15235. static MinMax(meshes: AbstractMesh[]): {
  15236. min: Vector3;
  15237. max: Vector3;
  15238. };
  15239. /**
  15240. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15241. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15242. * @returns a vector3
  15243. */
  15244. static Center(meshesOrMinMaxVector: {
  15245. min: Vector3;
  15246. max: Vector3;
  15247. } | AbstractMesh[]): Vector3;
  15248. /**
  15249. * Merge the array of meshes into a single mesh for performance reasons.
  15250. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15251. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15252. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15253. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15254. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15255. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15256. * @returns a new mesh
  15257. */
  15258. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15259. /** @hidden */
  15260. addInstance(instance: InstancedMesh): void;
  15261. /** @hidden */
  15262. removeInstance(instance: InstancedMesh): void;
  15263. }
  15264. }
  15265. declare module "babylonjs/Actions/action" {
  15266. import { Observable } from "babylonjs/Misc/observable";
  15267. import { Condition } from "babylonjs/Actions/condition";
  15268. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15269. import { ActionManager } from "babylonjs/Actions/actionManager";
  15270. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15271. /**
  15272. * Interface used to define Action
  15273. */
  15274. export interface IAction {
  15275. /**
  15276. * Trigger for the action
  15277. */
  15278. trigger: number;
  15279. /** Options of the trigger */
  15280. triggerOptions: any;
  15281. /**
  15282. * Gets the trigger parameters
  15283. * @returns the trigger parameters
  15284. */
  15285. getTriggerParameter(): any;
  15286. /**
  15287. * Internal only - executes current action event
  15288. * @hidden
  15289. */
  15290. _executeCurrent(evt?: ActionEvent): void;
  15291. /**
  15292. * Serialize placeholder for child classes
  15293. * @param parent of child
  15294. * @returns the serialized object
  15295. */
  15296. serialize(parent: any): any;
  15297. /**
  15298. * Internal only
  15299. * @hidden
  15300. */
  15301. _prepare(): void;
  15302. /**
  15303. * Internal only - manager for action
  15304. * @hidden
  15305. */
  15306. _actionManager: AbstractActionManager;
  15307. /**
  15308. * Adds action to chain of actions, may be a DoNothingAction
  15309. * @param action defines the next action to execute
  15310. * @returns The action passed in
  15311. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15312. */
  15313. then(action: IAction): IAction;
  15314. }
  15315. /**
  15316. * The action to be carried out following a trigger
  15317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15318. */
  15319. export class Action implements IAction {
  15320. /** the trigger, with or without parameters, for the action */
  15321. triggerOptions: any;
  15322. /**
  15323. * Trigger for the action
  15324. */
  15325. trigger: number;
  15326. /**
  15327. * Internal only - manager for action
  15328. * @hidden
  15329. */
  15330. _actionManager: ActionManager;
  15331. private _nextActiveAction;
  15332. private _child;
  15333. private _condition?;
  15334. private _triggerParameter;
  15335. /**
  15336. * An event triggered prior to action being executed.
  15337. */
  15338. onBeforeExecuteObservable: Observable<Action>;
  15339. /**
  15340. * Creates a new Action
  15341. * @param triggerOptions the trigger, with or without parameters, for the action
  15342. * @param condition an optional determinant of action
  15343. */
  15344. constructor(
  15345. /** the trigger, with or without parameters, for the action */
  15346. triggerOptions: any, condition?: Condition);
  15347. /**
  15348. * Internal only
  15349. * @hidden
  15350. */
  15351. _prepare(): void;
  15352. /**
  15353. * Gets the trigger parameters
  15354. * @returns the trigger parameters
  15355. */
  15356. getTriggerParameter(): any;
  15357. /**
  15358. * Internal only - executes current action event
  15359. * @hidden
  15360. */
  15361. _executeCurrent(evt?: ActionEvent): void;
  15362. /**
  15363. * Execute placeholder for child classes
  15364. * @param evt optional action event
  15365. */
  15366. execute(evt?: ActionEvent): void;
  15367. /**
  15368. * Skips to next active action
  15369. */
  15370. skipToNextActiveAction(): void;
  15371. /**
  15372. * Adds action to chain of actions, may be a DoNothingAction
  15373. * @param action defines the next action to execute
  15374. * @returns The action passed in
  15375. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15376. */
  15377. then(action: Action): Action;
  15378. /**
  15379. * Internal only
  15380. * @hidden
  15381. */
  15382. _getProperty(propertyPath: string): string;
  15383. /**
  15384. * Internal only
  15385. * @hidden
  15386. */
  15387. _getEffectiveTarget(target: any, propertyPath: string): any;
  15388. /**
  15389. * Serialize placeholder for child classes
  15390. * @param parent of child
  15391. * @returns the serialized object
  15392. */
  15393. serialize(parent: any): any;
  15394. /**
  15395. * Internal only called by serialize
  15396. * @hidden
  15397. */
  15398. protected _serialize(serializedAction: any, parent?: any): any;
  15399. /**
  15400. * Internal only
  15401. * @hidden
  15402. */
  15403. static _SerializeValueAsString: (value: any) => string;
  15404. /**
  15405. * Internal only
  15406. * @hidden
  15407. */
  15408. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15409. name: string;
  15410. targetType: string;
  15411. value: string;
  15412. };
  15413. }
  15414. }
  15415. declare module "babylonjs/Actions/condition" {
  15416. import { ActionManager } from "babylonjs/Actions/actionManager";
  15417. /**
  15418. * A Condition applied to an Action
  15419. */
  15420. export class Condition {
  15421. /**
  15422. * Internal only - manager for action
  15423. * @hidden
  15424. */
  15425. _actionManager: ActionManager;
  15426. /**
  15427. * Internal only
  15428. * @hidden
  15429. */
  15430. _evaluationId: number;
  15431. /**
  15432. * Internal only
  15433. * @hidden
  15434. */
  15435. _currentResult: boolean;
  15436. /**
  15437. * Creates a new Condition
  15438. * @param actionManager the manager of the action the condition is applied to
  15439. */
  15440. constructor(actionManager: ActionManager);
  15441. /**
  15442. * Check if the current condition is valid
  15443. * @returns a boolean
  15444. */
  15445. isValid(): boolean;
  15446. /**
  15447. * Internal only
  15448. * @hidden
  15449. */
  15450. _getProperty(propertyPath: string): string;
  15451. /**
  15452. * Internal only
  15453. * @hidden
  15454. */
  15455. _getEffectiveTarget(target: any, propertyPath: string): any;
  15456. /**
  15457. * Serialize placeholder for child classes
  15458. * @returns the serialized object
  15459. */
  15460. serialize(): any;
  15461. /**
  15462. * Internal only
  15463. * @hidden
  15464. */
  15465. protected _serialize(serializedCondition: any): any;
  15466. }
  15467. /**
  15468. * Defines specific conditional operators as extensions of Condition
  15469. */
  15470. export class ValueCondition extends Condition {
  15471. /** path to specify the property of the target the conditional operator uses */
  15472. propertyPath: string;
  15473. /** the value compared by the conditional operator against the current value of the property */
  15474. value: any;
  15475. /** the conditional operator, default ValueCondition.IsEqual */
  15476. operator: number;
  15477. /**
  15478. * Internal only
  15479. * @hidden
  15480. */
  15481. private static _IsEqual;
  15482. /**
  15483. * Internal only
  15484. * @hidden
  15485. */
  15486. private static _IsDifferent;
  15487. /**
  15488. * Internal only
  15489. * @hidden
  15490. */
  15491. private static _IsGreater;
  15492. /**
  15493. * Internal only
  15494. * @hidden
  15495. */
  15496. private static _IsLesser;
  15497. /**
  15498. * returns the number for IsEqual
  15499. */
  15500. static readonly IsEqual: number;
  15501. /**
  15502. * Returns the number for IsDifferent
  15503. */
  15504. static readonly IsDifferent: number;
  15505. /**
  15506. * Returns the number for IsGreater
  15507. */
  15508. static readonly IsGreater: number;
  15509. /**
  15510. * Returns the number for IsLesser
  15511. */
  15512. static readonly IsLesser: number;
  15513. /**
  15514. * Internal only The action manager for the condition
  15515. * @hidden
  15516. */
  15517. _actionManager: ActionManager;
  15518. /**
  15519. * Internal only
  15520. * @hidden
  15521. */
  15522. private _target;
  15523. /**
  15524. * Internal only
  15525. * @hidden
  15526. */
  15527. private _effectiveTarget;
  15528. /**
  15529. * Internal only
  15530. * @hidden
  15531. */
  15532. private _property;
  15533. /**
  15534. * Creates a new ValueCondition
  15535. * @param actionManager manager for the action the condition applies to
  15536. * @param target for the action
  15537. * @param propertyPath path to specify the property of the target the conditional operator uses
  15538. * @param value the value compared by the conditional operator against the current value of the property
  15539. * @param operator the conditional operator, default ValueCondition.IsEqual
  15540. */
  15541. constructor(actionManager: ActionManager, target: any,
  15542. /** path to specify the property of the target the conditional operator uses */
  15543. propertyPath: string,
  15544. /** the value compared by the conditional operator against the current value of the property */
  15545. value: any,
  15546. /** the conditional operator, default ValueCondition.IsEqual */
  15547. operator?: number);
  15548. /**
  15549. * Compares the given value with the property value for the specified conditional operator
  15550. * @returns the result of the comparison
  15551. */
  15552. isValid(): boolean;
  15553. /**
  15554. * Serialize the ValueCondition into a JSON compatible object
  15555. * @returns serialization object
  15556. */
  15557. serialize(): any;
  15558. /**
  15559. * Gets the name of the conditional operator for the ValueCondition
  15560. * @param operator the conditional operator
  15561. * @returns the name
  15562. */
  15563. static GetOperatorName(operator: number): string;
  15564. }
  15565. /**
  15566. * Defines a predicate condition as an extension of Condition
  15567. */
  15568. export class PredicateCondition extends Condition {
  15569. /** defines the predicate function used to validate the condition */
  15570. predicate: () => boolean;
  15571. /**
  15572. * Internal only - manager for action
  15573. * @hidden
  15574. */
  15575. _actionManager: ActionManager;
  15576. /**
  15577. * Creates a new PredicateCondition
  15578. * @param actionManager manager for the action the condition applies to
  15579. * @param predicate defines the predicate function used to validate the condition
  15580. */
  15581. constructor(actionManager: ActionManager,
  15582. /** defines the predicate function used to validate the condition */
  15583. predicate: () => boolean);
  15584. /**
  15585. * @returns the validity of the predicate condition
  15586. */
  15587. isValid(): boolean;
  15588. }
  15589. /**
  15590. * Defines a state condition as an extension of Condition
  15591. */
  15592. export class StateCondition extends Condition {
  15593. /** Value to compare with target state */
  15594. value: string;
  15595. /**
  15596. * Internal only - manager for action
  15597. * @hidden
  15598. */
  15599. _actionManager: ActionManager;
  15600. /**
  15601. * Internal only
  15602. * @hidden
  15603. */
  15604. private _target;
  15605. /**
  15606. * Creates a new StateCondition
  15607. * @param actionManager manager for the action the condition applies to
  15608. * @param target of the condition
  15609. * @param value to compare with target state
  15610. */
  15611. constructor(actionManager: ActionManager, target: any,
  15612. /** Value to compare with target state */
  15613. value: string);
  15614. /**
  15615. * Gets a boolean indicating if the current condition is met
  15616. * @returns the validity of the state
  15617. */
  15618. isValid(): boolean;
  15619. /**
  15620. * Serialize the StateCondition into a JSON compatible object
  15621. * @returns serialization object
  15622. */
  15623. serialize(): any;
  15624. }
  15625. }
  15626. declare module "babylonjs/Actions/directActions" {
  15627. import { Action } from "babylonjs/Actions/action";
  15628. import { Condition } from "babylonjs/Actions/condition";
  15629. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15630. /**
  15631. * This defines an action responsible to toggle a boolean once triggered.
  15632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15633. */
  15634. export class SwitchBooleanAction extends Action {
  15635. /**
  15636. * The path to the boolean property in the target object
  15637. */
  15638. propertyPath: string;
  15639. private _target;
  15640. private _effectiveTarget;
  15641. private _property;
  15642. /**
  15643. * Instantiate the action
  15644. * @param triggerOptions defines the trigger options
  15645. * @param target defines the object containing the boolean
  15646. * @param propertyPath defines the path to the boolean property in the target object
  15647. * @param condition defines the trigger related conditions
  15648. */
  15649. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15650. /** @hidden */
  15651. _prepare(): void;
  15652. /**
  15653. * Execute the action toggle the boolean value.
  15654. */
  15655. execute(): void;
  15656. /**
  15657. * Serializes the actions and its related information.
  15658. * @param parent defines the object to serialize in
  15659. * @returns the serialized object
  15660. */
  15661. serialize(parent: any): any;
  15662. }
  15663. /**
  15664. * This defines an action responsible to set a the state field of the target
  15665. * to a desired value once triggered.
  15666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15667. */
  15668. export class SetStateAction extends Action {
  15669. /**
  15670. * The value to store in the state field.
  15671. */
  15672. value: string;
  15673. private _target;
  15674. /**
  15675. * Instantiate the action
  15676. * @param triggerOptions defines the trigger options
  15677. * @param target defines the object containing the state property
  15678. * @param value defines the value to store in the state field
  15679. * @param condition defines the trigger related conditions
  15680. */
  15681. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15682. /**
  15683. * Execute the action and store the value on the target state property.
  15684. */
  15685. execute(): void;
  15686. /**
  15687. * Serializes the actions and its related information.
  15688. * @param parent defines the object to serialize in
  15689. * @returns the serialized object
  15690. */
  15691. serialize(parent: any): any;
  15692. }
  15693. /**
  15694. * This defines an action responsible to set a property of the target
  15695. * to a desired value once triggered.
  15696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15697. */
  15698. export class SetValueAction extends Action {
  15699. /**
  15700. * The path of the property to set in the target.
  15701. */
  15702. propertyPath: string;
  15703. /**
  15704. * The value to set in the property
  15705. */
  15706. value: any;
  15707. private _target;
  15708. private _effectiveTarget;
  15709. private _property;
  15710. /**
  15711. * Instantiate the action
  15712. * @param triggerOptions defines the trigger options
  15713. * @param target defines the object containing the property
  15714. * @param propertyPath defines the path of the property to set in the target
  15715. * @param value defines the value to set in the property
  15716. * @param condition defines the trigger related conditions
  15717. */
  15718. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15719. /** @hidden */
  15720. _prepare(): void;
  15721. /**
  15722. * Execute the action and set the targetted property to the desired value.
  15723. */
  15724. execute(): void;
  15725. /**
  15726. * Serializes the actions and its related information.
  15727. * @param parent defines the object to serialize in
  15728. * @returns the serialized object
  15729. */
  15730. serialize(parent: any): any;
  15731. }
  15732. /**
  15733. * This defines an action responsible to increment the target value
  15734. * to a desired value once triggered.
  15735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15736. */
  15737. export class IncrementValueAction extends Action {
  15738. /**
  15739. * The path of the property to increment in the target.
  15740. */
  15741. propertyPath: string;
  15742. /**
  15743. * The value we should increment the property by.
  15744. */
  15745. value: any;
  15746. private _target;
  15747. private _effectiveTarget;
  15748. private _property;
  15749. /**
  15750. * Instantiate the action
  15751. * @param triggerOptions defines the trigger options
  15752. * @param target defines the object containing the property
  15753. * @param propertyPath defines the path of the property to increment in the target
  15754. * @param value defines the value value we should increment the property by
  15755. * @param condition defines the trigger related conditions
  15756. */
  15757. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15758. /** @hidden */
  15759. _prepare(): void;
  15760. /**
  15761. * Execute the action and increment the target of the value amount.
  15762. */
  15763. execute(): void;
  15764. /**
  15765. * Serializes the actions and its related information.
  15766. * @param parent defines the object to serialize in
  15767. * @returns the serialized object
  15768. */
  15769. serialize(parent: any): any;
  15770. }
  15771. /**
  15772. * This defines an action responsible to start an animation once triggered.
  15773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15774. */
  15775. export class PlayAnimationAction extends Action {
  15776. /**
  15777. * Where the animation should start (animation frame)
  15778. */
  15779. from: number;
  15780. /**
  15781. * Where the animation should stop (animation frame)
  15782. */
  15783. to: number;
  15784. /**
  15785. * Define if the animation should loop or stop after the first play.
  15786. */
  15787. loop?: boolean;
  15788. private _target;
  15789. /**
  15790. * Instantiate the action
  15791. * @param triggerOptions defines the trigger options
  15792. * @param target defines the target animation or animation name
  15793. * @param from defines from where the animation should start (animation frame)
  15794. * @param end defines where the animation should stop (animation frame)
  15795. * @param loop defines if the animation should loop or stop after the first play
  15796. * @param condition defines the trigger related conditions
  15797. */
  15798. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15799. /** @hidden */
  15800. _prepare(): void;
  15801. /**
  15802. * Execute the action and play the animation.
  15803. */
  15804. execute(): void;
  15805. /**
  15806. * Serializes the actions and its related information.
  15807. * @param parent defines the object to serialize in
  15808. * @returns the serialized object
  15809. */
  15810. serialize(parent: any): any;
  15811. }
  15812. /**
  15813. * This defines an action responsible to stop an animation once triggered.
  15814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15815. */
  15816. export class StopAnimationAction extends Action {
  15817. private _target;
  15818. /**
  15819. * Instantiate the action
  15820. * @param triggerOptions defines the trigger options
  15821. * @param target defines the target animation or animation name
  15822. * @param condition defines the trigger related conditions
  15823. */
  15824. constructor(triggerOptions: any, target: any, condition?: Condition);
  15825. /** @hidden */
  15826. _prepare(): void;
  15827. /**
  15828. * Execute the action and stop the animation.
  15829. */
  15830. execute(): void;
  15831. /**
  15832. * Serializes the actions and its related information.
  15833. * @param parent defines the object to serialize in
  15834. * @returns the serialized object
  15835. */
  15836. serialize(parent: any): any;
  15837. }
  15838. /**
  15839. * This defines an action responsible that does nothing once triggered.
  15840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15841. */
  15842. export class DoNothingAction extends Action {
  15843. /**
  15844. * Instantiate the action
  15845. * @param triggerOptions defines the trigger options
  15846. * @param condition defines the trigger related conditions
  15847. */
  15848. constructor(triggerOptions?: any, condition?: Condition);
  15849. /**
  15850. * Execute the action and do nothing.
  15851. */
  15852. execute(): void;
  15853. /**
  15854. * Serializes the actions and its related information.
  15855. * @param parent defines the object to serialize in
  15856. * @returns the serialized object
  15857. */
  15858. serialize(parent: any): any;
  15859. }
  15860. /**
  15861. * This defines an action responsible to trigger several actions once triggered.
  15862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15863. */
  15864. export class CombineAction extends Action {
  15865. /**
  15866. * The list of aggregated animations to run.
  15867. */
  15868. children: Action[];
  15869. /**
  15870. * Instantiate the action
  15871. * @param triggerOptions defines the trigger options
  15872. * @param children defines the list of aggregated animations to run
  15873. * @param condition defines the trigger related conditions
  15874. */
  15875. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15876. /** @hidden */
  15877. _prepare(): void;
  15878. /**
  15879. * Execute the action and executes all the aggregated actions.
  15880. */
  15881. execute(evt: ActionEvent): void;
  15882. /**
  15883. * Serializes the actions and its related information.
  15884. * @param parent defines the object to serialize in
  15885. * @returns the serialized object
  15886. */
  15887. serialize(parent: any): any;
  15888. }
  15889. /**
  15890. * This defines an action responsible to run code (external event) once triggered.
  15891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15892. */
  15893. export class ExecuteCodeAction extends Action {
  15894. /**
  15895. * The callback function to run.
  15896. */
  15897. func: (evt: ActionEvent) => void;
  15898. /**
  15899. * Instantiate the action
  15900. * @param triggerOptions defines the trigger options
  15901. * @param func defines the callback function to run
  15902. * @param condition defines the trigger related conditions
  15903. */
  15904. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15905. /**
  15906. * Execute the action and run the attached code.
  15907. */
  15908. execute(evt: ActionEvent): void;
  15909. }
  15910. /**
  15911. * This defines an action responsible to set the parent property of the target once triggered.
  15912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15913. */
  15914. export class SetParentAction extends Action {
  15915. private _parent;
  15916. private _target;
  15917. /**
  15918. * Instantiate the action
  15919. * @param triggerOptions defines the trigger options
  15920. * @param target defines the target containing the parent property
  15921. * @param parent defines from where the animation should start (animation frame)
  15922. * @param condition defines the trigger related conditions
  15923. */
  15924. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15925. /** @hidden */
  15926. _prepare(): void;
  15927. /**
  15928. * Execute the action and set the parent property.
  15929. */
  15930. execute(): void;
  15931. /**
  15932. * Serializes the actions and its related information.
  15933. * @param parent defines the object to serialize in
  15934. * @returns the serialized object
  15935. */
  15936. serialize(parent: any): any;
  15937. }
  15938. }
  15939. declare module "babylonjs/Actions/actionManager" {
  15940. import { Nullable } from "babylonjs/types";
  15941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15942. import { Scene } from "babylonjs/scene";
  15943. import { IAction } from "babylonjs/Actions/action";
  15944. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  15945. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15946. /**
  15947. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15948. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15950. */
  15951. export class ActionManager extends AbstractActionManager {
  15952. /**
  15953. * Nothing
  15954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15955. */
  15956. static readonly NothingTrigger: number;
  15957. /**
  15958. * On pick
  15959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15960. */
  15961. static readonly OnPickTrigger: number;
  15962. /**
  15963. * On left pick
  15964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15965. */
  15966. static readonly OnLeftPickTrigger: number;
  15967. /**
  15968. * On right pick
  15969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15970. */
  15971. static readonly OnRightPickTrigger: number;
  15972. /**
  15973. * On center pick
  15974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15975. */
  15976. static readonly OnCenterPickTrigger: number;
  15977. /**
  15978. * On pick down
  15979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15980. */
  15981. static readonly OnPickDownTrigger: number;
  15982. /**
  15983. * On double pick
  15984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15985. */
  15986. static readonly OnDoublePickTrigger: number;
  15987. /**
  15988. * On pick up
  15989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15990. */
  15991. static readonly OnPickUpTrigger: number;
  15992. /**
  15993. * On pick out.
  15994. * This trigger will only be raised if you also declared a OnPickDown
  15995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15996. */
  15997. static readonly OnPickOutTrigger: number;
  15998. /**
  15999. * On long press
  16000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16001. */
  16002. static readonly OnLongPressTrigger: number;
  16003. /**
  16004. * On pointer over
  16005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16006. */
  16007. static readonly OnPointerOverTrigger: number;
  16008. /**
  16009. * On pointer out
  16010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16011. */
  16012. static readonly OnPointerOutTrigger: number;
  16013. /**
  16014. * On every frame
  16015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16016. */
  16017. static readonly OnEveryFrameTrigger: number;
  16018. /**
  16019. * On intersection enter
  16020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16021. */
  16022. static readonly OnIntersectionEnterTrigger: number;
  16023. /**
  16024. * On intersection exit
  16025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16026. */
  16027. static readonly OnIntersectionExitTrigger: number;
  16028. /**
  16029. * On key down
  16030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16031. */
  16032. static readonly OnKeyDownTrigger: number;
  16033. /**
  16034. * On key up
  16035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16036. */
  16037. static readonly OnKeyUpTrigger: number;
  16038. private _scene;
  16039. /**
  16040. * Creates a new action manager
  16041. * @param scene defines the hosting scene
  16042. */
  16043. constructor(scene: Scene);
  16044. /**
  16045. * Releases all associated resources
  16046. */
  16047. dispose(): void;
  16048. /**
  16049. * Gets hosting scene
  16050. * @returns the hosting scene
  16051. */
  16052. getScene(): Scene;
  16053. /**
  16054. * Does this action manager handles actions of any of the given triggers
  16055. * @param triggers defines the triggers to be tested
  16056. * @return a boolean indicating whether one (or more) of the triggers is handled
  16057. */
  16058. hasSpecificTriggers(triggers: number[]): boolean;
  16059. /**
  16060. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16061. * speed.
  16062. * @param triggerA defines the trigger to be tested
  16063. * @param triggerB defines the trigger to be tested
  16064. * @return a boolean indicating whether one (or more) of the triggers is handled
  16065. */
  16066. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16067. /**
  16068. * Does this action manager handles actions of a given trigger
  16069. * @param trigger defines the trigger to be tested
  16070. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16071. * @return whether the trigger is handled
  16072. */
  16073. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16074. /**
  16075. * Does this action manager has pointer triggers
  16076. */
  16077. readonly hasPointerTriggers: boolean;
  16078. /**
  16079. * Does this action manager has pick triggers
  16080. */
  16081. readonly hasPickTriggers: boolean;
  16082. /**
  16083. * Registers an action to this action manager
  16084. * @param action defines the action to be registered
  16085. * @return the action amended (prepared) after registration
  16086. */
  16087. registerAction(action: IAction): Nullable<IAction>;
  16088. /**
  16089. * Unregisters an action to this action manager
  16090. * @param action defines the action to be unregistered
  16091. * @return a boolean indicating whether the action has been unregistered
  16092. */
  16093. unregisterAction(action: IAction): Boolean;
  16094. /**
  16095. * Process a specific trigger
  16096. * @param trigger defines the trigger to process
  16097. * @param evt defines the event details to be processed
  16098. */
  16099. processTrigger(trigger: number, evt?: IActionEvent): void;
  16100. /** @hidden */
  16101. _getEffectiveTarget(target: any, propertyPath: string): any;
  16102. /** @hidden */
  16103. _getProperty(propertyPath: string): string;
  16104. /**
  16105. * Serialize this manager to a JSON object
  16106. * @param name defines the property name to store this manager
  16107. * @returns a JSON representation of this manager
  16108. */
  16109. serialize(name: string): any;
  16110. /**
  16111. * Creates a new ActionManager from a JSON data
  16112. * @param parsedActions defines the JSON data to read from
  16113. * @param object defines the hosting mesh
  16114. * @param scene defines the hosting scene
  16115. */
  16116. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16117. /**
  16118. * Get a trigger name by index
  16119. * @param trigger defines the trigger index
  16120. * @returns a trigger name
  16121. */
  16122. static GetTriggerName(trigger: number): string;
  16123. }
  16124. }
  16125. declare module "babylonjs/Culling/ray" {
  16126. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16127. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16129. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16130. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16131. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16132. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16133. /**
  16134. * Class representing a ray with position and direction
  16135. */
  16136. export class Ray {
  16137. /** origin point */
  16138. origin: Vector3;
  16139. /** direction */
  16140. direction: Vector3;
  16141. /** length of the ray */
  16142. length: number;
  16143. private static readonly TmpVector3;
  16144. private _tmpRay;
  16145. /**
  16146. * Creates a new ray
  16147. * @param origin origin point
  16148. * @param direction direction
  16149. * @param length length of the ray
  16150. */
  16151. constructor(
  16152. /** origin point */
  16153. origin: Vector3,
  16154. /** direction */
  16155. direction: Vector3,
  16156. /** length of the ray */
  16157. length?: number);
  16158. /**
  16159. * Checks if the ray intersects a box
  16160. * @param minimum bound of the box
  16161. * @param maximum bound of the box
  16162. * @param intersectionTreshold extra extend to be added to the box in all direction
  16163. * @returns if the box was hit
  16164. */
  16165. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16166. /**
  16167. * Checks if the ray intersects a box
  16168. * @param box the bounding box to check
  16169. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16170. * @returns if the box was hit
  16171. */
  16172. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16173. /**
  16174. * If the ray hits a sphere
  16175. * @param sphere the bounding sphere to check
  16176. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16177. * @returns true if it hits the sphere
  16178. */
  16179. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16180. /**
  16181. * If the ray hits a triange
  16182. * @param vertex0 triangle vertex
  16183. * @param vertex1 triangle vertex
  16184. * @param vertex2 triangle vertex
  16185. * @returns intersection information if hit
  16186. */
  16187. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16188. /**
  16189. * Checks if ray intersects a plane
  16190. * @param plane the plane to check
  16191. * @returns the distance away it was hit
  16192. */
  16193. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16194. /**
  16195. * Checks if ray intersects a mesh
  16196. * @param mesh the mesh to check
  16197. * @param fastCheck if only the bounding box should checked
  16198. * @returns picking info of the intersecton
  16199. */
  16200. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16201. /**
  16202. * Checks if ray intersects a mesh
  16203. * @param meshes the meshes to check
  16204. * @param fastCheck if only the bounding box should checked
  16205. * @param results array to store result in
  16206. * @returns Array of picking infos
  16207. */
  16208. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16209. private _comparePickingInfo;
  16210. private static smallnum;
  16211. private static rayl;
  16212. /**
  16213. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16214. * @param sega the first point of the segment to test the intersection against
  16215. * @param segb the second point of the segment to test the intersection against
  16216. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16217. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16218. */
  16219. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16220. /**
  16221. * Update the ray from viewport position
  16222. * @param x position
  16223. * @param y y position
  16224. * @param viewportWidth viewport width
  16225. * @param viewportHeight viewport height
  16226. * @param world world matrix
  16227. * @param view view matrix
  16228. * @param projection projection matrix
  16229. * @returns this ray updated
  16230. */
  16231. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16232. /**
  16233. * Creates a ray with origin and direction of 0,0,0
  16234. * @returns the new ray
  16235. */
  16236. static Zero(): Ray;
  16237. /**
  16238. * Creates a new ray from screen space and viewport
  16239. * @param x position
  16240. * @param y y position
  16241. * @param viewportWidth viewport width
  16242. * @param viewportHeight viewport height
  16243. * @param world world matrix
  16244. * @param view view matrix
  16245. * @param projection projection matrix
  16246. * @returns new ray
  16247. */
  16248. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16249. /**
  16250. * 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
  16251. * transformed to the given world matrix.
  16252. * @param origin The origin point
  16253. * @param end The end point
  16254. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16255. * @returns the new ray
  16256. */
  16257. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16258. /**
  16259. * Transforms a ray by a matrix
  16260. * @param ray ray to transform
  16261. * @param matrix matrix to apply
  16262. * @returns the resulting new ray
  16263. */
  16264. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16265. /**
  16266. * Transforms a ray by a matrix
  16267. * @param ray ray to transform
  16268. * @param matrix matrix to apply
  16269. * @param result ray to store result in
  16270. */
  16271. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16272. /**
  16273. * Unproject a ray from screen space to object space
  16274. * @param sourceX defines the screen space x coordinate to use
  16275. * @param sourceY defines the screen space y coordinate to use
  16276. * @param viewportWidth defines the current width of the viewport
  16277. * @param viewportHeight defines the current height of the viewport
  16278. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16279. * @param view defines the view matrix to use
  16280. * @param projection defines the projection matrix to use
  16281. */
  16282. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16283. }
  16284. /**
  16285. * Type used to define predicate used to select faces when a mesh intersection is detected
  16286. */
  16287. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16288. module "babylonjs/scene" {
  16289. interface Scene {
  16290. /** @hidden */
  16291. _tempPickingRay: Nullable<Ray>;
  16292. /** @hidden */
  16293. _cachedRayForTransform: Ray;
  16294. /** @hidden */
  16295. _pickWithRayInverseMatrix: Matrix;
  16296. /** @hidden */
  16297. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16298. /** @hidden */
  16299. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16300. }
  16301. }
  16302. }
  16303. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16304. import { Nullable } from "babylonjs/types";
  16305. import { Observable } from "babylonjs/Misc/observable";
  16306. import { Scene } from "babylonjs/scene";
  16307. import { Sprite } from "babylonjs/Sprites/sprite";
  16308. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16309. import { Ray } from "babylonjs/Culling/ray";
  16310. import { Camera } from "babylonjs/Cameras/camera";
  16311. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16312. import { ISceneComponent } from "babylonjs/sceneComponent";
  16313. module "babylonjs/scene" {
  16314. interface Scene {
  16315. /** @hidden */
  16316. _pointerOverSprite: Nullable<Sprite>;
  16317. /** @hidden */
  16318. _pickedDownSprite: Nullable<Sprite>;
  16319. /** @hidden */
  16320. _tempSpritePickingRay: Nullable<Ray>;
  16321. /**
  16322. * All of the sprite managers added to this scene
  16323. * @see http://doc.babylonjs.com/babylon101/sprites
  16324. */
  16325. spriteManagers: Array<ISpriteManager>;
  16326. /**
  16327. * An event triggered when sprites rendering is about to start
  16328. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16329. */
  16330. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16331. /**
  16332. * An event triggered when sprites rendering is done
  16333. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16334. */
  16335. onAfterSpritesRenderingObservable: Observable<Scene>;
  16336. /** @hidden */
  16337. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16338. /** Launch a ray to try to pick a sprite in the scene
  16339. * @param x position on screen
  16340. * @param y position on screen
  16341. * @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
  16342. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16343. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16344. * @returns a PickingInfo
  16345. */
  16346. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16347. /** Use the given ray to pick a sprite in the scene
  16348. * @param ray The ray (in world space) to use to pick meshes
  16349. * @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
  16350. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16351. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16352. * @returns a PickingInfo
  16353. */
  16354. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16355. /**
  16356. * Force the sprite under the pointer
  16357. * @param sprite defines the sprite to use
  16358. */
  16359. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16360. /**
  16361. * Gets the sprite under the pointer
  16362. * @returns a Sprite or null if no sprite is under the pointer
  16363. */
  16364. getPointerOverSprite(): Nullable<Sprite>;
  16365. }
  16366. }
  16367. /**
  16368. * Defines the sprite scene component responsible to manage sprites
  16369. * in a given scene.
  16370. */
  16371. export class SpriteSceneComponent implements ISceneComponent {
  16372. /**
  16373. * The component name helpfull to identify the component in the list of scene components.
  16374. */
  16375. readonly name: string;
  16376. /**
  16377. * The scene the component belongs to.
  16378. */
  16379. scene: Scene;
  16380. /** @hidden */
  16381. private _spritePredicate;
  16382. /**
  16383. * Creates a new instance of the component for the given scene
  16384. * @param scene Defines the scene to register the component in
  16385. */
  16386. constructor(scene: Scene);
  16387. /**
  16388. * Registers the component in a given scene
  16389. */
  16390. register(): void;
  16391. /**
  16392. * Rebuilds the elements related to this component in case of
  16393. * context lost for instance.
  16394. */
  16395. rebuild(): void;
  16396. /**
  16397. * Disposes the component and the associated ressources.
  16398. */
  16399. dispose(): void;
  16400. private _pickSpriteButKeepRay;
  16401. private _pointerMove;
  16402. private _pointerDown;
  16403. private _pointerUp;
  16404. }
  16405. }
  16406. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16407. /** @hidden */
  16408. export var fogFragmentDeclaration: {
  16409. name: string;
  16410. shader: string;
  16411. };
  16412. }
  16413. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16414. /** @hidden */
  16415. export var fogFragment: {
  16416. name: string;
  16417. shader: string;
  16418. };
  16419. }
  16420. declare module "babylonjs/Shaders/sprites.fragment" {
  16421. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16422. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16423. /** @hidden */
  16424. export var spritesPixelShader: {
  16425. name: string;
  16426. shader: string;
  16427. };
  16428. }
  16429. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16430. /** @hidden */
  16431. export var fogVertexDeclaration: {
  16432. name: string;
  16433. shader: string;
  16434. };
  16435. }
  16436. declare module "babylonjs/Shaders/sprites.vertex" {
  16437. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16438. /** @hidden */
  16439. export var spritesVertexShader: {
  16440. name: string;
  16441. shader: string;
  16442. };
  16443. }
  16444. declare module "babylonjs/Sprites/spriteManager" {
  16445. import { IDisposable, Scene } from "babylonjs/scene";
  16446. import { Nullable } from "babylonjs/types";
  16447. import { Observable } from "babylonjs/Misc/observable";
  16448. import { Sprite } from "babylonjs/Sprites/sprite";
  16449. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16450. import { Camera } from "babylonjs/Cameras/camera";
  16451. import { Texture } from "babylonjs/Materials/Textures/texture";
  16452. import "babylonjs/Shaders/sprites.fragment";
  16453. import "babylonjs/Shaders/sprites.vertex";
  16454. import { Ray } from "babylonjs/Culling/ray";
  16455. /**
  16456. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16457. */
  16458. export interface ISpriteManager extends IDisposable {
  16459. /**
  16460. * Restricts the camera to viewing objects with the same layerMask.
  16461. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16462. */
  16463. layerMask: number;
  16464. /**
  16465. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16466. */
  16467. isPickable: boolean;
  16468. /**
  16469. * Specifies the rendering group id for this mesh (0 by default)
  16470. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16471. */
  16472. renderingGroupId: number;
  16473. /**
  16474. * Defines the list of sprites managed by the manager.
  16475. */
  16476. sprites: Array<Sprite>;
  16477. /**
  16478. * Tests the intersection of a sprite with a specific ray.
  16479. * @param ray The ray we are sending to test the collision
  16480. * @param camera The camera space we are sending rays in
  16481. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16482. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16483. * @returns picking info or null.
  16484. */
  16485. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16486. /**
  16487. * Renders the list of sprites on screen.
  16488. */
  16489. render(): void;
  16490. }
  16491. /**
  16492. * Class used to manage multiple sprites on the same spritesheet
  16493. * @see http://doc.babylonjs.com/babylon101/sprites
  16494. */
  16495. export class SpriteManager implements ISpriteManager {
  16496. /** defines the manager's name */
  16497. name: string;
  16498. /** Gets the list of sprites */
  16499. sprites: Sprite[];
  16500. /** Gets or sets the rendering group id (0 by default) */
  16501. renderingGroupId: number;
  16502. /** Gets or sets camera layer mask */
  16503. layerMask: number;
  16504. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16505. fogEnabled: boolean;
  16506. /** Gets or sets a boolean indicating if the sprites are pickable */
  16507. isPickable: boolean;
  16508. /** Defines the default width of a cell in the spritesheet */
  16509. cellWidth: number;
  16510. /** Defines the default height of a cell in the spritesheet */
  16511. cellHeight: number;
  16512. /**
  16513. * An event triggered when the manager is disposed.
  16514. */
  16515. onDisposeObservable: Observable<SpriteManager>;
  16516. private _onDisposeObserver;
  16517. /**
  16518. * Callback called when the manager is disposed
  16519. */
  16520. onDispose: () => void;
  16521. private _capacity;
  16522. private _spriteTexture;
  16523. private _epsilon;
  16524. private _scene;
  16525. private _vertexData;
  16526. private _buffer;
  16527. private _vertexBuffers;
  16528. private _indexBuffer;
  16529. private _effectBase;
  16530. private _effectFog;
  16531. /**
  16532. * Gets or sets the spritesheet texture
  16533. */
  16534. texture: Texture;
  16535. /**
  16536. * Creates a new sprite manager
  16537. * @param name defines the manager's name
  16538. * @param imgUrl defines the sprite sheet url
  16539. * @param capacity defines the maximum allowed number of sprites
  16540. * @param cellSize defines the size of a sprite cell
  16541. * @param scene defines the hosting scene
  16542. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16543. * @param samplingMode defines the smapling mode to use with spritesheet
  16544. */
  16545. constructor(
  16546. /** defines the manager's name */
  16547. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16548. private _appendSpriteVertex;
  16549. /**
  16550. * Intersects the sprites with a ray
  16551. * @param ray defines the ray to intersect with
  16552. * @param camera defines the current active camera
  16553. * @param predicate defines a predicate used to select candidate sprites
  16554. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16555. * @returns null if no hit or a PickingInfo
  16556. */
  16557. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16558. /**
  16559. * Render all child sprites
  16560. */
  16561. render(): void;
  16562. /**
  16563. * Release associated resources
  16564. */
  16565. dispose(): void;
  16566. }
  16567. }
  16568. declare module "babylonjs/Sprites/sprite" {
  16569. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16570. import { Nullable } from "babylonjs/types";
  16571. import { ActionManager } from "babylonjs/Actions/actionManager";
  16572. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16573. /**
  16574. * Class used to represent a sprite
  16575. * @see http://doc.babylonjs.com/babylon101/sprites
  16576. */
  16577. export class Sprite {
  16578. /** defines the name */
  16579. name: string;
  16580. /** Gets or sets the current world position */
  16581. position: Vector3;
  16582. /** Gets or sets the main color */
  16583. color: Color4;
  16584. /** Gets or sets the width */
  16585. width: number;
  16586. /** Gets or sets the height */
  16587. height: number;
  16588. /** Gets or sets rotation angle */
  16589. angle: number;
  16590. /** Gets or sets the cell index in the sprite sheet */
  16591. cellIndex: number;
  16592. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16593. invertU: number;
  16594. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16595. invertV: number;
  16596. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16597. disposeWhenFinishedAnimating: boolean;
  16598. /** Gets the list of attached animations */
  16599. animations: Animation[];
  16600. /** Gets or sets a boolean indicating if the sprite can be picked */
  16601. isPickable: boolean;
  16602. /**
  16603. * Gets or sets the associated action manager
  16604. */
  16605. actionManager: Nullable<ActionManager>;
  16606. private _animationStarted;
  16607. private _loopAnimation;
  16608. private _fromIndex;
  16609. private _toIndex;
  16610. private _delay;
  16611. private _direction;
  16612. private _manager;
  16613. private _time;
  16614. private _onAnimationEnd;
  16615. /**
  16616. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16617. */
  16618. isVisible: boolean;
  16619. /**
  16620. * Gets or sets the sprite size
  16621. */
  16622. size: number;
  16623. /**
  16624. * Creates a new Sprite
  16625. * @param name defines the name
  16626. * @param manager defines the manager
  16627. */
  16628. constructor(
  16629. /** defines the name */
  16630. name: string, manager: ISpriteManager);
  16631. /**
  16632. * Starts an animation
  16633. * @param from defines the initial key
  16634. * @param to defines the end key
  16635. * @param loop defines if the animation must loop
  16636. * @param delay defines the start delay (in ms)
  16637. * @param onAnimationEnd defines a callback to call when animation ends
  16638. */
  16639. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16640. /** Stops current animation (if any) */
  16641. stopAnimation(): void;
  16642. /** @hidden */
  16643. _animate(deltaTime: number): void;
  16644. /** Release associated resources */
  16645. dispose(): void;
  16646. }
  16647. }
  16648. declare module "babylonjs/Collisions/pickingInfo" {
  16649. import { Nullable } from "babylonjs/types";
  16650. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16652. import { Sprite } from "babylonjs/Sprites/sprite";
  16653. import { Ray } from "babylonjs/Culling/ray";
  16654. /**
  16655. * Information about the result of picking within a scene
  16656. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16657. */
  16658. export class PickingInfo {
  16659. /** @hidden */
  16660. _pickingUnavailable: boolean;
  16661. /**
  16662. * If the pick collided with an object
  16663. */
  16664. hit: boolean;
  16665. /**
  16666. * Distance away where the pick collided
  16667. */
  16668. distance: number;
  16669. /**
  16670. * The location of pick collision
  16671. */
  16672. pickedPoint: Nullable<Vector3>;
  16673. /**
  16674. * The mesh corresponding the the pick collision
  16675. */
  16676. pickedMesh: Nullable<AbstractMesh>;
  16677. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16678. bu: number;
  16679. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16680. bv: number;
  16681. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16682. faceId: number;
  16683. /** Id of the the submesh that was picked */
  16684. subMeshId: number;
  16685. /** If a sprite was picked, this will be the sprite the pick collided with */
  16686. pickedSprite: Nullable<Sprite>;
  16687. /**
  16688. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16689. */
  16690. originMesh: Nullable<AbstractMesh>;
  16691. /**
  16692. * The ray that was used to perform the picking.
  16693. */
  16694. ray: Nullable<Ray>;
  16695. /**
  16696. * Gets the normal correspodning to the face the pick collided with
  16697. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16698. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16699. * @returns The normal correspodning to the face the pick collided with
  16700. */
  16701. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16702. /**
  16703. * Gets the texture coordinates of where the pick occured
  16704. * @returns the vector containing the coordnates of the texture
  16705. */
  16706. getTextureCoordinates(): Nullable<Vector2>;
  16707. }
  16708. }
  16709. declare module "babylonjs/Events/pointerEvents" {
  16710. import { Nullable } from "babylonjs/types";
  16711. import { Vector2 } from "babylonjs/Maths/math";
  16712. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16713. import { Ray } from "babylonjs/Culling/ray";
  16714. /**
  16715. * Gather the list of pointer event types as constants.
  16716. */
  16717. export class PointerEventTypes {
  16718. /**
  16719. * 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.
  16720. */
  16721. static readonly POINTERDOWN: number;
  16722. /**
  16723. * The pointerup event is fired when a pointer is no longer active.
  16724. */
  16725. static readonly POINTERUP: number;
  16726. /**
  16727. * The pointermove event is fired when a pointer changes coordinates.
  16728. */
  16729. static readonly POINTERMOVE: number;
  16730. /**
  16731. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16732. */
  16733. static readonly POINTERWHEEL: number;
  16734. /**
  16735. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16736. */
  16737. static readonly POINTERPICK: number;
  16738. /**
  16739. * The pointertap event is fired when a the object has been touched and released without drag.
  16740. */
  16741. static readonly POINTERTAP: number;
  16742. /**
  16743. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16744. */
  16745. static readonly POINTERDOUBLETAP: number;
  16746. }
  16747. /**
  16748. * Base class of pointer info types.
  16749. */
  16750. export class PointerInfoBase {
  16751. /**
  16752. * Defines the type of event (PointerEventTypes)
  16753. */
  16754. type: number;
  16755. /**
  16756. * Defines the related dom event
  16757. */
  16758. event: PointerEvent | MouseWheelEvent;
  16759. /**
  16760. * Instantiates the base class of pointers info.
  16761. * @param type Defines the type of event (PointerEventTypes)
  16762. * @param event Defines the related dom event
  16763. */
  16764. constructor(
  16765. /**
  16766. * Defines the type of event (PointerEventTypes)
  16767. */
  16768. type: number,
  16769. /**
  16770. * Defines the related dom event
  16771. */
  16772. event: PointerEvent | MouseWheelEvent);
  16773. }
  16774. /**
  16775. * This class is used to store pointer related info for the onPrePointerObservable event.
  16776. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16777. */
  16778. export class PointerInfoPre extends PointerInfoBase {
  16779. /**
  16780. * Ray from a pointer if availible (eg. 6dof controller)
  16781. */
  16782. ray: Nullable<Ray>;
  16783. /**
  16784. * Defines the local position of the pointer on the canvas.
  16785. */
  16786. localPosition: Vector2;
  16787. /**
  16788. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16789. */
  16790. skipOnPointerObservable: boolean;
  16791. /**
  16792. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16793. * @param type Defines the type of event (PointerEventTypes)
  16794. * @param event Defines the related dom event
  16795. * @param localX Defines the local x coordinates of the pointer when the event occured
  16796. * @param localY Defines the local y coordinates of the pointer when the event occured
  16797. */
  16798. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16799. }
  16800. /**
  16801. * This type contains all the data related to a pointer event in Babylon.js.
  16802. * 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.
  16803. */
  16804. export class PointerInfo extends PointerInfoBase {
  16805. /**
  16806. * Defines the picking info associated to the info (if any)\
  16807. */
  16808. pickInfo: Nullable<PickingInfo>;
  16809. /**
  16810. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16811. * @param type Defines the type of event (PointerEventTypes)
  16812. * @param event Defines the related dom event
  16813. * @param pickInfo Defines the picking info associated to the info (if any)\
  16814. */
  16815. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16816. /**
  16817. * Defines the picking info associated to the info (if any)\
  16818. */
  16819. pickInfo: Nullable<PickingInfo>);
  16820. }
  16821. /**
  16822. * Data relating to a touch event on the screen.
  16823. */
  16824. export interface PointerTouch {
  16825. /**
  16826. * X coordinate of touch.
  16827. */
  16828. x: number;
  16829. /**
  16830. * Y coordinate of touch.
  16831. */
  16832. y: number;
  16833. /**
  16834. * Id of touch. Unique for each finger.
  16835. */
  16836. pointerId: number;
  16837. /**
  16838. * Event type passed from DOM.
  16839. */
  16840. type: any;
  16841. }
  16842. }
  16843. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16844. import { Observable } from "babylonjs/Misc/observable";
  16845. import { Nullable } from "babylonjs/types";
  16846. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16848. /**
  16849. * Manage the mouse inputs to control the movement of a free camera.
  16850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16851. */
  16852. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16853. /**
  16854. * Define if touch is enabled in the mouse input
  16855. */
  16856. touchEnabled: boolean;
  16857. /**
  16858. * Defines the camera the input is attached to.
  16859. */
  16860. camera: FreeCamera;
  16861. /**
  16862. * Defines the buttons associated with the input to handle camera move.
  16863. */
  16864. buttons: number[];
  16865. /**
  16866. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16867. */
  16868. angularSensibility: number;
  16869. private _pointerInput;
  16870. private _onMouseMove;
  16871. private _observer;
  16872. private previousPosition;
  16873. /**
  16874. * Observable for when a pointer move event occurs containing the move offset
  16875. */
  16876. onPointerMovedObservable: Observable<{
  16877. offsetX: number;
  16878. offsetY: number;
  16879. }>;
  16880. /**
  16881. * @hidden
  16882. * If the camera should be rotated automatically based on pointer movement
  16883. */
  16884. _allowCameraRotation: boolean;
  16885. /**
  16886. * Manage the mouse inputs to control the movement of a free camera.
  16887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16888. * @param touchEnabled Defines if touch is enabled or not
  16889. */
  16890. constructor(
  16891. /**
  16892. * Define if touch is enabled in the mouse input
  16893. */
  16894. touchEnabled?: boolean);
  16895. /**
  16896. * Attach the input controls to a specific dom element to get the input from.
  16897. * @param element Defines the element the controls should be listened from
  16898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16899. */
  16900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16901. /**
  16902. * Called on JS contextmenu event.
  16903. * Override this method to provide functionality.
  16904. */
  16905. protected onContextMenu(evt: PointerEvent): void;
  16906. /**
  16907. * Detach the current controls from the specified dom element.
  16908. * @param element Defines the element to stop listening the inputs from
  16909. */
  16910. detachControl(element: Nullable<HTMLElement>): void;
  16911. /**
  16912. * Gets the class name of the current intput.
  16913. * @returns the class name
  16914. */
  16915. getClassName(): string;
  16916. /**
  16917. * Get the friendly name associated with the input class.
  16918. * @returns the input friendly name
  16919. */
  16920. getSimpleName(): string;
  16921. }
  16922. }
  16923. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  16924. import { Nullable } from "babylonjs/types";
  16925. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16926. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16927. /**
  16928. * Manage the touch inputs to control the movement of a free camera.
  16929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16930. */
  16931. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16932. /**
  16933. * Defines the camera the input is attached to.
  16934. */
  16935. camera: FreeCamera;
  16936. /**
  16937. * Defines the touch sensibility for rotation.
  16938. * The higher the faster.
  16939. */
  16940. touchAngularSensibility: number;
  16941. /**
  16942. * Defines the touch sensibility for move.
  16943. * The higher the faster.
  16944. */
  16945. touchMoveSensibility: number;
  16946. private _offsetX;
  16947. private _offsetY;
  16948. private _pointerPressed;
  16949. private _pointerInput;
  16950. private _observer;
  16951. private _onLostFocus;
  16952. /**
  16953. * Attach the input controls to a specific dom element to get the input from.
  16954. * @param element Defines the element the controls should be listened from
  16955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16956. */
  16957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16958. /**
  16959. * Detach the current controls from the specified dom element.
  16960. * @param element Defines the element to stop listening the inputs from
  16961. */
  16962. detachControl(element: Nullable<HTMLElement>): void;
  16963. /**
  16964. * Update the current camera state depending on the inputs that have been used this frame.
  16965. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16966. */
  16967. checkInputs(): void;
  16968. /**
  16969. * Gets the class name of the current intput.
  16970. * @returns the class name
  16971. */
  16972. getClassName(): string;
  16973. /**
  16974. * Get the friendly name associated with the input class.
  16975. * @returns the input friendly name
  16976. */
  16977. getSimpleName(): string;
  16978. }
  16979. }
  16980. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  16981. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16982. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  16983. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  16984. import { Nullable } from "babylonjs/types";
  16985. /**
  16986. * Default Inputs manager for the FreeCamera.
  16987. * It groups all the default supported inputs for ease of use.
  16988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16989. */
  16990. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16991. /**
  16992. * @hidden
  16993. */
  16994. _mouseInput: Nullable<FreeCameraMouseInput>;
  16995. /**
  16996. * Instantiates a new FreeCameraInputsManager.
  16997. * @param camera Defines the camera the inputs belong to
  16998. */
  16999. constructor(camera: FreeCamera);
  17000. /**
  17001. * Add keyboard input support to the input manager.
  17002. * @returns the current input manager
  17003. */
  17004. addKeyboard(): FreeCameraInputsManager;
  17005. /**
  17006. * Add mouse input support to the input manager.
  17007. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17008. * @returns the current input manager
  17009. */
  17010. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17011. /**
  17012. * Removes the mouse input support from the manager
  17013. * @returns the current input manager
  17014. */
  17015. removeMouse(): FreeCameraInputsManager;
  17016. /**
  17017. * Add touch input support to the input manager.
  17018. * @returns the current input manager
  17019. */
  17020. addTouch(): FreeCameraInputsManager;
  17021. /**
  17022. * Remove all attached input methods from a camera
  17023. */
  17024. clear(): void;
  17025. }
  17026. }
  17027. declare module "babylonjs/Cameras/freeCamera" {
  17028. import { Vector3 } from "babylonjs/Maths/math";
  17029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17030. import { Scene } from "babylonjs/scene";
  17031. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17032. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17033. /**
  17034. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17035. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17036. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17037. */
  17038. export class FreeCamera extends TargetCamera {
  17039. /**
  17040. * Define the collision ellipsoid of the camera.
  17041. * This is helpful to simulate a camera body like the player body around the camera
  17042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17043. */
  17044. ellipsoid: Vector3;
  17045. /**
  17046. * Define an offset for the position of the ellipsoid around the camera.
  17047. * This can be helpful to determine the center of the body near the gravity center of the body
  17048. * instead of its head.
  17049. */
  17050. ellipsoidOffset: Vector3;
  17051. /**
  17052. * Enable or disable collisions of the camera with the rest of the scene objects.
  17053. */
  17054. checkCollisions: boolean;
  17055. /**
  17056. * Enable or disable gravity on the camera.
  17057. */
  17058. applyGravity: boolean;
  17059. /**
  17060. * Define the input manager associated to the camera.
  17061. */
  17062. inputs: FreeCameraInputsManager;
  17063. /**
  17064. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17065. * Higher values reduce sensitivity.
  17066. */
  17067. /**
  17068. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17069. * Higher values reduce sensitivity.
  17070. */
  17071. angularSensibility: number;
  17072. /**
  17073. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17074. */
  17075. keysUp: number[];
  17076. /**
  17077. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17078. */
  17079. keysDown: number[];
  17080. /**
  17081. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17082. */
  17083. keysLeft: number[];
  17084. /**
  17085. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17086. */
  17087. keysRight: number[];
  17088. /**
  17089. * Event raised when the camera collide with a mesh in the scene.
  17090. */
  17091. onCollide: (collidedMesh: AbstractMesh) => void;
  17092. private _collider;
  17093. private _needMoveForGravity;
  17094. private _oldPosition;
  17095. private _diffPosition;
  17096. private _newPosition;
  17097. /** @hidden */
  17098. _localDirection: Vector3;
  17099. /** @hidden */
  17100. _transformedDirection: Vector3;
  17101. /**
  17102. * Instantiates a Free Camera.
  17103. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17104. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17105. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17106. * @param name Define the name of the camera in the scene
  17107. * @param position Define the start position of the camera in the scene
  17108. * @param scene Define the scene the camera belongs to
  17109. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17110. */
  17111. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17112. /**
  17113. * Attached controls to the current camera.
  17114. * @param element Defines the element the controls should be listened from
  17115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17116. */
  17117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17118. /**
  17119. * Detach the current controls from the camera.
  17120. * The camera will stop reacting to inputs.
  17121. * @param element Defines the element to stop listening the inputs from
  17122. */
  17123. detachControl(element: HTMLElement): void;
  17124. private _collisionMask;
  17125. /**
  17126. * Define a collision mask to limit the list of object the camera can collide with
  17127. */
  17128. collisionMask: number;
  17129. /** @hidden */
  17130. _collideWithWorld(displacement: Vector3): void;
  17131. private _onCollisionPositionChange;
  17132. /** @hidden */
  17133. _checkInputs(): void;
  17134. /** @hidden */
  17135. _decideIfNeedsToMove(): boolean;
  17136. /** @hidden */
  17137. _updatePosition(): void;
  17138. /**
  17139. * Destroy the camera and release the current resources hold by it.
  17140. */
  17141. dispose(): void;
  17142. /**
  17143. * Gets the current object class name.
  17144. * @return the class name
  17145. */
  17146. getClassName(): string;
  17147. }
  17148. }
  17149. declare module "babylonjs/Gamepads/gamepad" {
  17150. import { Observable } from "babylonjs/Misc/observable";
  17151. /**
  17152. * Represents a gamepad control stick position
  17153. */
  17154. export class StickValues {
  17155. /**
  17156. * The x component of the control stick
  17157. */
  17158. x: number;
  17159. /**
  17160. * The y component of the control stick
  17161. */
  17162. y: number;
  17163. /**
  17164. * Initializes the gamepad x and y control stick values
  17165. * @param x The x component of the gamepad control stick value
  17166. * @param y The y component of the gamepad control stick value
  17167. */
  17168. constructor(
  17169. /**
  17170. * The x component of the control stick
  17171. */
  17172. x: number,
  17173. /**
  17174. * The y component of the control stick
  17175. */
  17176. y: number);
  17177. }
  17178. /**
  17179. * An interface which manages callbacks for gamepad button changes
  17180. */
  17181. export interface GamepadButtonChanges {
  17182. /**
  17183. * Called when a gamepad has been changed
  17184. */
  17185. changed: boolean;
  17186. /**
  17187. * Called when a gamepad press event has been triggered
  17188. */
  17189. pressChanged: boolean;
  17190. /**
  17191. * Called when a touch event has been triggered
  17192. */
  17193. touchChanged: boolean;
  17194. /**
  17195. * Called when a value has changed
  17196. */
  17197. valueChanged: boolean;
  17198. }
  17199. /**
  17200. * Represents a gamepad
  17201. */
  17202. export class Gamepad {
  17203. /**
  17204. * The id of the gamepad
  17205. */
  17206. id: string;
  17207. /**
  17208. * The index of the gamepad
  17209. */
  17210. index: number;
  17211. /**
  17212. * The browser gamepad
  17213. */
  17214. browserGamepad: any;
  17215. /**
  17216. * Specifies what type of gamepad this represents
  17217. */
  17218. type: number;
  17219. private _leftStick;
  17220. private _rightStick;
  17221. /** @hidden */
  17222. _isConnected: boolean;
  17223. private _leftStickAxisX;
  17224. private _leftStickAxisY;
  17225. private _rightStickAxisX;
  17226. private _rightStickAxisY;
  17227. /**
  17228. * Triggered when the left control stick has been changed
  17229. */
  17230. private _onleftstickchanged;
  17231. /**
  17232. * Triggered when the right control stick has been changed
  17233. */
  17234. private _onrightstickchanged;
  17235. /**
  17236. * Represents a gamepad controller
  17237. */
  17238. static GAMEPAD: number;
  17239. /**
  17240. * Represents a generic controller
  17241. */
  17242. static GENERIC: number;
  17243. /**
  17244. * Represents an XBox controller
  17245. */
  17246. static XBOX: number;
  17247. /**
  17248. * Represents a pose-enabled controller
  17249. */
  17250. static POSE_ENABLED: number;
  17251. /**
  17252. * Specifies whether the left control stick should be Y-inverted
  17253. */
  17254. protected _invertLeftStickY: boolean;
  17255. /**
  17256. * Specifies if the gamepad has been connected
  17257. */
  17258. readonly isConnected: boolean;
  17259. /**
  17260. * Initializes the gamepad
  17261. * @param id The id of the gamepad
  17262. * @param index The index of the gamepad
  17263. * @param browserGamepad The browser gamepad
  17264. * @param leftStickX The x component of the left joystick
  17265. * @param leftStickY The y component of the left joystick
  17266. * @param rightStickX The x component of the right joystick
  17267. * @param rightStickY The y component of the right joystick
  17268. */
  17269. constructor(
  17270. /**
  17271. * The id of the gamepad
  17272. */
  17273. id: string,
  17274. /**
  17275. * The index of the gamepad
  17276. */
  17277. index: number,
  17278. /**
  17279. * The browser gamepad
  17280. */
  17281. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17282. /**
  17283. * Callback triggered when the left joystick has changed
  17284. * @param callback
  17285. */
  17286. onleftstickchanged(callback: (values: StickValues) => void): void;
  17287. /**
  17288. * Callback triggered when the right joystick has changed
  17289. * @param callback
  17290. */
  17291. onrightstickchanged(callback: (values: StickValues) => void): void;
  17292. /**
  17293. * Gets the left joystick
  17294. */
  17295. /**
  17296. * Sets the left joystick values
  17297. */
  17298. leftStick: StickValues;
  17299. /**
  17300. * Gets the right joystick
  17301. */
  17302. /**
  17303. * Sets the right joystick value
  17304. */
  17305. rightStick: StickValues;
  17306. /**
  17307. * Updates the gamepad joystick positions
  17308. */
  17309. update(): void;
  17310. /**
  17311. * Disposes the gamepad
  17312. */
  17313. dispose(): void;
  17314. }
  17315. /**
  17316. * Represents a generic gamepad
  17317. */
  17318. export class GenericPad extends Gamepad {
  17319. private _buttons;
  17320. private _onbuttondown;
  17321. private _onbuttonup;
  17322. /**
  17323. * Observable triggered when a button has been pressed
  17324. */
  17325. onButtonDownObservable: Observable<number>;
  17326. /**
  17327. * Observable triggered when a button has been released
  17328. */
  17329. onButtonUpObservable: Observable<number>;
  17330. /**
  17331. * Callback triggered when a button has been pressed
  17332. * @param callback Called when a button has been pressed
  17333. */
  17334. onbuttondown(callback: (buttonPressed: number) => void): void;
  17335. /**
  17336. * Callback triggered when a button has been released
  17337. * @param callback Called when a button has been released
  17338. */
  17339. onbuttonup(callback: (buttonReleased: number) => void): void;
  17340. /**
  17341. * Initializes the generic gamepad
  17342. * @param id The id of the generic gamepad
  17343. * @param index The index of the generic gamepad
  17344. * @param browserGamepad The browser gamepad
  17345. */
  17346. constructor(id: string, index: number, browserGamepad: any);
  17347. private _setButtonValue;
  17348. /**
  17349. * Updates the generic gamepad
  17350. */
  17351. update(): void;
  17352. /**
  17353. * Disposes the generic gamepad
  17354. */
  17355. dispose(): void;
  17356. }
  17357. }
  17358. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17359. import { Observable } from "babylonjs/Misc/observable";
  17360. import { Nullable } from "babylonjs/types";
  17361. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17362. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17364. import { Ray } from "babylonjs/Culling/ray";
  17365. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17366. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17367. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17368. /**
  17369. * Defines the types of pose enabled controllers that are supported
  17370. */
  17371. export enum PoseEnabledControllerType {
  17372. /**
  17373. * HTC Vive
  17374. */
  17375. VIVE = 0,
  17376. /**
  17377. * Oculus Rift
  17378. */
  17379. OCULUS = 1,
  17380. /**
  17381. * Windows mixed reality
  17382. */
  17383. WINDOWS = 2,
  17384. /**
  17385. * Samsung gear VR
  17386. */
  17387. GEAR_VR = 3,
  17388. /**
  17389. * Google Daydream
  17390. */
  17391. DAYDREAM = 4,
  17392. /**
  17393. * Generic
  17394. */
  17395. GENERIC = 5
  17396. }
  17397. /**
  17398. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17399. */
  17400. export interface MutableGamepadButton {
  17401. /**
  17402. * Value of the button/trigger
  17403. */
  17404. value: number;
  17405. /**
  17406. * If the button/trigger is currently touched
  17407. */
  17408. touched: boolean;
  17409. /**
  17410. * If the button/trigger is currently pressed
  17411. */
  17412. pressed: boolean;
  17413. }
  17414. /**
  17415. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17416. * @hidden
  17417. */
  17418. export interface ExtendedGamepadButton extends GamepadButton {
  17419. /**
  17420. * If the button/trigger is currently pressed
  17421. */
  17422. readonly pressed: boolean;
  17423. /**
  17424. * If the button/trigger is currently touched
  17425. */
  17426. readonly touched: boolean;
  17427. /**
  17428. * Value of the button/trigger
  17429. */
  17430. readonly value: number;
  17431. }
  17432. /** @hidden */
  17433. export interface _GamePadFactory {
  17434. /**
  17435. * Returns wether or not the current gamepad can be created for this type of controller.
  17436. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17437. * @returns true if it can be created, otherwise false
  17438. */
  17439. canCreate(gamepadInfo: any): boolean;
  17440. /**
  17441. * Creates a new instance of the Gamepad.
  17442. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17443. * @returns the new gamepad instance
  17444. */
  17445. create(gamepadInfo: any): Gamepad;
  17446. }
  17447. /**
  17448. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17449. */
  17450. export class PoseEnabledControllerHelper {
  17451. /** @hidden */
  17452. static _ControllerFactories: _GamePadFactory[];
  17453. /** @hidden */
  17454. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17455. /**
  17456. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17457. * @param vrGamepad the gamepad to initialized
  17458. * @returns a vr controller of the type the gamepad identified as
  17459. */
  17460. static InitiateController(vrGamepad: any): Gamepad;
  17461. }
  17462. /**
  17463. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17464. */
  17465. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17466. private _deviceRoomPosition;
  17467. private _deviceRoomRotationQuaternion;
  17468. /**
  17469. * The device position in babylon space
  17470. */
  17471. devicePosition: Vector3;
  17472. /**
  17473. * The device rotation in babylon space
  17474. */
  17475. deviceRotationQuaternion: Quaternion;
  17476. /**
  17477. * The scale factor of the device in babylon space
  17478. */
  17479. deviceScaleFactor: number;
  17480. /**
  17481. * (Likely devicePosition should be used instead) The device position in its room space
  17482. */
  17483. position: Vector3;
  17484. /**
  17485. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17486. */
  17487. rotationQuaternion: Quaternion;
  17488. /**
  17489. * The type of controller (Eg. Windows mixed reality)
  17490. */
  17491. controllerType: PoseEnabledControllerType;
  17492. protected _calculatedPosition: Vector3;
  17493. private _calculatedRotation;
  17494. /**
  17495. * The raw pose from the device
  17496. */
  17497. rawPose: DevicePose;
  17498. private _trackPosition;
  17499. private _maxRotationDistFromHeadset;
  17500. private _draggedRoomRotation;
  17501. /**
  17502. * @hidden
  17503. */
  17504. _disableTrackPosition(fixedPosition: Vector3): void;
  17505. /**
  17506. * Internal, the mesh attached to the controller
  17507. * @hidden
  17508. */
  17509. _mesh: Nullable<AbstractMesh>;
  17510. private _poseControlledCamera;
  17511. private _leftHandSystemQuaternion;
  17512. /**
  17513. * Internal, matrix used to convert room space to babylon space
  17514. * @hidden
  17515. */
  17516. _deviceToWorld: Matrix;
  17517. /**
  17518. * Node to be used when casting a ray from the controller
  17519. * @hidden
  17520. */
  17521. _pointingPoseNode: Nullable<TransformNode>;
  17522. /**
  17523. * Name of the child mesh that can be used to cast a ray from the controller
  17524. */
  17525. static readonly POINTING_POSE: string;
  17526. /**
  17527. * Creates a new PoseEnabledController from a gamepad
  17528. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17529. */
  17530. constructor(browserGamepad: any);
  17531. private _workingMatrix;
  17532. /**
  17533. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17534. */
  17535. update(): void;
  17536. /**
  17537. * Updates only the pose device and mesh without doing any button event checking
  17538. */
  17539. protected _updatePoseAndMesh(): void;
  17540. /**
  17541. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17542. * @param poseData raw pose fromthe device
  17543. */
  17544. updateFromDevice(poseData: DevicePose): void;
  17545. /**
  17546. * @hidden
  17547. */
  17548. _meshAttachedObservable: Observable<AbstractMesh>;
  17549. /**
  17550. * Attaches a mesh to the controller
  17551. * @param mesh the mesh to be attached
  17552. */
  17553. attachToMesh(mesh: AbstractMesh): void;
  17554. /**
  17555. * Attaches the controllers mesh to a camera
  17556. * @param camera the camera the mesh should be attached to
  17557. */
  17558. attachToPoseControlledCamera(camera: TargetCamera): void;
  17559. /**
  17560. * Disposes of the controller
  17561. */
  17562. dispose(): void;
  17563. /**
  17564. * The mesh that is attached to the controller
  17565. */
  17566. readonly mesh: Nullable<AbstractMesh>;
  17567. /**
  17568. * Gets the ray of the controller in the direction the controller is pointing
  17569. * @param length the length the resulting ray should be
  17570. * @returns a ray in the direction the controller is pointing
  17571. */
  17572. getForwardRay(length?: number): Ray;
  17573. }
  17574. }
  17575. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17576. import { Observable } from "babylonjs/Misc/observable";
  17577. import { Scene } from "babylonjs/scene";
  17578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17579. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17580. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17581. /**
  17582. * Defines the WebVRController object that represents controllers tracked in 3D space
  17583. */
  17584. export abstract class WebVRController extends PoseEnabledController {
  17585. /**
  17586. * Internal, the default controller model for the controller
  17587. */
  17588. protected _defaultModel: AbstractMesh;
  17589. /**
  17590. * Fired when the trigger state has changed
  17591. */
  17592. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17593. /**
  17594. * Fired when the main button state has changed
  17595. */
  17596. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17597. /**
  17598. * Fired when the secondary button state has changed
  17599. */
  17600. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17601. /**
  17602. * Fired when the pad state has changed
  17603. */
  17604. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17605. /**
  17606. * Fired when controllers stick values have changed
  17607. */
  17608. onPadValuesChangedObservable: Observable<StickValues>;
  17609. /**
  17610. * Array of button availible on the controller
  17611. */
  17612. protected _buttons: Array<MutableGamepadButton>;
  17613. private _onButtonStateChange;
  17614. /**
  17615. * Fired when a controller button's state has changed
  17616. * @param callback the callback containing the button that was modified
  17617. */
  17618. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17619. /**
  17620. * X and Y axis corresponding to the controllers joystick
  17621. */
  17622. pad: StickValues;
  17623. /**
  17624. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17625. */
  17626. hand: string;
  17627. /**
  17628. * The default controller model for the controller
  17629. */
  17630. readonly defaultModel: AbstractMesh;
  17631. /**
  17632. * Creates a new WebVRController from a gamepad
  17633. * @param vrGamepad the gamepad that the WebVRController should be created from
  17634. */
  17635. constructor(vrGamepad: any);
  17636. /**
  17637. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17638. */
  17639. update(): void;
  17640. /**
  17641. * Function to be called when a button is modified
  17642. */
  17643. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17644. /**
  17645. * Loads a mesh and attaches it to the controller
  17646. * @param scene the scene the mesh should be added to
  17647. * @param meshLoaded callback for when the mesh has been loaded
  17648. */
  17649. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17650. private _setButtonValue;
  17651. private _changes;
  17652. private _checkChanges;
  17653. /**
  17654. * Disposes of th webVRCOntroller
  17655. */
  17656. dispose(): void;
  17657. }
  17658. }
  17659. declare module "babylonjs/Lights/hemisphericLight" {
  17660. import { Nullable } from "babylonjs/types";
  17661. import { Scene } from "babylonjs/scene";
  17662. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17663. import { Effect } from "babylonjs/Materials/effect";
  17664. import { Light } from "babylonjs/Lights/light";
  17665. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17666. /**
  17667. * The HemisphericLight simulates the ambient environment light,
  17668. * so the passed direction is the light reflection direction, not the incoming direction.
  17669. */
  17670. export class HemisphericLight extends Light {
  17671. /**
  17672. * The groundColor is the light in the opposite direction to the one specified during creation.
  17673. * 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.
  17674. */
  17675. groundColor: Color3;
  17676. /**
  17677. * The light reflection direction, not the incoming direction.
  17678. */
  17679. direction: Vector3;
  17680. /**
  17681. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17682. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17683. * The HemisphericLight can't cast shadows.
  17684. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17685. * @param name The friendly name of the light
  17686. * @param direction The direction of the light reflection
  17687. * @param scene The scene the light belongs to
  17688. */
  17689. constructor(name: string, direction: Vector3, scene: Scene);
  17690. protected _buildUniformLayout(): void;
  17691. /**
  17692. * Returns the string "HemisphericLight".
  17693. * @return The class name
  17694. */
  17695. getClassName(): string;
  17696. /**
  17697. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17698. * Returns the updated direction.
  17699. * @param target The target the direction should point to
  17700. * @return The computed direction
  17701. */
  17702. setDirectionToTarget(target: Vector3): Vector3;
  17703. /**
  17704. * Returns the shadow generator associated to the light.
  17705. * @returns Always null for hemispheric lights because it does not support shadows.
  17706. */
  17707. getShadowGenerator(): Nullable<IShadowGenerator>;
  17708. /**
  17709. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17710. * @param effect The effect to update
  17711. * @param lightIndex The index of the light in the effect to update
  17712. * @returns The hemispheric light
  17713. */
  17714. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17715. /**
  17716. * Computes the world matrix of the node
  17717. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17718. * @param useWasUpdatedFlag defines a reserved property
  17719. * @returns the world matrix
  17720. */
  17721. computeWorldMatrix(): Matrix;
  17722. /**
  17723. * Returns the integer 3.
  17724. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17725. */
  17726. getTypeID(): number;
  17727. /**
  17728. * Prepares the list of defines specific to the light type.
  17729. * @param defines the list of defines
  17730. * @param lightIndex defines the index of the light for the effect
  17731. */
  17732. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17733. }
  17734. }
  17735. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17736. /** @hidden */
  17737. export var vrMultiviewToSingleviewPixelShader: {
  17738. name: string;
  17739. shader: string;
  17740. };
  17741. }
  17742. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17744. import { Scene } from "babylonjs/scene";
  17745. /**
  17746. * Renders to multiple views with a single draw call
  17747. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17748. */
  17749. export class MultiviewRenderTarget extends RenderTargetTexture {
  17750. /**
  17751. * Creates a multiview render target
  17752. * @param scene scene used with the render target
  17753. * @param size the size of the render target (used for each view)
  17754. */
  17755. constructor(scene: Scene, size?: number | {
  17756. width: number;
  17757. height: number;
  17758. } | {
  17759. ratio: number;
  17760. });
  17761. /**
  17762. * @hidden
  17763. * @param faceIndex the face index, if its a cube texture
  17764. */
  17765. _bindFrameBuffer(faceIndex?: number): void;
  17766. /**
  17767. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17768. * @returns the view count
  17769. */
  17770. getViewCount(): number;
  17771. }
  17772. }
  17773. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17774. import { Camera } from "babylonjs/Cameras/camera";
  17775. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17776. import { Nullable } from "babylonjs/types";
  17777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17778. import { Matrix } from "babylonjs/Maths/math";
  17779. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17780. module "babylonjs/Engines/engine" {
  17781. interface Engine {
  17782. /**
  17783. * Creates a new multiview render target
  17784. * @param width defines the width of the texture
  17785. * @param height defines the height of the texture
  17786. * @returns the created multiview texture
  17787. */
  17788. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17789. /**
  17790. * Binds a multiview framebuffer to be drawn to
  17791. * @param multiviewTexture texture to bind
  17792. */
  17793. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17794. }
  17795. }
  17796. module "babylonjs/Cameras/camera" {
  17797. interface Camera {
  17798. /**
  17799. * @hidden
  17800. * 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)
  17801. */
  17802. _useMultiviewToSingleView: boolean;
  17803. /**
  17804. * @hidden
  17805. * 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)
  17806. */
  17807. _multiviewTexture: Nullable<RenderTargetTexture>;
  17808. /**
  17809. * @hidden
  17810. * ensures the multiview texture of the camera exists and has the specified width/height
  17811. * @param width height to set on the multiview texture
  17812. * @param height width to set on the multiview texture
  17813. */
  17814. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17815. }
  17816. }
  17817. module "babylonjs/scene" {
  17818. interface Scene {
  17819. /** @hidden */
  17820. _transformMatrixR: Matrix;
  17821. /** @hidden */
  17822. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17823. /** @hidden */
  17824. _createMultiviewUbo(): void;
  17825. /** @hidden */
  17826. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17827. /** @hidden */
  17828. _renderMultiviewToSingleView(camera: Camera): void;
  17829. }
  17830. }
  17831. }
  17832. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17833. import { Camera } from "babylonjs/Cameras/camera";
  17834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17835. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17836. import "babylonjs/Engines/Extensions/engine.multiview";
  17837. /**
  17838. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17839. * This will not be used for webXR as it supports displaying texture arrays directly
  17840. */
  17841. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17842. /**
  17843. * Initializes a VRMultiviewToSingleview
  17844. * @param name name of the post process
  17845. * @param camera camera to be applied to
  17846. * @param scaleFactor scaling factor to the size of the output texture
  17847. */
  17848. constructor(name: string, camera: Camera, scaleFactor: number);
  17849. }
  17850. }
  17851. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17852. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17853. import { Nullable } from "babylonjs/types";
  17854. import { Size } from "babylonjs/Maths/math";
  17855. import { Observable } from "babylonjs/Misc/observable";
  17856. module "babylonjs/Engines/engine" {
  17857. interface Engine {
  17858. /** @hidden */
  17859. _vrDisplay: any;
  17860. /** @hidden */
  17861. _vrSupported: boolean;
  17862. /** @hidden */
  17863. _oldSize: Size;
  17864. /** @hidden */
  17865. _oldHardwareScaleFactor: number;
  17866. /** @hidden */
  17867. _vrExclusivePointerMode: boolean;
  17868. /** @hidden */
  17869. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17870. /** @hidden */
  17871. _onVRDisplayPointerRestricted: () => void;
  17872. /** @hidden */
  17873. _onVRDisplayPointerUnrestricted: () => void;
  17874. /** @hidden */
  17875. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17876. /** @hidden */
  17877. _onVrDisplayDisconnect: Nullable<() => void>;
  17878. /** @hidden */
  17879. _onVrDisplayPresentChange: Nullable<() => void>;
  17880. /**
  17881. * Observable signaled when VR display mode changes
  17882. */
  17883. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17884. /**
  17885. * Observable signaled when VR request present is complete
  17886. */
  17887. onVRRequestPresentComplete: Observable<boolean>;
  17888. /**
  17889. * Observable signaled when VR request present starts
  17890. */
  17891. onVRRequestPresentStart: Observable<Engine>;
  17892. /**
  17893. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17894. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17895. */
  17896. isInVRExclusivePointerMode: boolean;
  17897. /**
  17898. * Gets a boolean indicating if a webVR device was detected
  17899. * @returns true if a webVR device was detected
  17900. */
  17901. isVRDevicePresent(): boolean;
  17902. /**
  17903. * Gets the current webVR device
  17904. * @returns the current webVR device (or null)
  17905. */
  17906. getVRDevice(): any;
  17907. /**
  17908. * Initializes a webVR display and starts listening to display change events
  17909. * The onVRDisplayChangedObservable will be notified upon these changes
  17910. * @returns A promise containing a VRDisplay and if vr is supported
  17911. */
  17912. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17913. /** @hidden */
  17914. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17915. /**
  17916. * Call this function to switch to webVR mode
  17917. * Will do nothing if webVR is not supported or if there is no webVR device
  17918. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17919. */
  17920. enableVR(): void;
  17921. /** @hidden */
  17922. _onVRFullScreenTriggered(): void;
  17923. }
  17924. }
  17925. }
  17926. declare module "babylonjs/Cameras/VR/webVRCamera" {
  17927. import { Nullable } from "babylonjs/types";
  17928. import { Observable } from "babylonjs/Misc/observable";
  17929. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17930. import { Scene } from "babylonjs/scene";
  17931. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17932. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  17933. import { Node } from "babylonjs/node";
  17934. import { Ray } from "babylonjs/Culling/ray";
  17935. import "babylonjs/Cameras/RigModes/webVRRigMode";
  17936. import "babylonjs/Engines/Extensions/engine.webVR";
  17937. /**
  17938. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17939. * IMPORTANT!! The data is right-hand data.
  17940. * @export
  17941. * @interface DevicePose
  17942. */
  17943. export interface DevicePose {
  17944. /**
  17945. * The position of the device, values in array are [x,y,z].
  17946. */
  17947. readonly position: Nullable<Float32Array>;
  17948. /**
  17949. * The linearVelocity of the device, values in array are [x,y,z].
  17950. */
  17951. readonly linearVelocity: Nullable<Float32Array>;
  17952. /**
  17953. * The linearAcceleration of the device, values in array are [x,y,z].
  17954. */
  17955. readonly linearAcceleration: Nullable<Float32Array>;
  17956. /**
  17957. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17958. */
  17959. readonly orientation: Nullable<Float32Array>;
  17960. /**
  17961. * The angularVelocity of the device, values in array are [x,y,z].
  17962. */
  17963. readonly angularVelocity: Nullable<Float32Array>;
  17964. /**
  17965. * The angularAcceleration of the device, values in array are [x,y,z].
  17966. */
  17967. readonly angularAcceleration: Nullable<Float32Array>;
  17968. }
  17969. /**
  17970. * Interface representing a pose controlled object in Babylon.
  17971. * A pose controlled object has both regular pose values as well as pose values
  17972. * from an external device such as a VR head mounted display
  17973. */
  17974. export interface PoseControlled {
  17975. /**
  17976. * The position of the object in babylon space.
  17977. */
  17978. position: Vector3;
  17979. /**
  17980. * The rotation quaternion of the object in babylon space.
  17981. */
  17982. rotationQuaternion: Quaternion;
  17983. /**
  17984. * The position of the device in babylon space.
  17985. */
  17986. devicePosition?: Vector3;
  17987. /**
  17988. * The rotation quaternion of the device in babylon space.
  17989. */
  17990. deviceRotationQuaternion: Quaternion;
  17991. /**
  17992. * The raw pose coming from the device.
  17993. */
  17994. rawPose: Nullable<DevicePose>;
  17995. /**
  17996. * The scale of the device to be used when translating from device space to babylon space.
  17997. */
  17998. deviceScaleFactor: number;
  17999. /**
  18000. * Updates the poseControlled values based on the input device pose.
  18001. * @param poseData the pose data to update the object with
  18002. */
  18003. updateFromDevice(poseData: DevicePose): void;
  18004. }
  18005. /**
  18006. * Set of options to customize the webVRCamera
  18007. */
  18008. export interface WebVROptions {
  18009. /**
  18010. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18011. */
  18012. trackPosition?: boolean;
  18013. /**
  18014. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18015. */
  18016. positionScale?: number;
  18017. /**
  18018. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18019. */
  18020. displayName?: string;
  18021. /**
  18022. * Should the native controller meshes be initialized. (default: true)
  18023. */
  18024. controllerMeshes?: boolean;
  18025. /**
  18026. * Creating a default HemiLight only on controllers. (default: true)
  18027. */
  18028. defaultLightingOnControllers?: boolean;
  18029. /**
  18030. * If you don't want to use the default VR button of the helper. (default: false)
  18031. */
  18032. useCustomVRButton?: boolean;
  18033. /**
  18034. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18035. */
  18036. customVRButton?: HTMLButtonElement;
  18037. /**
  18038. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18039. */
  18040. rayLength?: number;
  18041. /**
  18042. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18043. */
  18044. defaultHeight?: number;
  18045. /**
  18046. * If multiview should be used if availible (default: false)
  18047. */
  18048. useMultiview?: boolean;
  18049. }
  18050. /**
  18051. * This represents a WebVR camera.
  18052. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18053. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18054. */
  18055. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18056. private webVROptions;
  18057. /**
  18058. * @hidden
  18059. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18060. */
  18061. _vrDevice: any;
  18062. /**
  18063. * The rawPose of the vrDevice.
  18064. */
  18065. rawPose: Nullable<DevicePose>;
  18066. private _onVREnabled;
  18067. private _specsVersion;
  18068. private _attached;
  18069. private _frameData;
  18070. protected _descendants: Array<Node>;
  18071. private _deviceRoomPosition;
  18072. /** @hidden */
  18073. _deviceRoomRotationQuaternion: Quaternion;
  18074. private _standingMatrix;
  18075. /**
  18076. * Represents device position in babylon space.
  18077. */
  18078. devicePosition: Vector3;
  18079. /**
  18080. * Represents device rotation in babylon space.
  18081. */
  18082. deviceRotationQuaternion: Quaternion;
  18083. /**
  18084. * The scale of the device to be used when translating from device space to babylon space.
  18085. */
  18086. deviceScaleFactor: number;
  18087. private _deviceToWorld;
  18088. private _worldToDevice;
  18089. /**
  18090. * References to the webVR controllers for the vrDevice.
  18091. */
  18092. controllers: Array<WebVRController>;
  18093. /**
  18094. * Emits an event when a controller is attached.
  18095. */
  18096. onControllersAttachedObservable: Observable<WebVRController[]>;
  18097. /**
  18098. * Emits an event when a controller's mesh has been loaded;
  18099. */
  18100. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18101. /**
  18102. * Emits an event when the HMD's pose has been updated.
  18103. */
  18104. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18105. private _poseSet;
  18106. /**
  18107. * If the rig cameras be used as parent instead of this camera.
  18108. */
  18109. rigParenting: boolean;
  18110. private _lightOnControllers;
  18111. private _defaultHeight?;
  18112. /**
  18113. * Instantiates a WebVRFreeCamera.
  18114. * @param name The name of the WebVRFreeCamera
  18115. * @param position The starting anchor position for the camera
  18116. * @param scene The scene the camera belongs to
  18117. * @param webVROptions a set of customizable options for the webVRCamera
  18118. */
  18119. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18120. /**
  18121. * Gets the device distance from the ground in meters.
  18122. * @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.
  18123. */
  18124. deviceDistanceToRoomGround(): number;
  18125. /**
  18126. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18127. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18128. */
  18129. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18130. /**
  18131. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18132. * @returns A promise with a boolean set to if the standing matrix is supported.
  18133. */
  18134. useStandingMatrixAsync(): Promise<boolean>;
  18135. /**
  18136. * Disposes the camera
  18137. */
  18138. dispose(): void;
  18139. /**
  18140. * Gets a vrController by name.
  18141. * @param name The name of the controller to retreive
  18142. * @returns the controller matching the name specified or null if not found
  18143. */
  18144. getControllerByName(name: string): Nullable<WebVRController>;
  18145. private _leftController;
  18146. /**
  18147. * The controller corresponding to the users left hand.
  18148. */
  18149. readonly leftController: Nullable<WebVRController>;
  18150. private _rightController;
  18151. /**
  18152. * The controller corresponding to the users right hand.
  18153. */
  18154. readonly rightController: Nullable<WebVRController>;
  18155. /**
  18156. * Casts a ray forward from the vrCamera's gaze.
  18157. * @param length Length of the ray (default: 100)
  18158. * @returns the ray corresponding to the gaze
  18159. */
  18160. getForwardRay(length?: number): Ray;
  18161. /**
  18162. * @hidden
  18163. * Updates the camera based on device's frame data
  18164. */
  18165. _checkInputs(): void;
  18166. /**
  18167. * Updates the poseControlled values based on the input device pose.
  18168. * @param poseData Pose coming from the device
  18169. */
  18170. updateFromDevice(poseData: DevicePose): void;
  18171. private _htmlElementAttached;
  18172. private _detachIfAttached;
  18173. /**
  18174. * WebVR's attach control will start broadcasting frames to the device.
  18175. * Note that in certain browsers (chrome for example) this function must be called
  18176. * within a user-interaction callback. Example:
  18177. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18178. *
  18179. * @param element html element to attach the vrDevice to
  18180. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18181. */
  18182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18183. /**
  18184. * Detaches the camera from the html element and disables VR
  18185. *
  18186. * @param element html element to detach from
  18187. */
  18188. detachControl(element: HTMLElement): void;
  18189. /**
  18190. * @returns the name of this class
  18191. */
  18192. getClassName(): string;
  18193. /**
  18194. * Calls resetPose on the vrDisplay
  18195. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18196. */
  18197. resetToCurrentRotation(): void;
  18198. /**
  18199. * @hidden
  18200. * Updates the rig cameras (left and right eye)
  18201. */
  18202. _updateRigCameras(): void;
  18203. private _workingVector;
  18204. private _oneVector;
  18205. private _workingMatrix;
  18206. private updateCacheCalled;
  18207. private _correctPositionIfNotTrackPosition;
  18208. /**
  18209. * @hidden
  18210. * Updates the cached values of the camera
  18211. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18212. */
  18213. _updateCache(ignoreParentClass?: boolean): void;
  18214. /**
  18215. * @hidden
  18216. * Get current device position in babylon world
  18217. */
  18218. _computeDevicePosition(): void;
  18219. /**
  18220. * Updates the current device position and rotation in the babylon world
  18221. */
  18222. update(): void;
  18223. /**
  18224. * @hidden
  18225. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18226. * @returns an identity matrix
  18227. */
  18228. _getViewMatrix(): Matrix;
  18229. private _tmpMatrix;
  18230. /**
  18231. * This function is called by the two RIG cameras.
  18232. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18233. * @hidden
  18234. */
  18235. _getWebVRViewMatrix(): Matrix;
  18236. /** @hidden */
  18237. _getWebVRProjectionMatrix(): Matrix;
  18238. private _onGamepadConnectedObserver;
  18239. private _onGamepadDisconnectedObserver;
  18240. private _updateCacheWhenTrackingDisabledObserver;
  18241. /**
  18242. * Initializes the controllers and their meshes
  18243. */
  18244. initControllers(): void;
  18245. }
  18246. }
  18247. declare module "babylonjs/PostProcesses/postProcess" {
  18248. import { Nullable } from "babylonjs/types";
  18249. import { SmartArray } from "babylonjs/Misc/smartArray";
  18250. import { Observable } from "babylonjs/Misc/observable";
  18251. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18252. import { Camera } from "babylonjs/Cameras/camera";
  18253. import { Effect } from "babylonjs/Materials/effect";
  18254. import "babylonjs/Shaders/postprocess.vertex";
  18255. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18256. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18257. import { Engine } from "babylonjs/Engines/engine";
  18258. /**
  18259. * Size options for a post process
  18260. */
  18261. export type PostProcessOptions = {
  18262. width: number;
  18263. height: number;
  18264. };
  18265. /**
  18266. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18267. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18268. */
  18269. export class PostProcess {
  18270. /** Name of the PostProcess. */
  18271. name: string;
  18272. /**
  18273. * Gets or sets the unique id of the post process
  18274. */
  18275. uniqueId: number;
  18276. /**
  18277. * Width of the texture to apply the post process on
  18278. */
  18279. width: number;
  18280. /**
  18281. * Height of the texture to apply the post process on
  18282. */
  18283. height: number;
  18284. /**
  18285. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18286. * @hidden
  18287. */
  18288. _outputTexture: Nullable<InternalTexture>;
  18289. /**
  18290. * Sampling mode used by the shader
  18291. * See https://doc.babylonjs.com/classes/3.1/texture
  18292. */
  18293. renderTargetSamplingMode: number;
  18294. /**
  18295. * Clear color to use when screen clearing
  18296. */
  18297. clearColor: Color4;
  18298. /**
  18299. * If the buffer needs to be cleared before applying the post process. (default: true)
  18300. * Should be set to false if shader will overwrite all previous pixels.
  18301. */
  18302. autoClear: boolean;
  18303. /**
  18304. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18305. */
  18306. alphaMode: number;
  18307. /**
  18308. * Sets the setAlphaBlendConstants of the babylon engine
  18309. */
  18310. alphaConstants: Color4;
  18311. /**
  18312. * Animations to be used for the post processing
  18313. */
  18314. animations: import("babylonjs/Animations/animation").Animation[];
  18315. /**
  18316. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18317. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18318. */
  18319. enablePixelPerfectMode: boolean;
  18320. /**
  18321. * Force the postprocess to be applied without taking in account viewport
  18322. */
  18323. forceFullscreenViewport: boolean;
  18324. /**
  18325. * List of inspectable custom properties (used by the Inspector)
  18326. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18327. */
  18328. inspectableCustomProperties: IInspectable[];
  18329. /**
  18330. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18331. *
  18332. * | Value | Type | Description |
  18333. * | ----- | ----------------------------------- | ----------- |
  18334. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18335. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18336. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18337. *
  18338. */
  18339. scaleMode: number;
  18340. /**
  18341. * Force textures to be a power of two (default: false)
  18342. */
  18343. alwaysForcePOT: boolean;
  18344. private _samples;
  18345. /**
  18346. * Number of sample textures (default: 1)
  18347. */
  18348. samples: number;
  18349. /**
  18350. * Modify the scale of the post process to be the same as the viewport (default: false)
  18351. */
  18352. adaptScaleToCurrentViewport: boolean;
  18353. private _camera;
  18354. private _scene;
  18355. private _engine;
  18356. private _options;
  18357. private _reusable;
  18358. private _textureType;
  18359. /**
  18360. * Smart array of input and output textures for the post process.
  18361. * @hidden
  18362. */
  18363. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18364. /**
  18365. * The index in _textures that corresponds to the output texture.
  18366. * @hidden
  18367. */
  18368. _currentRenderTextureInd: number;
  18369. private _effect;
  18370. private _samplers;
  18371. private _fragmentUrl;
  18372. private _vertexUrl;
  18373. private _parameters;
  18374. private _scaleRatio;
  18375. protected _indexParameters: any;
  18376. private _shareOutputWithPostProcess;
  18377. private _texelSize;
  18378. private _forcedOutputTexture;
  18379. /**
  18380. * Returns the fragment url or shader name used in the post process.
  18381. * @returns the fragment url or name in the shader store.
  18382. */
  18383. getEffectName(): string;
  18384. /**
  18385. * An event triggered when the postprocess is activated.
  18386. */
  18387. onActivateObservable: Observable<Camera>;
  18388. private _onActivateObserver;
  18389. /**
  18390. * A function that is added to the onActivateObservable
  18391. */
  18392. onActivate: Nullable<(camera: Camera) => void>;
  18393. /**
  18394. * An event triggered when the postprocess changes its size.
  18395. */
  18396. onSizeChangedObservable: Observable<PostProcess>;
  18397. private _onSizeChangedObserver;
  18398. /**
  18399. * A function that is added to the onSizeChangedObservable
  18400. */
  18401. onSizeChanged: (postProcess: PostProcess) => void;
  18402. /**
  18403. * An event triggered when the postprocess applies its effect.
  18404. */
  18405. onApplyObservable: Observable<Effect>;
  18406. private _onApplyObserver;
  18407. /**
  18408. * A function that is added to the onApplyObservable
  18409. */
  18410. onApply: (effect: Effect) => void;
  18411. /**
  18412. * An event triggered before rendering the postprocess
  18413. */
  18414. onBeforeRenderObservable: Observable<Effect>;
  18415. private _onBeforeRenderObserver;
  18416. /**
  18417. * A function that is added to the onBeforeRenderObservable
  18418. */
  18419. onBeforeRender: (effect: Effect) => void;
  18420. /**
  18421. * An event triggered after rendering the postprocess
  18422. */
  18423. onAfterRenderObservable: Observable<Effect>;
  18424. private _onAfterRenderObserver;
  18425. /**
  18426. * A function that is added to the onAfterRenderObservable
  18427. */
  18428. onAfterRender: (efect: Effect) => void;
  18429. /**
  18430. * 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
  18431. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18432. */
  18433. inputTexture: InternalTexture;
  18434. /**
  18435. * Gets the camera which post process is applied to.
  18436. * @returns The camera the post process is applied to.
  18437. */
  18438. getCamera(): Camera;
  18439. /**
  18440. * Gets the texel size of the postprocess.
  18441. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18442. */
  18443. readonly texelSize: Vector2;
  18444. /**
  18445. * Creates a new instance PostProcess
  18446. * @param name The name of the PostProcess.
  18447. * @param fragmentUrl The url of the fragment shader to be used.
  18448. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18449. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18450. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18451. * @param camera The camera to apply the render pass to.
  18452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18453. * @param engine The engine which the post process will be applied. (default: current engine)
  18454. * @param reusable If the post process can be reused on the same frame. (default: false)
  18455. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18456. * @param textureType Type of textures used when performing the post process. (default: 0)
  18457. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18458. * @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
  18459. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18460. */
  18461. constructor(
  18462. /** Name of the PostProcess. */
  18463. 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);
  18464. /**
  18465. * Gets a string idenfifying the name of the class
  18466. * @returns "PostProcess" string
  18467. */
  18468. getClassName(): string;
  18469. /**
  18470. * Gets the engine which this post process belongs to.
  18471. * @returns The engine the post process was enabled with.
  18472. */
  18473. getEngine(): Engine;
  18474. /**
  18475. * The effect that is created when initializing the post process.
  18476. * @returns The created effect corresponding the the postprocess.
  18477. */
  18478. getEffect(): Effect;
  18479. /**
  18480. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18481. * @param postProcess The post process to share the output with.
  18482. * @returns This post process.
  18483. */
  18484. shareOutputWith(postProcess: PostProcess): PostProcess;
  18485. /**
  18486. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18487. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18488. */
  18489. useOwnOutput(): void;
  18490. /**
  18491. * Updates the effect with the current post process compile time values and recompiles the shader.
  18492. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18493. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18494. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18495. * @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
  18496. * @param onCompiled Called when the shader has been compiled.
  18497. * @param onError Called if there is an error when compiling a shader.
  18498. */
  18499. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18500. /**
  18501. * The post process is reusable if it can be used multiple times within one frame.
  18502. * @returns If the post process is reusable
  18503. */
  18504. isReusable(): boolean;
  18505. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18506. markTextureDirty(): void;
  18507. /**
  18508. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18509. * 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.
  18510. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18511. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18512. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18513. * @returns The target texture that was bound to be written to.
  18514. */
  18515. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18516. /**
  18517. * If the post process is supported.
  18518. */
  18519. readonly isSupported: boolean;
  18520. /**
  18521. * The aspect ratio of the output texture.
  18522. */
  18523. readonly aspectRatio: number;
  18524. /**
  18525. * Get a value indicating if the post-process is ready to be used
  18526. * @returns true if the post-process is ready (shader is compiled)
  18527. */
  18528. isReady(): boolean;
  18529. /**
  18530. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18531. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18532. */
  18533. apply(): Nullable<Effect>;
  18534. private _disposeTextures;
  18535. /**
  18536. * Disposes the post process.
  18537. * @param camera The camera to dispose the post process on.
  18538. */
  18539. dispose(camera?: Camera): void;
  18540. }
  18541. }
  18542. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18543. /** @hidden */
  18544. export var kernelBlurVaryingDeclaration: {
  18545. name: string;
  18546. shader: string;
  18547. };
  18548. }
  18549. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18550. /** @hidden */
  18551. export var kernelBlurFragment: {
  18552. name: string;
  18553. shader: string;
  18554. };
  18555. }
  18556. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18557. /** @hidden */
  18558. export var kernelBlurFragment2: {
  18559. name: string;
  18560. shader: string;
  18561. };
  18562. }
  18563. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18564. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18565. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18566. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18567. /** @hidden */
  18568. export var kernelBlurPixelShader: {
  18569. name: string;
  18570. shader: string;
  18571. };
  18572. }
  18573. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18574. /** @hidden */
  18575. export var kernelBlurVertex: {
  18576. name: string;
  18577. shader: string;
  18578. };
  18579. }
  18580. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18581. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18582. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18583. /** @hidden */
  18584. export var kernelBlurVertexShader: {
  18585. name: string;
  18586. shader: string;
  18587. };
  18588. }
  18589. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18590. import { Vector2 } from "babylonjs/Maths/math";
  18591. import { Nullable } from "babylonjs/types";
  18592. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18593. import { Camera } from "babylonjs/Cameras/camera";
  18594. import { Effect } from "babylonjs/Materials/effect";
  18595. import { Engine } from "babylonjs/Engines/engine";
  18596. import "babylonjs/Shaders/kernelBlur.fragment";
  18597. import "babylonjs/Shaders/kernelBlur.vertex";
  18598. /**
  18599. * The Blur Post Process which blurs an image based on a kernel and direction.
  18600. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18601. */
  18602. export class BlurPostProcess extends PostProcess {
  18603. /** The direction in which to blur the image. */
  18604. direction: Vector2;
  18605. private blockCompilation;
  18606. protected _kernel: number;
  18607. protected _idealKernel: number;
  18608. protected _packedFloat: boolean;
  18609. private _staticDefines;
  18610. /**
  18611. * Sets the length in pixels of the blur sample region
  18612. */
  18613. /**
  18614. * Gets the length in pixels of the blur sample region
  18615. */
  18616. kernel: number;
  18617. /**
  18618. * Sets wether or not the blur needs to unpack/repack floats
  18619. */
  18620. /**
  18621. * Gets wether or not the blur is unpacking/repacking floats
  18622. */
  18623. packedFloat: boolean;
  18624. /**
  18625. * Creates a new instance BlurPostProcess
  18626. * @param name The name of the effect.
  18627. * @param direction The direction in which to blur the image.
  18628. * @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.
  18629. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18630. * @param camera The camera to apply the render pass to.
  18631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18632. * @param engine The engine which the post process will be applied. (default: current engine)
  18633. * @param reusable If the post process can be reused on the same frame. (default: false)
  18634. * @param textureType Type of textures used when performing the post process. (default: 0)
  18635. * @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)
  18636. */
  18637. constructor(name: string,
  18638. /** The direction in which to blur the image. */
  18639. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18640. /**
  18641. * Updates the effect with the current post process compile time values and recompiles the shader.
  18642. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18643. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18644. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18645. * @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
  18646. * @param onCompiled Called when the shader has been compiled.
  18647. * @param onError Called if there is an error when compiling a shader.
  18648. */
  18649. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18650. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18651. /**
  18652. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18653. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18654. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18655. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18656. * The gaps between physical kernels are compensated for in the weighting of the samples
  18657. * @param idealKernel Ideal blur kernel.
  18658. * @return Nearest best kernel.
  18659. */
  18660. protected _nearestBestKernel(idealKernel: number): number;
  18661. /**
  18662. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18663. * @param x The point on the Gaussian distribution to sample.
  18664. * @return the value of the Gaussian function at x.
  18665. */
  18666. protected _gaussianWeight(x: number): number;
  18667. /**
  18668. * Generates a string that can be used as a floating point number in GLSL.
  18669. * @param x Value to print.
  18670. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18671. * @return GLSL float string.
  18672. */
  18673. protected _glslFloat(x: number, decimalFigures?: number): string;
  18674. }
  18675. }
  18676. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18677. import { Scene } from "babylonjs/scene";
  18678. import { Plane } from "babylonjs/Maths/math";
  18679. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18680. /**
  18681. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18682. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18683. * You can then easily use it as a reflectionTexture on a flat surface.
  18684. * In case the surface is not a plane, please consider relying on reflection probes.
  18685. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18686. */
  18687. export class MirrorTexture extends RenderTargetTexture {
  18688. private scene;
  18689. /**
  18690. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18691. * 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.
  18692. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18693. */
  18694. mirrorPlane: Plane;
  18695. /**
  18696. * Define the blur ratio used to blur the reflection if needed.
  18697. */
  18698. blurRatio: number;
  18699. /**
  18700. * Define the adaptive blur kernel used to blur the reflection if needed.
  18701. * This will autocompute the closest best match for the `blurKernel`
  18702. */
  18703. adaptiveBlurKernel: number;
  18704. /**
  18705. * Define the blur kernel used to blur the reflection if needed.
  18706. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18707. */
  18708. blurKernel: number;
  18709. /**
  18710. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18711. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18712. */
  18713. blurKernelX: number;
  18714. /**
  18715. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18716. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18717. */
  18718. blurKernelY: number;
  18719. private _autoComputeBlurKernel;
  18720. protected _onRatioRescale(): void;
  18721. private _updateGammaSpace;
  18722. private _imageProcessingConfigChangeObserver;
  18723. private _transformMatrix;
  18724. private _mirrorMatrix;
  18725. private _savedViewMatrix;
  18726. private _blurX;
  18727. private _blurY;
  18728. private _adaptiveBlurKernel;
  18729. private _blurKernelX;
  18730. private _blurKernelY;
  18731. private _blurRatio;
  18732. /**
  18733. * Instantiates a Mirror Texture.
  18734. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18735. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18736. * You can then easily use it as a reflectionTexture on a flat surface.
  18737. * In case the surface is not a plane, please consider relying on reflection probes.
  18738. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18739. * @param name
  18740. * @param size
  18741. * @param scene
  18742. * @param generateMipMaps
  18743. * @param type
  18744. * @param samplingMode
  18745. * @param generateDepthBuffer
  18746. */
  18747. constructor(name: string, size: number | {
  18748. width: number;
  18749. height: number;
  18750. } | {
  18751. ratio: number;
  18752. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18753. private _preparePostProcesses;
  18754. /**
  18755. * Clone the mirror texture.
  18756. * @returns the cloned texture
  18757. */
  18758. clone(): MirrorTexture;
  18759. /**
  18760. * Serialize the texture to a JSON representation you could use in Parse later on
  18761. * @returns the serialized JSON representation
  18762. */
  18763. serialize(): any;
  18764. /**
  18765. * Dispose the texture and release its associated resources.
  18766. */
  18767. dispose(): void;
  18768. }
  18769. }
  18770. declare module "babylonjs/Materials/Textures/texture" {
  18771. import { Observable } from "babylonjs/Misc/observable";
  18772. import { Nullable } from "babylonjs/types";
  18773. import { Scene } from "babylonjs/scene";
  18774. import { Matrix } from "babylonjs/Maths/math";
  18775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18776. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18777. /**
  18778. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18779. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18780. */
  18781. export class Texture extends BaseTexture {
  18782. /** @hidden */
  18783. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18784. /** @hidden */
  18785. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18786. /** @hidden */
  18787. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18788. /** nearest is mag = nearest and min = nearest and mip = linear */
  18789. static readonly NEAREST_SAMPLINGMODE: number;
  18790. /** nearest is mag = nearest and min = nearest and mip = linear */
  18791. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18792. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18793. static readonly BILINEAR_SAMPLINGMODE: number;
  18794. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18795. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18796. /** Trilinear is mag = linear and min = linear and mip = linear */
  18797. static readonly TRILINEAR_SAMPLINGMODE: number;
  18798. /** Trilinear is mag = linear and min = linear and mip = linear */
  18799. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18800. /** mag = nearest and min = nearest and mip = nearest */
  18801. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18802. /** mag = nearest and min = linear and mip = nearest */
  18803. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18804. /** mag = nearest and min = linear and mip = linear */
  18805. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18806. /** mag = nearest and min = linear and mip = none */
  18807. static readonly NEAREST_LINEAR: number;
  18808. /** mag = nearest and min = nearest and mip = none */
  18809. static readonly NEAREST_NEAREST: number;
  18810. /** mag = linear and min = nearest and mip = nearest */
  18811. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18812. /** mag = linear and min = nearest and mip = linear */
  18813. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18814. /** mag = linear and min = linear and mip = none */
  18815. static readonly LINEAR_LINEAR: number;
  18816. /** mag = linear and min = nearest and mip = none */
  18817. static readonly LINEAR_NEAREST: number;
  18818. /** Explicit coordinates mode */
  18819. static readonly EXPLICIT_MODE: number;
  18820. /** Spherical coordinates mode */
  18821. static readonly SPHERICAL_MODE: number;
  18822. /** Planar coordinates mode */
  18823. static readonly PLANAR_MODE: number;
  18824. /** Cubic coordinates mode */
  18825. static readonly CUBIC_MODE: number;
  18826. /** Projection coordinates mode */
  18827. static readonly PROJECTION_MODE: number;
  18828. /** Inverse Cubic coordinates mode */
  18829. static readonly SKYBOX_MODE: number;
  18830. /** Inverse Cubic coordinates mode */
  18831. static readonly INVCUBIC_MODE: number;
  18832. /** Equirectangular coordinates mode */
  18833. static readonly EQUIRECTANGULAR_MODE: number;
  18834. /** Equirectangular Fixed coordinates mode */
  18835. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18836. /** Equirectangular Fixed Mirrored coordinates mode */
  18837. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18838. /** Texture is not repeating outside of 0..1 UVs */
  18839. static readonly CLAMP_ADDRESSMODE: number;
  18840. /** Texture is repeating outside of 0..1 UVs */
  18841. static readonly WRAP_ADDRESSMODE: number;
  18842. /** Texture is repeating and mirrored */
  18843. static readonly MIRROR_ADDRESSMODE: number;
  18844. /**
  18845. * 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
  18846. */
  18847. static UseSerializedUrlIfAny: boolean;
  18848. /**
  18849. * Define the url of the texture.
  18850. */
  18851. url: Nullable<string>;
  18852. /**
  18853. * Define an offset on the texture to offset the u coordinates of the UVs
  18854. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18855. */
  18856. uOffset: number;
  18857. /**
  18858. * Define an offset on the texture to offset the v coordinates of the UVs
  18859. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18860. */
  18861. vOffset: number;
  18862. /**
  18863. * Define an offset on the texture to scale the u coordinates of the UVs
  18864. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18865. */
  18866. uScale: number;
  18867. /**
  18868. * Define an offset on the texture to scale the v coordinates of the UVs
  18869. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18870. */
  18871. vScale: number;
  18872. /**
  18873. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18874. * @see http://doc.babylonjs.com/how_to/more_materials
  18875. */
  18876. uAng: number;
  18877. /**
  18878. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18879. * @see http://doc.babylonjs.com/how_to/more_materials
  18880. */
  18881. vAng: number;
  18882. /**
  18883. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18884. * @see http://doc.babylonjs.com/how_to/more_materials
  18885. */
  18886. wAng: number;
  18887. /**
  18888. * Defines the center of rotation (U)
  18889. */
  18890. uRotationCenter: number;
  18891. /**
  18892. * Defines the center of rotation (V)
  18893. */
  18894. vRotationCenter: number;
  18895. /**
  18896. * Defines the center of rotation (W)
  18897. */
  18898. wRotationCenter: number;
  18899. /**
  18900. * Are mip maps generated for this texture or not.
  18901. */
  18902. readonly noMipmap: boolean;
  18903. /**
  18904. * List of inspectable custom properties (used by the Inspector)
  18905. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18906. */
  18907. inspectableCustomProperties: Nullable<IInspectable[]>;
  18908. private _noMipmap;
  18909. /** @hidden */
  18910. _invertY: boolean;
  18911. private _rowGenerationMatrix;
  18912. private _cachedTextureMatrix;
  18913. private _projectionModeMatrix;
  18914. private _t0;
  18915. private _t1;
  18916. private _t2;
  18917. private _cachedUOffset;
  18918. private _cachedVOffset;
  18919. private _cachedUScale;
  18920. private _cachedVScale;
  18921. private _cachedUAng;
  18922. private _cachedVAng;
  18923. private _cachedWAng;
  18924. private _cachedProjectionMatrixId;
  18925. private _cachedCoordinatesMode;
  18926. /** @hidden */
  18927. protected _initialSamplingMode: number;
  18928. /** @hidden */
  18929. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18930. private _deleteBuffer;
  18931. protected _format: Nullable<number>;
  18932. private _delayedOnLoad;
  18933. private _delayedOnError;
  18934. /**
  18935. * Observable triggered once the texture has been loaded.
  18936. */
  18937. onLoadObservable: Observable<Texture>;
  18938. protected _isBlocking: boolean;
  18939. /**
  18940. * Is the texture preventing material to render while loading.
  18941. * If false, a default texture will be used instead of the loading one during the preparation step.
  18942. */
  18943. isBlocking: boolean;
  18944. /**
  18945. * Get the current sampling mode associated with the texture.
  18946. */
  18947. readonly samplingMode: number;
  18948. /**
  18949. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18950. */
  18951. readonly invertY: boolean;
  18952. /**
  18953. * Instantiates a new texture.
  18954. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18955. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18956. * @param url define the url of the picture to load as a texture
  18957. * @param scene define the scene the texture will belong to
  18958. * @param noMipmap define if the texture will require mip maps or not
  18959. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18960. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18961. * @param onLoad define a callback triggered when the texture has been loaded
  18962. * @param onError define a callback triggered when an error occurred during the loading session
  18963. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18964. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18965. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18966. */
  18967. 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);
  18968. /**
  18969. * Update the url (and optional buffer) of this texture if url was null during construction.
  18970. * @param url the url of the texture
  18971. * @param buffer the buffer of the texture (defaults to null)
  18972. * @param onLoad callback called when the texture is loaded (defaults to null)
  18973. */
  18974. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18975. /**
  18976. * Finish the loading sequence of a texture flagged as delayed load.
  18977. * @hidden
  18978. */
  18979. delayLoad(): void;
  18980. private _prepareRowForTextureGeneration;
  18981. /**
  18982. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18983. * @returns the transform matrix of the texture.
  18984. */
  18985. getTextureMatrix(): Matrix;
  18986. /**
  18987. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18988. * @returns The reflection texture transform
  18989. */
  18990. getReflectionTextureMatrix(): Matrix;
  18991. /**
  18992. * Clones the texture.
  18993. * @returns the cloned texture
  18994. */
  18995. clone(): Texture;
  18996. /**
  18997. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18998. * @returns The JSON representation of the texture
  18999. */
  19000. serialize(): any;
  19001. /**
  19002. * Get the current class name of the texture useful for serialization or dynamic coding.
  19003. * @returns "Texture"
  19004. */
  19005. getClassName(): string;
  19006. /**
  19007. * Dispose the texture and release its associated resources.
  19008. */
  19009. dispose(): void;
  19010. /**
  19011. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19012. * @param parsedTexture Define the JSON representation of the texture
  19013. * @param scene Define the scene the parsed texture should be instantiated in
  19014. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19015. * @returns The parsed texture if successful
  19016. */
  19017. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19018. /**
  19019. * Creates a texture from its base 64 representation.
  19020. * @param data Define the base64 payload without the data: prefix
  19021. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19022. * @param scene Define the scene the texture should belong to
  19023. * @param noMipmap Forces the texture to not create mip map information if true
  19024. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19025. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19026. * @param onLoad define a callback triggered when the texture has been loaded
  19027. * @param onError define a callback triggered when an error occurred during the loading session
  19028. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19029. * @returns the created texture
  19030. */
  19031. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19032. /**
  19033. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19034. * @param data Define the base64 payload without the data: prefix
  19035. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19036. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19037. * @param scene Define the scene the texture should belong to
  19038. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19039. * @param noMipmap Forces the texture to not create mip map information if true
  19040. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19041. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19042. * @param onLoad define a callback triggered when the texture has been loaded
  19043. * @param onError define a callback triggered when an error occurred during the loading session
  19044. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19045. * @returns the created texture
  19046. */
  19047. 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;
  19048. }
  19049. }
  19050. declare module "babylonjs/PostProcesses/postProcessManager" {
  19051. import { Nullable } from "babylonjs/types";
  19052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19053. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19054. import { Scene } from "babylonjs/scene";
  19055. /**
  19056. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19057. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19058. */
  19059. export class PostProcessManager {
  19060. private _scene;
  19061. private _indexBuffer;
  19062. private _vertexBuffers;
  19063. /**
  19064. * Creates a new instance PostProcess
  19065. * @param scene The scene that the post process is associated with.
  19066. */
  19067. constructor(scene: Scene);
  19068. private _prepareBuffers;
  19069. private _buildIndexBuffer;
  19070. /**
  19071. * Rebuilds the vertex buffers of the manager.
  19072. * @hidden
  19073. */
  19074. _rebuild(): void;
  19075. /**
  19076. * Prepares a frame to be run through a post process.
  19077. * @param sourceTexture The input texture to the post procesess. (default: null)
  19078. * @param postProcesses An array of post processes to be run. (default: null)
  19079. * @returns True if the post processes were able to be run.
  19080. * @hidden
  19081. */
  19082. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19083. /**
  19084. * Manually render a set of post processes to a texture.
  19085. * @param postProcesses An array of post processes to be run.
  19086. * @param targetTexture The target texture to render to.
  19087. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19088. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19089. * @param lodLevel defines which lod of the texture to render to
  19090. */
  19091. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19092. /**
  19093. * Finalize the result of the output of the postprocesses.
  19094. * @param doNotPresent If true the result will not be displayed to the screen.
  19095. * @param targetTexture The target texture to render to.
  19096. * @param faceIndex The index of the face to bind the target texture to.
  19097. * @param postProcesses The array of post processes to render.
  19098. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19099. * @hidden
  19100. */
  19101. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19102. /**
  19103. * Disposes of the post process manager.
  19104. */
  19105. dispose(): void;
  19106. }
  19107. }
  19108. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19109. import { Scene } from "babylonjs/scene";
  19110. import { ISceneComponent } from "babylonjs/sceneComponent";
  19111. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19112. module "babylonjs/abstractScene" {
  19113. interface AbstractScene {
  19114. /**
  19115. * The list of procedural textures added to the scene
  19116. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19117. */
  19118. proceduralTextures: Array<ProceduralTexture>;
  19119. }
  19120. }
  19121. /**
  19122. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19123. * in a given scene.
  19124. */
  19125. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19126. /**
  19127. * The component name helpfull to identify the component in the list of scene components.
  19128. */
  19129. readonly name: string;
  19130. /**
  19131. * The scene the component belongs to.
  19132. */
  19133. scene: Scene;
  19134. /**
  19135. * Creates a new instance of the component for the given scene
  19136. * @param scene Defines the scene to register the component in
  19137. */
  19138. constructor(scene: Scene);
  19139. /**
  19140. * Registers the component in a given scene
  19141. */
  19142. register(): void;
  19143. /**
  19144. * Rebuilds the elements related to this component in case of
  19145. * context lost for instance.
  19146. */
  19147. rebuild(): void;
  19148. /**
  19149. * Disposes the component and the associated ressources.
  19150. */
  19151. dispose(): void;
  19152. private _beforeClear;
  19153. }
  19154. }
  19155. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19156. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19157. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19158. module "babylonjs/Engines/engine" {
  19159. interface Engine {
  19160. /**
  19161. * Creates a new render target cube texture
  19162. * @param size defines the size of the texture
  19163. * @param options defines the options used to create the texture
  19164. * @returns a new render target cube texture stored in an InternalTexture
  19165. */
  19166. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19167. }
  19168. }
  19169. }
  19170. declare module "babylonjs/Shaders/procedural.vertex" {
  19171. /** @hidden */
  19172. export var proceduralVertexShader: {
  19173. name: string;
  19174. shader: string;
  19175. };
  19176. }
  19177. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19178. import { Observable } from "babylonjs/Misc/observable";
  19179. import { Nullable } from "babylonjs/types";
  19180. import { Scene } from "babylonjs/scene";
  19181. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19182. import { Effect } from "babylonjs/Materials/effect";
  19183. import { Texture } from "babylonjs/Materials/Textures/texture";
  19184. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19185. import "babylonjs/Shaders/procedural.vertex";
  19186. /**
  19187. * 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.
  19188. * This is the base class of any Procedural texture and contains most of the shareable code.
  19189. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19190. */
  19191. export class ProceduralTexture extends Texture {
  19192. isCube: boolean;
  19193. /**
  19194. * Define if the texture is enabled or not (disabled texture will not render)
  19195. */
  19196. isEnabled: boolean;
  19197. /**
  19198. * Define if the texture must be cleared before rendering (default is true)
  19199. */
  19200. autoClear: boolean;
  19201. /**
  19202. * Callback called when the texture is generated
  19203. */
  19204. onGenerated: () => void;
  19205. /**
  19206. * Event raised when the texture is generated
  19207. */
  19208. onGeneratedObservable: Observable<ProceduralTexture>;
  19209. /** @hidden */
  19210. _generateMipMaps: boolean;
  19211. /** @hidden **/
  19212. _effect: Effect;
  19213. /** @hidden */
  19214. _textures: {
  19215. [key: string]: Texture;
  19216. };
  19217. private _size;
  19218. private _currentRefreshId;
  19219. private _refreshRate;
  19220. private _vertexBuffers;
  19221. private _indexBuffer;
  19222. private _uniforms;
  19223. private _samplers;
  19224. private _fragment;
  19225. private _floats;
  19226. private _ints;
  19227. private _floatsArrays;
  19228. private _colors3;
  19229. private _colors4;
  19230. private _vectors2;
  19231. private _vectors3;
  19232. private _matrices;
  19233. private _fallbackTexture;
  19234. private _fallbackTextureUsed;
  19235. private _engine;
  19236. private _cachedDefines;
  19237. private _contentUpdateId;
  19238. private _contentData;
  19239. /**
  19240. * Instantiates a new procedural texture.
  19241. * 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.
  19242. * This is the base class of any Procedural texture and contains most of the shareable code.
  19243. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19244. * @param name Define the name of the texture
  19245. * @param size Define the size of the texture to create
  19246. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19247. * @param scene Define the scene the texture belongs to
  19248. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19249. * @param generateMipMaps Define if the texture should creates mip maps or not
  19250. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19251. */
  19252. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19253. /**
  19254. * The effect that is created when initializing the post process.
  19255. * @returns The created effect corresponding the the postprocess.
  19256. */
  19257. getEffect(): Effect;
  19258. /**
  19259. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19260. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19261. */
  19262. getContent(): Nullable<ArrayBufferView>;
  19263. private _createIndexBuffer;
  19264. /** @hidden */
  19265. _rebuild(): void;
  19266. /**
  19267. * Resets the texture in order to recreate its associated resources.
  19268. * This can be called in case of context loss
  19269. */
  19270. reset(): void;
  19271. protected _getDefines(): string;
  19272. /**
  19273. * Is the texture ready to be used ? (rendered at least once)
  19274. * @returns true if ready, otherwise, false.
  19275. */
  19276. isReady(): boolean;
  19277. /**
  19278. * Resets the refresh counter of the texture and start bak from scratch.
  19279. * Could be useful to regenerate the texture if it is setup to render only once.
  19280. */
  19281. resetRefreshCounter(): void;
  19282. /**
  19283. * Set the fragment shader to use in order to render the texture.
  19284. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19285. */
  19286. setFragment(fragment: any): void;
  19287. /**
  19288. * Define the refresh rate of the texture or the rendering frequency.
  19289. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19290. */
  19291. refreshRate: number;
  19292. /** @hidden */
  19293. _shouldRender(): boolean;
  19294. /**
  19295. * Get the size the texture is rendering at.
  19296. * @returns the size (texture is always squared)
  19297. */
  19298. getRenderSize(): number;
  19299. /**
  19300. * Resize the texture to new value.
  19301. * @param size Define the new size the texture should have
  19302. * @param generateMipMaps Define whether the new texture should create mip maps
  19303. */
  19304. resize(size: number, generateMipMaps: boolean): void;
  19305. private _checkUniform;
  19306. /**
  19307. * Set a texture in the shader program used to render.
  19308. * @param name Define the name of the uniform samplers as defined in the shader
  19309. * @param texture Define the texture to bind to this sampler
  19310. * @return the texture itself allowing "fluent" like uniform updates
  19311. */
  19312. setTexture(name: string, texture: Texture): ProceduralTexture;
  19313. /**
  19314. * Set a float in the shader.
  19315. * @param name Define the name of the uniform as defined in the shader
  19316. * @param value Define the value to give to the uniform
  19317. * @return the texture itself allowing "fluent" like uniform updates
  19318. */
  19319. setFloat(name: string, value: number): ProceduralTexture;
  19320. /**
  19321. * Set a int in the shader.
  19322. * @param name Define the name of the uniform as defined in the shader
  19323. * @param value Define the value to give to the uniform
  19324. * @return the texture itself allowing "fluent" like uniform updates
  19325. */
  19326. setInt(name: string, value: number): ProceduralTexture;
  19327. /**
  19328. * Set an array of floats in the shader.
  19329. * @param name Define the name of the uniform as defined in the shader
  19330. * @param value Define the value to give to the uniform
  19331. * @return the texture itself allowing "fluent" like uniform updates
  19332. */
  19333. setFloats(name: string, value: number[]): ProceduralTexture;
  19334. /**
  19335. * Set a vec3 in the shader from a Color3.
  19336. * @param name Define the name of the uniform as defined in the shader
  19337. * @param value Define the value to give to the uniform
  19338. * @return the texture itself allowing "fluent" like uniform updates
  19339. */
  19340. setColor3(name: string, value: Color3): ProceduralTexture;
  19341. /**
  19342. * Set a vec4 in the shader from a Color4.
  19343. * @param name Define the name of the uniform as defined in the shader
  19344. * @param value Define the value to give to the uniform
  19345. * @return the texture itself allowing "fluent" like uniform updates
  19346. */
  19347. setColor4(name: string, value: Color4): ProceduralTexture;
  19348. /**
  19349. * Set a vec2 in the shader from a Vector2.
  19350. * @param name Define the name of the uniform as defined in the shader
  19351. * @param value Define the value to give to the uniform
  19352. * @return the texture itself allowing "fluent" like uniform updates
  19353. */
  19354. setVector2(name: string, value: Vector2): ProceduralTexture;
  19355. /**
  19356. * Set a vec3 in the shader from a Vector3.
  19357. * @param name Define the name of the uniform as defined in the shader
  19358. * @param value Define the value to give to the uniform
  19359. * @return the texture itself allowing "fluent" like uniform updates
  19360. */
  19361. setVector3(name: string, value: Vector3): ProceduralTexture;
  19362. /**
  19363. * Set a mat4 in the shader from a MAtrix.
  19364. * @param name Define the name of the uniform as defined in the shader
  19365. * @param value Define the value to give to the uniform
  19366. * @return the texture itself allowing "fluent" like uniform updates
  19367. */
  19368. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19369. /**
  19370. * Render the texture to its associated render target.
  19371. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19372. */
  19373. render(useCameraPostProcess?: boolean): void;
  19374. /**
  19375. * Clone the texture.
  19376. * @returns the cloned texture
  19377. */
  19378. clone(): ProceduralTexture;
  19379. /**
  19380. * Dispose the texture and release its asoociated resources.
  19381. */
  19382. dispose(): void;
  19383. }
  19384. }
  19385. declare module "babylonjs/Particles/baseParticleSystem" {
  19386. import { Nullable } from "babylonjs/types";
  19387. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19389. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19390. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19391. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19392. import { Scene } from "babylonjs/scene";
  19393. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19394. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19395. import { Texture } from "babylonjs/Materials/Textures/texture";
  19396. import { Animation } from "babylonjs/Animations/animation";
  19397. /**
  19398. * This represents the base class for particle system in Babylon.
  19399. * 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.
  19400. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19401. * @example https://doc.babylonjs.com/babylon101/particles
  19402. */
  19403. export class BaseParticleSystem {
  19404. /**
  19405. * Source color is added to the destination color without alpha affecting the result
  19406. */
  19407. static BLENDMODE_ONEONE: number;
  19408. /**
  19409. * Blend current color and particle color using particle’s alpha
  19410. */
  19411. static BLENDMODE_STANDARD: number;
  19412. /**
  19413. * Add current color and particle color multiplied by particle’s alpha
  19414. */
  19415. static BLENDMODE_ADD: number;
  19416. /**
  19417. * Multiply current color with particle color
  19418. */
  19419. static BLENDMODE_MULTIPLY: number;
  19420. /**
  19421. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19422. */
  19423. static BLENDMODE_MULTIPLYADD: number;
  19424. /**
  19425. * List of animations used by the particle system.
  19426. */
  19427. animations: Animation[];
  19428. /**
  19429. * The id of the Particle system.
  19430. */
  19431. id: string;
  19432. /**
  19433. * The friendly name of the Particle system.
  19434. */
  19435. name: string;
  19436. /**
  19437. * The rendering group used by the Particle system to chose when to render.
  19438. */
  19439. renderingGroupId: number;
  19440. /**
  19441. * The emitter represents the Mesh or position we are attaching the particle system to.
  19442. */
  19443. emitter: Nullable<AbstractMesh | Vector3>;
  19444. /**
  19445. * The maximum number of particles to emit per frame
  19446. */
  19447. emitRate: number;
  19448. /**
  19449. * If you want to launch only a few particles at once, that can be done, as well.
  19450. */
  19451. manualEmitCount: number;
  19452. /**
  19453. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19454. */
  19455. updateSpeed: number;
  19456. /**
  19457. * The amount of time the particle system is running (depends of the overall update speed).
  19458. */
  19459. targetStopDuration: number;
  19460. /**
  19461. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19462. */
  19463. disposeOnStop: boolean;
  19464. /**
  19465. * Minimum power of emitting particles.
  19466. */
  19467. minEmitPower: number;
  19468. /**
  19469. * Maximum power of emitting particles.
  19470. */
  19471. maxEmitPower: number;
  19472. /**
  19473. * Minimum life time of emitting particles.
  19474. */
  19475. minLifeTime: number;
  19476. /**
  19477. * Maximum life time of emitting particles.
  19478. */
  19479. maxLifeTime: number;
  19480. /**
  19481. * Minimum Size of emitting particles.
  19482. */
  19483. minSize: number;
  19484. /**
  19485. * Maximum Size of emitting particles.
  19486. */
  19487. maxSize: number;
  19488. /**
  19489. * Minimum scale of emitting particles on X axis.
  19490. */
  19491. minScaleX: number;
  19492. /**
  19493. * Maximum scale of emitting particles on X axis.
  19494. */
  19495. maxScaleX: number;
  19496. /**
  19497. * Minimum scale of emitting particles on Y axis.
  19498. */
  19499. minScaleY: number;
  19500. /**
  19501. * Maximum scale of emitting particles on Y axis.
  19502. */
  19503. maxScaleY: number;
  19504. /**
  19505. * Gets or sets the minimal initial rotation in radians.
  19506. */
  19507. minInitialRotation: number;
  19508. /**
  19509. * Gets or sets the maximal initial rotation in radians.
  19510. */
  19511. maxInitialRotation: number;
  19512. /**
  19513. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19514. */
  19515. minAngularSpeed: number;
  19516. /**
  19517. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19518. */
  19519. maxAngularSpeed: number;
  19520. /**
  19521. * The texture used to render each particle. (this can be a spritesheet)
  19522. */
  19523. particleTexture: Nullable<Texture>;
  19524. /**
  19525. * The layer mask we are rendering the particles through.
  19526. */
  19527. layerMask: number;
  19528. /**
  19529. * This can help using your own shader to render the particle system.
  19530. * The according effect will be created
  19531. */
  19532. customShader: any;
  19533. /**
  19534. * By default particle system starts as soon as they are created. This prevents the
  19535. * automatic start to happen and let you decide when to start emitting particles.
  19536. */
  19537. preventAutoStart: boolean;
  19538. private _noiseTexture;
  19539. /**
  19540. * Gets or sets a texture used to add random noise to particle positions
  19541. */
  19542. noiseTexture: Nullable<ProceduralTexture>;
  19543. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19544. noiseStrength: Vector3;
  19545. /**
  19546. * Callback triggered when the particle animation is ending.
  19547. */
  19548. onAnimationEnd: Nullable<() => void>;
  19549. /**
  19550. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19551. */
  19552. blendMode: number;
  19553. /**
  19554. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19555. * to override the particles.
  19556. */
  19557. forceDepthWrite: boolean;
  19558. /** 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 */
  19559. preWarmCycles: number;
  19560. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19561. preWarmStepOffset: number;
  19562. /**
  19563. * 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)
  19564. */
  19565. spriteCellChangeSpeed: number;
  19566. /**
  19567. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19568. */
  19569. startSpriteCellID: number;
  19570. /**
  19571. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19572. */
  19573. endSpriteCellID: number;
  19574. /**
  19575. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19576. */
  19577. spriteCellWidth: number;
  19578. /**
  19579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19580. */
  19581. spriteCellHeight: number;
  19582. /**
  19583. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19584. */
  19585. spriteRandomStartCell: boolean;
  19586. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19587. translationPivot: Vector2;
  19588. /** @hidden */
  19589. protected _isAnimationSheetEnabled: boolean;
  19590. /**
  19591. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19592. */
  19593. beginAnimationOnStart: boolean;
  19594. /**
  19595. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19596. */
  19597. beginAnimationFrom: number;
  19598. /**
  19599. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19600. */
  19601. beginAnimationTo: number;
  19602. /**
  19603. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19604. */
  19605. beginAnimationLoop: boolean;
  19606. /**
  19607. * Gets or sets a world offset applied to all particles
  19608. */
  19609. worldOffset: Vector3;
  19610. /**
  19611. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19612. */
  19613. isAnimationSheetEnabled: boolean;
  19614. /**
  19615. * Get hosting scene
  19616. * @returns the scene
  19617. */
  19618. getScene(): Scene;
  19619. /**
  19620. * You can use gravity if you want to give an orientation to your particles.
  19621. */
  19622. gravity: Vector3;
  19623. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19624. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19625. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19626. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19627. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19628. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19629. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19630. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19631. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19632. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19633. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19634. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19635. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19636. /**
  19637. * Defines the delay in milliseconds before starting the system (0 by default)
  19638. */
  19639. startDelay: number;
  19640. /**
  19641. * Gets the current list of drag gradients.
  19642. * You must use addDragGradient and removeDragGradient to udpate this list
  19643. * @returns the list of drag gradients
  19644. */
  19645. getDragGradients(): Nullable<Array<FactorGradient>>;
  19646. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19647. limitVelocityDamping: number;
  19648. /**
  19649. * Gets the current list of limit velocity gradients.
  19650. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19651. * @returns the list of limit velocity gradients
  19652. */
  19653. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19654. /**
  19655. * Gets the current list of color gradients.
  19656. * You must use addColorGradient and removeColorGradient to udpate this list
  19657. * @returns the list of color gradients
  19658. */
  19659. getColorGradients(): Nullable<Array<ColorGradient>>;
  19660. /**
  19661. * Gets the current list of size gradients.
  19662. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19663. * @returns the list of size gradients
  19664. */
  19665. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19666. /**
  19667. * Gets the current list of color remap gradients.
  19668. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19669. * @returns the list of color remap gradients
  19670. */
  19671. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19672. /**
  19673. * Gets the current list of alpha remap gradients.
  19674. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19675. * @returns the list of alpha remap gradients
  19676. */
  19677. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19678. /**
  19679. * Gets the current list of life time gradients.
  19680. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19681. * @returns the list of life time gradients
  19682. */
  19683. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19684. /**
  19685. * Gets the current list of angular speed gradients.
  19686. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19687. * @returns the list of angular speed gradients
  19688. */
  19689. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19690. /**
  19691. * Gets the current list of velocity gradients.
  19692. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19693. * @returns the list of velocity gradients
  19694. */
  19695. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19696. /**
  19697. * Gets the current list of start size gradients.
  19698. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19699. * @returns the list of start size gradients
  19700. */
  19701. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19702. /**
  19703. * Gets the current list of emit rate gradients.
  19704. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19705. * @returns the list of emit rate gradients
  19706. */
  19707. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19708. /**
  19709. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19710. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19711. */
  19712. direction1: Vector3;
  19713. /**
  19714. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19715. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19716. */
  19717. direction2: Vector3;
  19718. /**
  19719. * 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.
  19720. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19721. */
  19722. minEmitBox: Vector3;
  19723. /**
  19724. * 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.
  19725. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19726. */
  19727. maxEmitBox: Vector3;
  19728. /**
  19729. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19730. */
  19731. color1: Color4;
  19732. /**
  19733. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19734. */
  19735. color2: Color4;
  19736. /**
  19737. * Color the particle will have at the end of its lifetime
  19738. */
  19739. colorDead: Color4;
  19740. /**
  19741. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19742. */
  19743. textureMask: Color4;
  19744. /**
  19745. * The particle emitter type defines the emitter used by the particle system.
  19746. * It can be for example box, sphere, or cone...
  19747. */
  19748. particleEmitterType: IParticleEmitterType;
  19749. /** @hidden */
  19750. _isSubEmitter: boolean;
  19751. /**
  19752. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19753. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19754. */
  19755. billboardMode: number;
  19756. protected _isBillboardBased: boolean;
  19757. /**
  19758. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19759. */
  19760. isBillboardBased: boolean;
  19761. /**
  19762. * The scene the particle system belongs to.
  19763. */
  19764. protected _scene: Scene;
  19765. /**
  19766. * Local cache of defines for image processing.
  19767. */
  19768. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19769. /**
  19770. * Default configuration related to image processing available in the standard Material.
  19771. */
  19772. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19773. /**
  19774. * Gets the image processing configuration used either in this material.
  19775. */
  19776. /**
  19777. * Sets the Default image processing configuration used either in the this material.
  19778. *
  19779. * If sets to null, the scene one is in use.
  19780. */
  19781. imageProcessingConfiguration: ImageProcessingConfiguration;
  19782. /**
  19783. * Attaches a new image processing configuration to the Standard Material.
  19784. * @param configuration
  19785. */
  19786. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19787. /** @hidden */
  19788. protected _reset(): void;
  19789. /** @hidden */
  19790. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19791. /**
  19792. * Instantiates a particle system.
  19793. * 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.
  19794. * @param name The name of the particle system
  19795. */
  19796. constructor(name: string);
  19797. /**
  19798. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19801. * @returns the emitter
  19802. */
  19803. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19804. /**
  19805. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19806. * @param radius The radius of the hemisphere to emit from
  19807. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19808. * @returns the emitter
  19809. */
  19810. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19811. /**
  19812. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19813. * @param radius The radius of the sphere to emit from
  19814. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19815. * @returns the emitter
  19816. */
  19817. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19818. /**
  19819. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19820. * @param radius The radius of the sphere to emit from
  19821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19823. * @returns the emitter
  19824. */
  19825. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19826. /**
  19827. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19828. * @param radius The radius of the emission cylinder
  19829. * @param height The height of the emission cylinder
  19830. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19831. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19832. * @returns the emitter
  19833. */
  19834. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19835. /**
  19836. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19837. * @param radius The radius of the cylinder to emit from
  19838. * @param height The height of the emission cylinder
  19839. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19842. * @returns the emitter
  19843. */
  19844. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19845. /**
  19846. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19847. * @param radius The radius of the cone to emit from
  19848. * @param angle The base angle of the cone
  19849. * @returns the emitter
  19850. */
  19851. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19852. /**
  19853. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19856. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19857. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19858. * @returns the emitter
  19859. */
  19860. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19861. }
  19862. }
  19863. declare module "babylonjs/Particles/subEmitter" {
  19864. import { Scene } from "babylonjs/scene";
  19865. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19866. /**
  19867. * Type of sub emitter
  19868. */
  19869. export enum SubEmitterType {
  19870. /**
  19871. * Attached to the particle over it's lifetime
  19872. */
  19873. ATTACHED = 0,
  19874. /**
  19875. * Created when the particle dies
  19876. */
  19877. END = 1
  19878. }
  19879. /**
  19880. * Sub emitter class used to emit particles from an existing particle
  19881. */
  19882. export class SubEmitter {
  19883. /**
  19884. * the particle system to be used by the sub emitter
  19885. */
  19886. particleSystem: ParticleSystem;
  19887. /**
  19888. * Type of the submitter (Default: END)
  19889. */
  19890. type: SubEmitterType;
  19891. /**
  19892. * 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)
  19893. * Note: This only is supported when using an emitter of type Mesh
  19894. */
  19895. inheritDirection: boolean;
  19896. /**
  19897. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19898. */
  19899. inheritedVelocityAmount: number;
  19900. /**
  19901. * Creates a sub emitter
  19902. * @param particleSystem the particle system to be used by the sub emitter
  19903. */
  19904. constructor(
  19905. /**
  19906. * the particle system to be used by the sub emitter
  19907. */
  19908. particleSystem: ParticleSystem);
  19909. /**
  19910. * Clones the sub emitter
  19911. * @returns the cloned sub emitter
  19912. */
  19913. clone(): SubEmitter;
  19914. /**
  19915. * Serialize current object to a JSON object
  19916. * @returns the serialized object
  19917. */
  19918. serialize(): any;
  19919. /** @hidden */
  19920. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19921. /**
  19922. * Creates a new SubEmitter from a serialized JSON version
  19923. * @param serializationObject defines the JSON object to read from
  19924. * @param scene defines the hosting scene
  19925. * @param rootUrl defines the rootUrl for data loading
  19926. * @returns a new SubEmitter
  19927. */
  19928. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19929. /** Release associated resources */
  19930. dispose(): void;
  19931. }
  19932. }
  19933. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  19934. /** @hidden */
  19935. export var imageProcessingDeclaration: {
  19936. name: string;
  19937. shader: string;
  19938. };
  19939. }
  19940. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  19941. /** @hidden */
  19942. export var imageProcessingFunctions: {
  19943. name: string;
  19944. shader: string;
  19945. };
  19946. }
  19947. declare module "babylonjs/Shaders/particles.fragment" {
  19948. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19949. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19950. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19951. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19952. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19953. /** @hidden */
  19954. export var particlesPixelShader: {
  19955. name: string;
  19956. shader: string;
  19957. };
  19958. }
  19959. declare module "babylonjs/Shaders/particles.vertex" {
  19960. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19961. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19962. /** @hidden */
  19963. export var particlesVertexShader: {
  19964. name: string;
  19965. shader: string;
  19966. };
  19967. }
  19968. declare module "babylonjs/Particles/particleSystem" {
  19969. import { Nullable } from "babylonjs/types";
  19970. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  19971. import { Observable } from "babylonjs/Misc/observable";
  19972. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  19973. import { Effect } from "babylonjs/Materials/effect";
  19974. import { Scene, IDisposable } from "babylonjs/scene";
  19975. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19976. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  19977. import { Particle } from "babylonjs/Particles/particle";
  19978. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  19979. import "babylonjs/Shaders/particles.fragment";
  19980. import "babylonjs/Shaders/particles.vertex";
  19981. /**
  19982. * This represents a particle system in Babylon.
  19983. * 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.
  19984. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19985. * @example https://doc.babylonjs.com/babylon101/particles
  19986. */
  19987. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19988. /**
  19989. * Billboard mode will only apply to Y axis
  19990. */
  19991. static readonly BILLBOARDMODE_Y: number;
  19992. /**
  19993. * Billboard mode will apply to all axes
  19994. */
  19995. static readonly BILLBOARDMODE_ALL: number;
  19996. /**
  19997. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19998. */
  19999. static readonly BILLBOARDMODE_STRETCHED: number;
  20000. /**
  20001. * This function can be defined to provide custom update for active particles.
  20002. * This function will be called instead of regular update (age, position, color, etc.).
  20003. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20004. */
  20005. updateFunction: (particles: Particle[]) => void;
  20006. private _emitterWorldMatrix;
  20007. /**
  20008. * This function can be defined to specify initial direction for every new particle.
  20009. * It by default use the emitterType defined function
  20010. */
  20011. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20012. /**
  20013. * This function can be defined to specify initial position for every new particle.
  20014. * It by default use the emitterType defined function
  20015. */
  20016. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20017. /**
  20018. * @hidden
  20019. */
  20020. _inheritedVelocityOffset: Vector3;
  20021. /**
  20022. * An event triggered when the system is disposed
  20023. */
  20024. onDisposeObservable: Observable<ParticleSystem>;
  20025. private _onDisposeObserver;
  20026. /**
  20027. * Sets a callback that will be triggered when the system is disposed
  20028. */
  20029. onDispose: () => void;
  20030. private _particles;
  20031. private _epsilon;
  20032. private _capacity;
  20033. private _stockParticles;
  20034. private _newPartsExcess;
  20035. private _vertexData;
  20036. private _vertexBuffer;
  20037. private _vertexBuffers;
  20038. private _spriteBuffer;
  20039. private _indexBuffer;
  20040. private _effect;
  20041. private _customEffect;
  20042. private _cachedDefines;
  20043. private _scaledColorStep;
  20044. private _colorDiff;
  20045. private _scaledDirection;
  20046. private _scaledGravity;
  20047. private _currentRenderId;
  20048. private _alive;
  20049. private _useInstancing;
  20050. private _started;
  20051. private _stopped;
  20052. private _actualFrame;
  20053. private _scaledUpdateSpeed;
  20054. private _vertexBufferSize;
  20055. /** @hidden */
  20056. _currentEmitRateGradient: Nullable<FactorGradient>;
  20057. /** @hidden */
  20058. _currentEmitRate1: number;
  20059. /** @hidden */
  20060. _currentEmitRate2: number;
  20061. /** @hidden */
  20062. _currentStartSizeGradient: Nullable<FactorGradient>;
  20063. /** @hidden */
  20064. _currentStartSize1: number;
  20065. /** @hidden */
  20066. _currentStartSize2: number;
  20067. private readonly _rawTextureWidth;
  20068. private _rampGradientsTexture;
  20069. private _useRampGradients;
  20070. /** Gets or sets a boolean indicating that ramp gradients must be used
  20071. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20072. */
  20073. useRampGradients: boolean;
  20074. /**
  20075. * 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.
  20076. * 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: [])
  20077. */
  20078. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20079. private _subEmitters;
  20080. /**
  20081. * @hidden
  20082. * If the particle systems emitter should be disposed when the particle system is disposed
  20083. */
  20084. _disposeEmitterOnDispose: boolean;
  20085. /**
  20086. * The current active Sub-systems, this property is used by the root particle system only.
  20087. */
  20088. activeSubSystems: Array<ParticleSystem>;
  20089. private _rootParticleSystem;
  20090. /**
  20091. * Gets the current list of active particles
  20092. */
  20093. readonly particles: Particle[];
  20094. /**
  20095. * Returns the string "ParticleSystem"
  20096. * @returns a string containing the class name
  20097. */
  20098. getClassName(): string;
  20099. /**
  20100. * Instantiates a particle system.
  20101. * 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.
  20102. * @param name The name of the particle system
  20103. * @param capacity The max number of particles alive at the same time
  20104. * @param scene The scene the particle system belongs to
  20105. * @param customEffect a custom effect used to change the way particles are rendered by default
  20106. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20107. * @param epsilon Offset used to render the particles
  20108. */
  20109. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20110. private _addFactorGradient;
  20111. private _removeFactorGradient;
  20112. /**
  20113. * Adds a new life time gradient
  20114. * @param gradient defines the gradient to use (between 0 and 1)
  20115. * @param factor defines the life time factor to affect to the specified gradient
  20116. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20117. * @returns the current particle system
  20118. */
  20119. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20120. /**
  20121. * Remove a specific life time gradient
  20122. * @param gradient defines the gradient to remove
  20123. * @returns the current particle system
  20124. */
  20125. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20126. /**
  20127. * Adds a new size gradient
  20128. * @param gradient defines the gradient to use (between 0 and 1)
  20129. * @param factor defines the size factor to affect to the specified gradient
  20130. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20131. * @returns the current particle system
  20132. */
  20133. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20134. /**
  20135. * Remove a specific size gradient
  20136. * @param gradient defines the gradient to remove
  20137. * @returns the current particle system
  20138. */
  20139. removeSizeGradient(gradient: number): IParticleSystem;
  20140. /**
  20141. * Adds a new color remap gradient
  20142. * @param gradient defines the gradient to use (between 0 and 1)
  20143. * @param min defines the color remap minimal range
  20144. * @param max defines the color remap maximal range
  20145. * @returns the current particle system
  20146. */
  20147. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20148. /**
  20149. * Remove a specific color remap gradient
  20150. * @param gradient defines the gradient to remove
  20151. * @returns the current particle system
  20152. */
  20153. removeColorRemapGradient(gradient: number): IParticleSystem;
  20154. /**
  20155. * Adds a new alpha remap gradient
  20156. * @param gradient defines the gradient to use (between 0 and 1)
  20157. * @param min defines the alpha remap minimal range
  20158. * @param max defines the alpha remap maximal range
  20159. * @returns the current particle system
  20160. */
  20161. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20162. /**
  20163. * Remove a specific alpha remap gradient
  20164. * @param gradient defines the gradient to remove
  20165. * @returns the current particle system
  20166. */
  20167. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20168. /**
  20169. * Adds a new angular speed gradient
  20170. * @param gradient defines the gradient to use (between 0 and 1)
  20171. * @param factor defines the angular speed to affect to the specified gradient
  20172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20173. * @returns the current particle system
  20174. */
  20175. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20176. /**
  20177. * Remove a specific angular speed gradient
  20178. * @param gradient defines the gradient to remove
  20179. * @returns the current particle system
  20180. */
  20181. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20182. /**
  20183. * Adds a new velocity gradient
  20184. * @param gradient defines the gradient to use (between 0 and 1)
  20185. * @param factor defines the velocity to affect to the specified gradient
  20186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20187. * @returns the current particle system
  20188. */
  20189. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20190. /**
  20191. * Remove a specific velocity gradient
  20192. * @param gradient defines the gradient to remove
  20193. * @returns the current particle system
  20194. */
  20195. removeVelocityGradient(gradient: number): IParticleSystem;
  20196. /**
  20197. * Adds a new limit velocity gradient
  20198. * @param gradient defines the gradient to use (between 0 and 1)
  20199. * @param factor defines the limit velocity value to affect to the specified gradient
  20200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20201. * @returns the current particle system
  20202. */
  20203. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20204. /**
  20205. * Remove a specific limit velocity gradient
  20206. * @param gradient defines the gradient to remove
  20207. * @returns the current particle system
  20208. */
  20209. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20210. /**
  20211. * Adds a new drag gradient
  20212. * @param gradient defines the gradient to use (between 0 and 1)
  20213. * @param factor defines the drag value to affect to the specified gradient
  20214. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20215. * @returns the current particle system
  20216. */
  20217. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20218. /**
  20219. * Remove a specific drag gradient
  20220. * @param gradient defines the gradient to remove
  20221. * @returns the current particle system
  20222. */
  20223. removeDragGradient(gradient: number): IParticleSystem;
  20224. /**
  20225. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20226. * @param gradient defines the gradient to use (between 0 and 1)
  20227. * @param factor defines the emit rate value to affect to the specified gradient
  20228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20229. * @returns the current particle system
  20230. */
  20231. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20232. /**
  20233. * Remove a specific emit rate gradient
  20234. * @param gradient defines the gradient to remove
  20235. * @returns the current particle system
  20236. */
  20237. removeEmitRateGradient(gradient: number): IParticleSystem;
  20238. /**
  20239. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20240. * @param gradient defines the gradient to use (between 0 and 1)
  20241. * @param factor defines the start size value to affect to the specified gradient
  20242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20243. * @returns the current particle system
  20244. */
  20245. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20246. /**
  20247. * Remove a specific start size gradient
  20248. * @param gradient defines the gradient to remove
  20249. * @returns the current particle system
  20250. */
  20251. removeStartSizeGradient(gradient: number): IParticleSystem;
  20252. private _createRampGradientTexture;
  20253. /**
  20254. * Gets the current list of ramp gradients.
  20255. * You must use addRampGradient and removeRampGradient to udpate this list
  20256. * @returns the list of ramp gradients
  20257. */
  20258. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20259. /**
  20260. * Adds a new ramp gradient used to remap particle colors
  20261. * @param gradient defines the gradient to use (between 0 and 1)
  20262. * @param color defines the color to affect to the specified gradient
  20263. * @returns the current particle system
  20264. */
  20265. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20266. /**
  20267. * Remove a specific ramp gradient
  20268. * @param gradient defines the gradient to remove
  20269. * @returns the current particle system
  20270. */
  20271. removeRampGradient(gradient: number): ParticleSystem;
  20272. /**
  20273. * Adds a new color gradient
  20274. * @param gradient defines the gradient to use (between 0 and 1)
  20275. * @param color1 defines the color to affect to the specified gradient
  20276. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20277. * @returns this particle system
  20278. */
  20279. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20280. /**
  20281. * Remove a specific color gradient
  20282. * @param gradient defines the gradient to remove
  20283. * @returns this particle system
  20284. */
  20285. removeColorGradient(gradient: number): IParticleSystem;
  20286. private _fetchR;
  20287. protected _reset(): void;
  20288. private _resetEffect;
  20289. private _createVertexBuffers;
  20290. private _createIndexBuffer;
  20291. /**
  20292. * Gets the maximum number of particles active at the same time.
  20293. * @returns The max number of active particles.
  20294. */
  20295. getCapacity(): number;
  20296. /**
  20297. * Gets whether there are still active particles in the system.
  20298. * @returns True if it is alive, otherwise false.
  20299. */
  20300. isAlive(): boolean;
  20301. /**
  20302. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20303. * @returns True if it has been started, otherwise false.
  20304. */
  20305. isStarted(): boolean;
  20306. private _prepareSubEmitterInternalArray;
  20307. /**
  20308. * Starts the particle system and begins to emit
  20309. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20310. */
  20311. start(delay?: number): void;
  20312. /**
  20313. * Stops the particle system.
  20314. * @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.
  20315. */
  20316. stop(stopSubEmitters?: boolean): void;
  20317. /**
  20318. * Remove all active particles
  20319. */
  20320. reset(): void;
  20321. /**
  20322. * @hidden (for internal use only)
  20323. */
  20324. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20325. /**
  20326. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20327. * Its lifetime will start back at 0.
  20328. */
  20329. recycleParticle: (particle: Particle) => void;
  20330. private _stopSubEmitters;
  20331. private _createParticle;
  20332. private _removeFromRoot;
  20333. private _emitFromParticle;
  20334. private _update;
  20335. /** @hidden */
  20336. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20337. /** @hidden */
  20338. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20339. /** @hidden */
  20340. private _getEffect;
  20341. /**
  20342. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20343. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20344. */
  20345. animate(preWarmOnly?: boolean): void;
  20346. private _appendParticleVertices;
  20347. /**
  20348. * Rebuilds the particle system.
  20349. */
  20350. rebuild(): void;
  20351. /**
  20352. * Is this system ready to be used/rendered
  20353. * @return true if the system is ready
  20354. */
  20355. isReady(): boolean;
  20356. private _render;
  20357. /**
  20358. * Renders the particle system in its current state.
  20359. * @returns the current number of particles
  20360. */
  20361. render(): number;
  20362. /**
  20363. * Disposes the particle system and free the associated resources
  20364. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20365. */
  20366. dispose(disposeTexture?: boolean): void;
  20367. /**
  20368. * Clones the particle system.
  20369. * @param name The name of the cloned object
  20370. * @param newEmitter The new emitter to use
  20371. * @returns the cloned particle system
  20372. */
  20373. clone(name: string, newEmitter: any): ParticleSystem;
  20374. /**
  20375. * Serializes the particle system to a JSON object.
  20376. * @returns the JSON object
  20377. */
  20378. serialize(): any;
  20379. /** @hidden */
  20380. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20381. /** @hidden */
  20382. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20383. /**
  20384. * Parses a JSON object to create a particle system.
  20385. * @param parsedParticleSystem The JSON object to parse
  20386. * @param scene The scene to create the particle system in
  20387. * @param rootUrl The root url to use to load external dependencies like texture
  20388. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20389. * @returns the Parsed particle system
  20390. */
  20391. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20392. }
  20393. }
  20394. declare module "babylonjs/Particles/particle" {
  20395. import { Nullable } from "babylonjs/types";
  20396. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20397. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20398. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20399. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20400. /**
  20401. * A particle represents one of the element emitted by a particle system.
  20402. * This is mainly define by its coordinates, direction, velocity and age.
  20403. */
  20404. export class Particle {
  20405. /**
  20406. * The particle system the particle belongs to.
  20407. */
  20408. particleSystem: ParticleSystem;
  20409. private static _Count;
  20410. /**
  20411. * Unique ID of the particle
  20412. */
  20413. id: number;
  20414. /**
  20415. * The world position of the particle in the scene.
  20416. */
  20417. position: Vector3;
  20418. /**
  20419. * The world direction of the particle in the scene.
  20420. */
  20421. direction: Vector3;
  20422. /**
  20423. * The color of the particle.
  20424. */
  20425. color: Color4;
  20426. /**
  20427. * The color change of the particle per step.
  20428. */
  20429. colorStep: Color4;
  20430. /**
  20431. * Defines how long will the life of the particle be.
  20432. */
  20433. lifeTime: number;
  20434. /**
  20435. * The current age of the particle.
  20436. */
  20437. age: number;
  20438. /**
  20439. * The current size of the particle.
  20440. */
  20441. size: number;
  20442. /**
  20443. * The current scale of the particle.
  20444. */
  20445. scale: Vector2;
  20446. /**
  20447. * The current angle of the particle.
  20448. */
  20449. angle: number;
  20450. /**
  20451. * Defines how fast is the angle changing.
  20452. */
  20453. angularSpeed: number;
  20454. /**
  20455. * Defines the cell index used by the particle to be rendered from a sprite.
  20456. */
  20457. cellIndex: number;
  20458. /**
  20459. * The information required to support color remapping
  20460. */
  20461. remapData: Vector4;
  20462. /** @hidden */
  20463. _randomCellOffset?: number;
  20464. /** @hidden */
  20465. _initialDirection: Nullable<Vector3>;
  20466. /** @hidden */
  20467. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20468. /** @hidden */
  20469. _initialStartSpriteCellID: number;
  20470. /** @hidden */
  20471. _initialEndSpriteCellID: number;
  20472. /** @hidden */
  20473. _currentColorGradient: Nullable<ColorGradient>;
  20474. /** @hidden */
  20475. _currentColor1: Color4;
  20476. /** @hidden */
  20477. _currentColor2: Color4;
  20478. /** @hidden */
  20479. _currentSizeGradient: Nullable<FactorGradient>;
  20480. /** @hidden */
  20481. _currentSize1: number;
  20482. /** @hidden */
  20483. _currentSize2: number;
  20484. /** @hidden */
  20485. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20486. /** @hidden */
  20487. _currentAngularSpeed1: number;
  20488. /** @hidden */
  20489. _currentAngularSpeed2: number;
  20490. /** @hidden */
  20491. _currentVelocityGradient: Nullable<FactorGradient>;
  20492. /** @hidden */
  20493. _currentVelocity1: number;
  20494. /** @hidden */
  20495. _currentVelocity2: number;
  20496. /** @hidden */
  20497. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20498. /** @hidden */
  20499. _currentLimitVelocity1: number;
  20500. /** @hidden */
  20501. _currentLimitVelocity2: number;
  20502. /** @hidden */
  20503. _currentDragGradient: Nullable<FactorGradient>;
  20504. /** @hidden */
  20505. _currentDrag1: number;
  20506. /** @hidden */
  20507. _currentDrag2: number;
  20508. /** @hidden */
  20509. _randomNoiseCoordinates1: Vector3;
  20510. /** @hidden */
  20511. _randomNoiseCoordinates2: Vector3;
  20512. /**
  20513. * Creates a new instance Particle
  20514. * @param particleSystem the particle system the particle belongs to
  20515. */
  20516. constructor(
  20517. /**
  20518. * The particle system the particle belongs to.
  20519. */
  20520. particleSystem: ParticleSystem);
  20521. private updateCellInfoFromSystem;
  20522. /**
  20523. * Defines how the sprite cell index is updated for the particle
  20524. */
  20525. updateCellIndex(): void;
  20526. /** @hidden */
  20527. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20528. /** @hidden */
  20529. _inheritParticleInfoToSubEmitters(): void;
  20530. /** @hidden */
  20531. _reset(): void;
  20532. /**
  20533. * Copy the properties of particle to another one.
  20534. * @param other the particle to copy the information to.
  20535. */
  20536. copyTo(other: Particle): void;
  20537. }
  20538. }
  20539. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20540. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20541. import { Effect } from "babylonjs/Materials/effect";
  20542. import { Particle } from "babylonjs/Particles/particle";
  20543. /**
  20544. * Particle emitter represents a volume emitting particles.
  20545. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20546. */
  20547. export interface IParticleEmitterType {
  20548. /**
  20549. * Called by the particle System when the direction is computed for the created particle.
  20550. * @param worldMatrix is the world matrix of the particle system
  20551. * @param directionToUpdate is the direction vector to update with the result
  20552. * @param particle is the particle we are computed the direction for
  20553. */
  20554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20555. /**
  20556. * Called by the particle System when the position is computed for the created particle.
  20557. * @param worldMatrix is the world matrix of the particle system
  20558. * @param positionToUpdate is the position vector to update with the result
  20559. * @param particle is the particle we are computed the position for
  20560. */
  20561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20562. /**
  20563. * Clones the current emitter and returns a copy of it
  20564. * @returns the new emitter
  20565. */
  20566. clone(): IParticleEmitterType;
  20567. /**
  20568. * Called by the GPUParticleSystem to setup the update shader
  20569. * @param effect defines the update shader
  20570. */
  20571. applyToShader(effect: Effect): void;
  20572. /**
  20573. * Returns a string to use to update the GPU particles update shader
  20574. * @returns the effect defines string
  20575. */
  20576. getEffectDefines(): string;
  20577. /**
  20578. * Returns a string representing the class name
  20579. * @returns a string containing the class name
  20580. */
  20581. getClassName(): string;
  20582. /**
  20583. * Serializes the particle system to a JSON object.
  20584. * @returns the JSON object
  20585. */
  20586. serialize(): any;
  20587. /**
  20588. * Parse properties from a JSON object
  20589. * @param serializationObject defines the JSON object
  20590. */
  20591. parse(serializationObject: any): void;
  20592. }
  20593. }
  20594. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20595. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20596. import { Effect } from "babylonjs/Materials/effect";
  20597. import { Particle } from "babylonjs/Particles/particle";
  20598. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20599. /**
  20600. * Particle emitter emitting particles from the inside of a box.
  20601. * It emits the particles randomly between 2 given directions.
  20602. */
  20603. export class BoxParticleEmitter implements IParticleEmitterType {
  20604. /**
  20605. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20606. */
  20607. direction1: Vector3;
  20608. /**
  20609. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20610. */
  20611. direction2: Vector3;
  20612. /**
  20613. * 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.
  20614. */
  20615. minEmitBox: Vector3;
  20616. /**
  20617. * 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.
  20618. */
  20619. maxEmitBox: Vector3;
  20620. /**
  20621. * Creates a new instance BoxParticleEmitter
  20622. */
  20623. constructor();
  20624. /**
  20625. * Called by the particle System when the direction is computed for the created particle.
  20626. * @param worldMatrix is the world matrix of the particle system
  20627. * @param directionToUpdate is the direction vector to update with the result
  20628. * @param particle is the particle we are computed the direction for
  20629. */
  20630. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20631. /**
  20632. * Called by the particle System when the position is computed for the created particle.
  20633. * @param worldMatrix is the world matrix of the particle system
  20634. * @param positionToUpdate is the position vector to update with the result
  20635. * @param particle is the particle we are computed the position for
  20636. */
  20637. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20638. /**
  20639. * Clones the current emitter and returns a copy of it
  20640. * @returns the new emitter
  20641. */
  20642. clone(): BoxParticleEmitter;
  20643. /**
  20644. * Called by the GPUParticleSystem to setup the update shader
  20645. * @param effect defines the update shader
  20646. */
  20647. applyToShader(effect: Effect): void;
  20648. /**
  20649. * Returns a string to use to update the GPU particles update shader
  20650. * @returns a string containng the defines string
  20651. */
  20652. getEffectDefines(): string;
  20653. /**
  20654. * Returns the string "BoxParticleEmitter"
  20655. * @returns a string containing the class name
  20656. */
  20657. getClassName(): string;
  20658. /**
  20659. * Serializes the particle system to a JSON object.
  20660. * @returns the JSON object
  20661. */
  20662. serialize(): any;
  20663. /**
  20664. * Parse properties from a JSON object
  20665. * @param serializationObject defines the JSON object
  20666. */
  20667. parse(serializationObject: any): void;
  20668. }
  20669. }
  20670. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20671. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20672. import { Effect } from "babylonjs/Materials/effect";
  20673. import { Particle } from "babylonjs/Particles/particle";
  20674. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20675. /**
  20676. * Particle emitter emitting particles from the inside of a cone.
  20677. * It emits the particles alongside the cone volume from the base to the particle.
  20678. * The emission direction might be randomized.
  20679. */
  20680. export class ConeParticleEmitter implements IParticleEmitterType {
  20681. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20682. directionRandomizer: number;
  20683. private _radius;
  20684. private _angle;
  20685. private _height;
  20686. /**
  20687. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20688. */
  20689. radiusRange: number;
  20690. /**
  20691. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20692. */
  20693. heightRange: number;
  20694. /**
  20695. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20696. */
  20697. emitFromSpawnPointOnly: boolean;
  20698. /**
  20699. * Gets or sets the radius of the emission cone
  20700. */
  20701. radius: number;
  20702. /**
  20703. * Gets or sets the angle of the emission cone
  20704. */
  20705. angle: number;
  20706. private _buildHeight;
  20707. /**
  20708. * Creates a new instance ConeParticleEmitter
  20709. * @param radius the radius of the emission cone (1 by default)
  20710. * @param angle the cone base angle (PI by default)
  20711. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20712. */
  20713. constructor(radius?: number, angle?: number,
  20714. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20715. directionRandomizer?: number);
  20716. /**
  20717. * Called by the particle System when the direction is computed for the created particle.
  20718. * @param worldMatrix is the world matrix of the particle system
  20719. * @param directionToUpdate is the direction vector to update with the result
  20720. * @param particle is the particle we are computed the direction for
  20721. */
  20722. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20723. /**
  20724. * Called by the particle System when the position is computed for the created particle.
  20725. * @param worldMatrix is the world matrix of the particle system
  20726. * @param positionToUpdate is the position vector to update with the result
  20727. * @param particle is the particle we are computed the position for
  20728. */
  20729. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20730. /**
  20731. * Clones the current emitter and returns a copy of it
  20732. * @returns the new emitter
  20733. */
  20734. clone(): ConeParticleEmitter;
  20735. /**
  20736. * Called by the GPUParticleSystem to setup the update shader
  20737. * @param effect defines the update shader
  20738. */
  20739. applyToShader(effect: Effect): void;
  20740. /**
  20741. * Returns a string to use to update the GPU particles update shader
  20742. * @returns a string containng the defines string
  20743. */
  20744. getEffectDefines(): string;
  20745. /**
  20746. * Returns the string "ConeParticleEmitter"
  20747. * @returns a string containing the class name
  20748. */
  20749. getClassName(): string;
  20750. /**
  20751. * Serializes the particle system to a JSON object.
  20752. * @returns the JSON object
  20753. */
  20754. serialize(): any;
  20755. /**
  20756. * Parse properties from a JSON object
  20757. * @param serializationObject defines the JSON object
  20758. */
  20759. parse(serializationObject: any): void;
  20760. }
  20761. }
  20762. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20763. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20764. import { Effect } from "babylonjs/Materials/effect";
  20765. import { Particle } from "babylonjs/Particles/particle";
  20766. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20767. /**
  20768. * Particle emitter emitting particles from the inside of a cylinder.
  20769. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20770. */
  20771. export class CylinderParticleEmitter implements IParticleEmitterType {
  20772. /**
  20773. * The radius of the emission cylinder.
  20774. */
  20775. radius: number;
  20776. /**
  20777. * The height of the emission cylinder.
  20778. */
  20779. height: number;
  20780. /**
  20781. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20782. */
  20783. radiusRange: number;
  20784. /**
  20785. * How much to randomize the particle direction [0-1].
  20786. */
  20787. directionRandomizer: number;
  20788. /**
  20789. * Creates a new instance CylinderParticleEmitter
  20790. * @param radius the radius of the emission cylinder (1 by default)
  20791. * @param height the height of the emission cylinder (1 by default)
  20792. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20793. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20794. */
  20795. constructor(
  20796. /**
  20797. * The radius of the emission cylinder.
  20798. */
  20799. radius?: number,
  20800. /**
  20801. * The height of the emission cylinder.
  20802. */
  20803. height?: number,
  20804. /**
  20805. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20806. */
  20807. radiusRange?: number,
  20808. /**
  20809. * How much to randomize the particle direction [0-1].
  20810. */
  20811. directionRandomizer?: number);
  20812. /**
  20813. * Called by the particle System when the direction is computed for the created particle.
  20814. * @param worldMatrix is the world matrix of the particle system
  20815. * @param directionToUpdate is the direction vector to update with the result
  20816. * @param particle is the particle we are computed the direction for
  20817. */
  20818. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20819. /**
  20820. * Called by the particle System when the position is computed for the created particle.
  20821. * @param worldMatrix is the world matrix of the particle system
  20822. * @param positionToUpdate is the position vector to update with the result
  20823. * @param particle is the particle we are computed the position for
  20824. */
  20825. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20826. /**
  20827. * Clones the current emitter and returns a copy of it
  20828. * @returns the new emitter
  20829. */
  20830. clone(): CylinderParticleEmitter;
  20831. /**
  20832. * Called by the GPUParticleSystem to setup the update shader
  20833. * @param effect defines the update shader
  20834. */
  20835. applyToShader(effect: Effect): void;
  20836. /**
  20837. * Returns a string to use to update the GPU particles update shader
  20838. * @returns a string containng the defines string
  20839. */
  20840. getEffectDefines(): string;
  20841. /**
  20842. * Returns the string "CylinderParticleEmitter"
  20843. * @returns a string containing the class name
  20844. */
  20845. getClassName(): string;
  20846. /**
  20847. * Serializes the particle system to a JSON object.
  20848. * @returns the JSON object
  20849. */
  20850. serialize(): any;
  20851. /**
  20852. * Parse properties from a JSON object
  20853. * @param serializationObject defines the JSON object
  20854. */
  20855. parse(serializationObject: any): void;
  20856. }
  20857. /**
  20858. * Particle emitter emitting particles from the inside of a cylinder.
  20859. * It emits the particles randomly between two vectors.
  20860. */
  20861. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20862. /**
  20863. * The min limit of the emission direction.
  20864. */
  20865. direction1: Vector3;
  20866. /**
  20867. * The max limit of the emission direction.
  20868. */
  20869. direction2: Vector3;
  20870. /**
  20871. * Creates a new instance CylinderDirectedParticleEmitter
  20872. * @param radius the radius of the emission cylinder (1 by default)
  20873. * @param height the height of the emission cylinder (1 by default)
  20874. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20875. * @param direction1 the min limit of the emission direction (up vector by default)
  20876. * @param direction2 the max limit of the emission direction (up vector by default)
  20877. */
  20878. constructor(radius?: number, height?: number, radiusRange?: number,
  20879. /**
  20880. * The min limit of the emission direction.
  20881. */
  20882. direction1?: Vector3,
  20883. /**
  20884. * The max limit of the emission direction.
  20885. */
  20886. direction2?: Vector3);
  20887. /**
  20888. * Called by the particle System when the direction is computed for the created particle.
  20889. * @param worldMatrix is the world matrix of the particle system
  20890. * @param directionToUpdate is the direction vector to update with the result
  20891. * @param particle is the particle we are computed the direction for
  20892. */
  20893. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20894. /**
  20895. * Clones the current emitter and returns a copy of it
  20896. * @returns the new emitter
  20897. */
  20898. clone(): CylinderDirectedParticleEmitter;
  20899. /**
  20900. * Called by the GPUParticleSystem to setup the update shader
  20901. * @param effect defines the update shader
  20902. */
  20903. applyToShader(effect: Effect): void;
  20904. /**
  20905. * Returns a string to use to update the GPU particles update shader
  20906. * @returns a string containng the defines string
  20907. */
  20908. getEffectDefines(): string;
  20909. /**
  20910. * Returns the string "CylinderDirectedParticleEmitter"
  20911. * @returns a string containing the class name
  20912. */
  20913. getClassName(): string;
  20914. /**
  20915. * Serializes the particle system to a JSON object.
  20916. * @returns the JSON object
  20917. */
  20918. serialize(): any;
  20919. /**
  20920. * Parse properties from a JSON object
  20921. * @param serializationObject defines the JSON object
  20922. */
  20923. parse(serializationObject: any): void;
  20924. }
  20925. }
  20926. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  20927. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20928. import { Effect } from "babylonjs/Materials/effect";
  20929. import { Particle } from "babylonjs/Particles/particle";
  20930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20931. /**
  20932. * Particle emitter emitting particles from the inside of a hemisphere.
  20933. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20934. */
  20935. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20936. /**
  20937. * The radius of the emission hemisphere.
  20938. */
  20939. radius: number;
  20940. /**
  20941. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20942. */
  20943. radiusRange: number;
  20944. /**
  20945. * How much to randomize the particle direction [0-1].
  20946. */
  20947. directionRandomizer: number;
  20948. /**
  20949. * Creates a new instance HemisphericParticleEmitter
  20950. * @param radius the radius of the emission hemisphere (1 by default)
  20951. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20952. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20953. */
  20954. constructor(
  20955. /**
  20956. * The radius of the emission hemisphere.
  20957. */
  20958. radius?: number,
  20959. /**
  20960. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20961. */
  20962. radiusRange?: number,
  20963. /**
  20964. * How much to randomize the particle direction [0-1].
  20965. */
  20966. directionRandomizer?: number);
  20967. /**
  20968. * Called by the particle System when the direction is computed for the created particle.
  20969. * @param worldMatrix is the world matrix of the particle system
  20970. * @param directionToUpdate is the direction vector to update with the result
  20971. * @param particle is the particle we are computed the direction for
  20972. */
  20973. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20974. /**
  20975. * Called by the particle System when the position is computed for the created particle.
  20976. * @param worldMatrix is the world matrix of the particle system
  20977. * @param positionToUpdate is the position vector to update with the result
  20978. * @param particle is the particle we are computed the position for
  20979. */
  20980. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20981. /**
  20982. * Clones the current emitter and returns a copy of it
  20983. * @returns the new emitter
  20984. */
  20985. clone(): HemisphericParticleEmitter;
  20986. /**
  20987. * Called by the GPUParticleSystem to setup the update shader
  20988. * @param effect defines the update shader
  20989. */
  20990. applyToShader(effect: Effect): void;
  20991. /**
  20992. * Returns a string to use to update the GPU particles update shader
  20993. * @returns a string containng the defines string
  20994. */
  20995. getEffectDefines(): string;
  20996. /**
  20997. * Returns the string "HemisphericParticleEmitter"
  20998. * @returns a string containing the class name
  20999. */
  21000. getClassName(): string;
  21001. /**
  21002. * Serializes the particle system to a JSON object.
  21003. * @returns the JSON object
  21004. */
  21005. serialize(): any;
  21006. /**
  21007. * Parse properties from a JSON object
  21008. * @param serializationObject defines the JSON object
  21009. */
  21010. parse(serializationObject: any): void;
  21011. }
  21012. }
  21013. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21014. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21015. import { Effect } from "babylonjs/Materials/effect";
  21016. import { Particle } from "babylonjs/Particles/particle";
  21017. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21018. /**
  21019. * Particle emitter emitting particles from a point.
  21020. * It emits the particles randomly between 2 given directions.
  21021. */
  21022. export class PointParticleEmitter implements IParticleEmitterType {
  21023. /**
  21024. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21025. */
  21026. direction1: Vector3;
  21027. /**
  21028. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21029. */
  21030. direction2: Vector3;
  21031. /**
  21032. * Creates a new instance PointParticleEmitter
  21033. */
  21034. constructor();
  21035. /**
  21036. * Called by the particle System when the direction is computed for the created particle.
  21037. * @param worldMatrix is the world matrix of the particle system
  21038. * @param directionToUpdate is the direction vector to update with the result
  21039. * @param particle is the particle we are computed the direction for
  21040. */
  21041. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21042. /**
  21043. * Called by the particle System when the position is computed for the created particle.
  21044. * @param worldMatrix is the world matrix of the particle system
  21045. * @param positionToUpdate is the position vector to update with the result
  21046. * @param particle is the particle we are computed the position for
  21047. */
  21048. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21049. /**
  21050. * Clones the current emitter and returns a copy of it
  21051. * @returns the new emitter
  21052. */
  21053. clone(): PointParticleEmitter;
  21054. /**
  21055. * Called by the GPUParticleSystem to setup the update shader
  21056. * @param effect defines the update shader
  21057. */
  21058. applyToShader(effect: Effect): void;
  21059. /**
  21060. * Returns a string to use to update the GPU particles update shader
  21061. * @returns a string containng the defines string
  21062. */
  21063. getEffectDefines(): string;
  21064. /**
  21065. * Returns the string "PointParticleEmitter"
  21066. * @returns a string containing the class name
  21067. */
  21068. getClassName(): string;
  21069. /**
  21070. * Serializes the particle system to a JSON object.
  21071. * @returns the JSON object
  21072. */
  21073. serialize(): any;
  21074. /**
  21075. * Parse properties from a JSON object
  21076. * @param serializationObject defines the JSON object
  21077. */
  21078. parse(serializationObject: any): void;
  21079. }
  21080. }
  21081. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21082. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21083. import { Effect } from "babylonjs/Materials/effect";
  21084. import { Particle } from "babylonjs/Particles/particle";
  21085. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21086. /**
  21087. * Particle emitter emitting particles from the inside of a sphere.
  21088. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21089. */
  21090. export class SphereParticleEmitter implements IParticleEmitterType {
  21091. /**
  21092. * The radius of the emission sphere.
  21093. */
  21094. radius: number;
  21095. /**
  21096. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21097. */
  21098. radiusRange: number;
  21099. /**
  21100. * How much to randomize the particle direction [0-1].
  21101. */
  21102. directionRandomizer: number;
  21103. /**
  21104. * Creates a new instance SphereParticleEmitter
  21105. * @param radius the radius of the emission sphere (1 by default)
  21106. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21107. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21108. */
  21109. constructor(
  21110. /**
  21111. * The radius of the emission sphere.
  21112. */
  21113. radius?: number,
  21114. /**
  21115. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21116. */
  21117. radiusRange?: number,
  21118. /**
  21119. * How much to randomize the particle direction [0-1].
  21120. */
  21121. directionRandomizer?: number);
  21122. /**
  21123. * Called by the particle System when the direction is computed for the created particle.
  21124. * @param worldMatrix is the world matrix of the particle system
  21125. * @param directionToUpdate is the direction vector to update with the result
  21126. * @param particle is the particle we are computed the direction for
  21127. */
  21128. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21129. /**
  21130. * Called by the particle System when the position is computed for the created particle.
  21131. * @param worldMatrix is the world matrix of the particle system
  21132. * @param positionToUpdate is the position vector to update with the result
  21133. * @param particle is the particle we are computed the position for
  21134. */
  21135. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21136. /**
  21137. * Clones the current emitter and returns a copy of it
  21138. * @returns the new emitter
  21139. */
  21140. clone(): SphereParticleEmitter;
  21141. /**
  21142. * Called by the GPUParticleSystem to setup the update shader
  21143. * @param effect defines the update shader
  21144. */
  21145. applyToShader(effect: Effect): void;
  21146. /**
  21147. * Returns a string to use to update the GPU particles update shader
  21148. * @returns a string containng the defines string
  21149. */
  21150. getEffectDefines(): string;
  21151. /**
  21152. * Returns the string "SphereParticleEmitter"
  21153. * @returns a string containing the class name
  21154. */
  21155. getClassName(): string;
  21156. /**
  21157. * Serializes the particle system to a JSON object.
  21158. * @returns the JSON object
  21159. */
  21160. serialize(): any;
  21161. /**
  21162. * Parse properties from a JSON object
  21163. * @param serializationObject defines the JSON object
  21164. */
  21165. parse(serializationObject: any): void;
  21166. }
  21167. /**
  21168. * Particle emitter emitting particles from the inside of a sphere.
  21169. * It emits the particles randomly between two vectors.
  21170. */
  21171. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21172. /**
  21173. * The min limit of the emission direction.
  21174. */
  21175. direction1: Vector3;
  21176. /**
  21177. * The max limit of the emission direction.
  21178. */
  21179. direction2: Vector3;
  21180. /**
  21181. * Creates a new instance SphereDirectedParticleEmitter
  21182. * @param radius the radius of the emission sphere (1 by default)
  21183. * @param direction1 the min limit of the emission direction (up vector by default)
  21184. * @param direction2 the max limit of the emission direction (up vector by default)
  21185. */
  21186. constructor(radius?: number,
  21187. /**
  21188. * The min limit of the emission direction.
  21189. */
  21190. direction1?: Vector3,
  21191. /**
  21192. * The max limit of the emission direction.
  21193. */
  21194. direction2?: Vector3);
  21195. /**
  21196. * Called by the particle System when the direction is computed for the created particle.
  21197. * @param worldMatrix is the world matrix of the particle system
  21198. * @param directionToUpdate is the direction vector to update with the result
  21199. * @param particle is the particle we are computed the direction for
  21200. */
  21201. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21202. /**
  21203. * Clones the current emitter and returns a copy of it
  21204. * @returns the new emitter
  21205. */
  21206. clone(): SphereDirectedParticleEmitter;
  21207. /**
  21208. * Called by the GPUParticleSystem to setup the update shader
  21209. * @param effect defines the update shader
  21210. */
  21211. applyToShader(effect: Effect): void;
  21212. /**
  21213. * Returns a string to use to update the GPU particles update shader
  21214. * @returns a string containng the defines string
  21215. */
  21216. getEffectDefines(): string;
  21217. /**
  21218. * Returns the string "SphereDirectedParticleEmitter"
  21219. * @returns a string containing the class name
  21220. */
  21221. getClassName(): string;
  21222. /**
  21223. * Serializes the particle system to a JSON object.
  21224. * @returns the JSON object
  21225. */
  21226. serialize(): any;
  21227. /**
  21228. * Parse properties from a JSON object
  21229. * @param serializationObject defines the JSON object
  21230. */
  21231. parse(serializationObject: any): void;
  21232. }
  21233. }
  21234. declare module "babylonjs/Particles/EmitterTypes/index" {
  21235. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21236. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21237. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21238. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21239. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21240. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21241. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21242. }
  21243. declare module "babylonjs/Particles/IParticleSystem" {
  21244. import { Nullable } from "babylonjs/types";
  21245. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21248. import { Texture } from "babylonjs/Materials/Textures/texture";
  21249. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21250. import { Scene } from "babylonjs/scene";
  21251. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21252. import { Animation } from "babylonjs/Animations/animation";
  21253. /**
  21254. * Interface representing a particle system in Babylon.js.
  21255. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21256. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21257. */
  21258. export interface IParticleSystem {
  21259. /**
  21260. * List of animations used by the particle system.
  21261. */
  21262. animations: Animation[];
  21263. /**
  21264. * The id of the Particle system.
  21265. */
  21266. id: string;
  21267. /**
  21268. * The name of the Particle system.
  21269. */
  21270. name: string;
  21271. /**
  21272. * The emitter represents the Mesh or position we are attaching the particle system to.
  21273. */
  21274. emitter: Nullable<AbstractMesh | Vector3>;
  21275. /**
  21276. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21277. */
  21278. isBillboardBased: boolean;
  21279. /**
  21280. * The rendering group used by the Particle system to chose when to render.
  21281. */
  21282. renderingGroupId: number;
  21283. /**
  21284. * The layer mask we are rendering the particles through.
  21285. */
  21286. layerMask: number;
  21287. /**
  21288. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21289. */
  21290. updateSpeed: number;
  21291. /**
  21292. * The amount of time the particle system is running (depends of the overall update speed).
  21293. */
  21294. targetStopDuration: number;
  21295. /**
  21296. * The texture used to render each particle. (this can be a spritesheet)
  21297. */
  21298. particleTexture: Nullable<Texture>;
  21299. /**
  21300. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21301. */
  21302. blendMode: number;
  21303. /**
  21304. * Minimum life time of emitting particles.
  21305. */
  21306. minLifeTime: number;
  21307. /**
  21308. * Maximum life time of emitting particles.
  21309. */
  21310. maxLifeTime: number;
  21311. /**
  21312. * Minimum Size of emitting particles.
  21313. */
  21314. minSize: number;
  21315. /**
  21316. * Maximum Size of emitting particles.
  21317. */
  21318. maxSize: number;
  21319. /**
  21320. * Minimum scale of emitting particles on X axis.
  21321. */
  21322. minScaleX: number;
  21323. /**
  21324. * Maximum scale of emitting particles on X axis.
  21325. */
  21326. maxScaleX: number;
  21327. /**
  21328. * Minimum scale of emitting particles on Y axis.
  21329. */
  21330. minScaleY: number;
  21331. /**
  21332. * Maximum scale of emitting particles on Y axis.
  21333. */
  21334. maxScaleY: number;
  21335. /**
  21336. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21337. */
  21338. color1: Color4;
  21339. /**
  21340. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21341. */
  21342. color2: Color4;
  21343. /**
  21344. * Color the particle will have at the end of its lifetime.
  21345. */
  21346. colorDead: Color4;
  21347. /**
  21348. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21349. */
  21350. emitRate: number;
  21351. /**
  21352. * You can use gravity if you want to give an orientation to your particles.
  21353. */
  21354. gravity: Vector3;
  21355. /**
  21356. * Minimum power of emitting particles.
  21357. */
  21358. minEmitPower: number;
  21359. /**
  21360. * Maximum power of emitting particles.
  21361. */
  21362. maxEmitPower: number;
  21363. /**
  21364. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21365. */
  21366. minAngularSpeed: number;
  21367. /**
  21368. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21369. */
  21370. maxAngularSpeed: number;
  21371. /**
  21372. * Gets or sets the minimal initial rotation in radians.
  21373. */
  21374. minInitialRotation: number;
  21375. /**
  21376. * Gets or sets the maximal initial rotation in radians.
  21377. */
  21378. maxInitialRotation: number;
  21379. /**
  21380. * The particle emitter type defines the emitter used by the particle system.
  21381. * It can be for example box, sphere, or cone...
  21382. */
  21383. particleEmitterType: Nullable<IParticleEmitterType>;
  21384. /**
  21385. * Defines the delay in milliseconds before starting the system (0 by default)
  21386. */
  21387. startDelay: number;
  21388. /**
  21389. * 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
  21390. */
  21391. preWarmCycles: number;
  21392. /**
  21393. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21394. */
  21395. preWarmStepOffset: number;
  21396. /**
  21397. * 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)
  21398. */
  21399. spriteCellChangeSpeed: number;
  21400. /**
  21401. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21402. */
  21403. startSpriteCellID: number;
  21404. /**
  21405. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21406. */
  21407. endSpriteCellID: number;
  21408. /**
  21409. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21410. */
  21411. spriteCellWidth: number;
  21412. /**
  21413. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21414. */
  21415. spriteCellHeight: number;
  21416. /**
  21417. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21418. */
  21419. spriteRandomStartCell: boolean;
  21420. /**
  21421. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21422. */
  21423. isAnimationSheetEnabled: boolean;
  21424. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21425. translationPivot: Vector2;
  21426. /**
  21427. * Gets or sets a texture used to add random noise to particle positions
  21428. */
  21429. noiseTexture: Nullable<BaseTexture>;
  21430. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21431. noiseStrength: Vector3;
  21432. /**
  21433. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21434. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21435. */
  21436. billboardMode: number;
  21437. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21438. limitVelocityDamping: number;
  21439. /**
  21440. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21441. */
  21442. beginAnimationOnStart: boolean;
  21443. /**
  21444. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21445. */
  21446. beginAnimationFrom: number;
  21447. /**
  21448. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21449. */
  21450. beginAnimationTo: number;
  21451. /**
  21452. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21453. */
  21454. beginAnimationLoop: boolean;
  21455. /**
  21456. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21457. */
  21458. disposeOnStop: boolean;
  21459. /**
  21460. * Gets the maximum number of particles active at the same time.
  21461. * @returns The max number of active particles.
  21462. */
  21463. getCapacity(): number;
  21464. /**
  21465. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21466. * @returns True if it has been started, otherwise false.
  21467. */
  21468. isStarted(): boolean;
  21469. /**
  21470. * Animates the particle system for this frame.
  21471. */
  21472. animate(): void;
  21473. /**
  21474. * Renders the particle system in its current state.
  21475. * @returns the current number of particles
  21476. */
  21477. render(): number;
  21478. /**
  21479. * Dispose the particle system and frees its associated resources.
  21480. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21481. */
  21482. dispose(disposeTexture?: boolean): void;
  21483. /**
  21484. * Clones the particle system.
  21485. * @param name The name of the cloned object
  21486. * @param newEmitter The new emitter to use
  21487. * @returns the cloned particle system
  21488. */
  21489. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21490. /**
  21491. * Serializes the particle system to a JSON object.
  21492. * @returns the JSON object
  21493. */
  21494. serialize(): any;
  21495. /**
  21496. * Rebuild the particle system
  21497. */
  21498. rebuild(): void;
  21499. /**
  21500. * Starts the particle system and begins to emit
  21501. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21502. */
  21503. start(delay?: number): void;
  21504. /**
  21505. * Stops the particle system.
  21506. */
  21507. stop(): void;
  21508. /**
  21509. * Remove all active particles
  21510. */
  21511. reset(): void;
  21512. /**
  21513. * Is this system ready to be used/rendered
  21514. * @return true if the system is ready
  21515. */
  21516. isReady(): boolean;
  21517. /**
  21518. * Adds a new color gradient
  21519. * @param gradient defines the gradient to use (between 0 and 1)
  21520. * @param color1 defines the color to affect to the specified gradient
  21521. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21522. * @returns the current particle system
  21523. */
  21524. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21525. /**
  21526. * Remove a specific color gradient
  21527. * @param gradient defines the gradient to remove
  21528. * @returns the current particle system
  21529. */
  21530. removeColorGradient(gradient: number): IParticleSystem;
  21531. /**
  21532. * Adds a new size gradient
  21533. * @param gradient defines the gradient to use (between 0 and 1)
  21534. * @param factor defines the size factor to affect to the specified gradient
  21535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21536. * @returns the current particle system
  21537. */
  21538. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21539. /**
  21540. * Remove a specific size gradient
  21541. * @param gradient defines the gradient to remove
  21542. * @returns the current particle system
  21543. */
  21544. removeSizeGradient(gradient: number): IParticleSystem;
  21545. /**
  21546. * Gets the current list of color gradients.
  21547. * You must use addColorGradient and removeColorGradient to udpate this list
  21548. * @returns the list of color gradients
  21549. */
  21550. getColorGradients(): Nullable<Array<ColorGradient>>;
  21551. /**
  21552. * Gets the current list of size gradients.
  21553. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21554. * @returns the list of size gradients
  21555. */
  21556. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21557. /**
  21558. * Gets the current list of angular speed gradients.
  21559. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21560. * @returns the list of angular speed gradients
  21561. */
  21562. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21563. /**
  21564. * Adds a new angular speed gradient
  21565. * @param gradient defines the gradient to use (between 0 and 1)
  21566. * @param factor defines the angular speed to affect to the specified gradient
  21567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21568. * @returns the current particle system
  21569. */
  21570. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21571. /**
  21572. * Remove a specific angular speed gradient
  21573. * @param gradient defines the gradient to remove
  21574. * @returns the current particle system
  21575. */
  21576. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21577. /**
  21578. * Gets the current list of velocity gradients.
  21579. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21580. * @returns the list of velocity gradients
  21581. */
  21582. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21583. /**
  21584. * Adds a new velocity gradient
  21585. * @param gradient defines the gradient to use (between 0 and 1)
  21586. * @param factor defines the velocity to affect to the specified gradient
  21587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21588. * @returns the current particle system
  21589. */
  21590. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21591. /**
  21592. * Remove a specific velocity gradient
  21593. * @param gradient defines the gradient to remove
  21594. * @returns the current particle system
  21595. */
  21596. removeVelocityGradient(gradient: number): IParticleSystem;
  21597. /**
  21598. * Gets the current list of limit velocity gradients.
  21599. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21600. * @returns the list of limit velocity gradients
  21601. */
  21602. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21603. /**
  21604. * Adds a new limit velocity gradient
  21605. * @param gradient defines the gradient to use (between 0 and 1)
  21606. * @param factor defines the limit velocity to affect to the specified gradient
  21607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21608. * @returns the current particle system
  21609. */
  21610. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21611. /**
  21612. * Remove a specific limit velocity gradient
  21613. * @param gradient defines the gradient to remove
  21614. * @returns the current particle system
  21615. */
  21616. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21617. /**
  21618. * Adds a new drag gradient
  21619. * @param gradient defines the gradient to use (between 0 and 1)
  21620. * @param factor defines the drag to affect to the specified gradient
  21621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21622. * @returns the current particle system
  21623. */
  21624. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21625. /**
  21626. * Remove a specific drag gradient
  21627. * @param gradient defines the gradient to remove
  21628. * @returns the current particle system
  21629. */
  21630. removeDragGradient(gradient: number): IParticleSystem;
  21631. /**
  21632. * Gets the current list of drag gradients.
  21633. * You must use addDragGradient and removeDragGradient to udpate this list
  21634. * @returns the list of drag gradients
  21635. */
  21636. getDragGradients(): Nullable<Array<FactorGradient>>;
  21637. /**
  21638. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21639. * @param gradient defines the gradient to use (between 0 and 1)
  21640. * @param factor defines the emit rate to affect to the specified gradient
  21641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21642. * @returns the current particle system
  21643. */
  21644. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21645. /**
  21646. * Remove a specific emit rate gradient
  21647. * @param gradient defines the gradient to remove
  21648. * @returns the current particle system
  21649. */
  21650. removeEmitRateGradient(gradient: number): IParticleSystem;
  21651. /**
  21652. * Gets the current list of emit rate gradients.
  21653. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21654. * @returns the list of emit rate gradients
  21655. */
  21656. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21657. /**
  21658. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21659. * @param gradient defines the gradient to use (between 0 and 1)
  21660. * @param factor defines the start size to affect to the specified gradient
  21661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21662. * @returns the current particle system
  21663. */
  21664. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21665. /**
  21666. * Remove a specific start size gradient
  21667. * @param gradient defines the gradient to remove
  21668. * @returns the current particle system
  21669. */
  21670. removeStartSizeGradient(gradient: number): IParticleSystem;
  21671. /**
  21672. * Gets the current list of start size gradients.
  21673. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21674. * @returns the list of start size gradients
  21675. */
  21676. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21677. /**
  21678. * Adds a new life time gradient
  21679. * @param gradient defines the gradient to use (between 0 and 1)
  21680. * @param factor defines the life time factor to affect to the specified gradient
  21681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21682. * @returns the current particle system
  21683. */
  21684. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21685. /**
  21686. * Remove a specific life time gradient
  21687. * @param gradient defines the gradient to remove
  21688. * @returns the current particle system
  21689. */
  21690. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21691. /**
  21692. * Gets the current list of life time gradients.
  21693. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21694. * @returns the list of life time gradients
  21695. */
  21696. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21697. /**
  21698. * Gets the current list of color gradients.
  21699. * You must use addColorGradient and removeColorGradient to udpate this list
  21700. * @returns the list of color gradients
  21701. */
  21702. getColorGradients(): Nullable<Array<ColorGradient>>;
  21703. /**
  21704. * Adds a new ramp gradient used to remap particle colors
  21705. * @param gradient defines the gradient to use (between 0 and 1)
  21706. * @param color defines the color to affect to the specified gradient
  21707. * @returns the current particle system
  21708. */
  21709. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21710. /**
  21711. * Gets the current list of ramp gradients.
  21712. * You must use addRampGradient and removeRampGradient to udpate this list
  21713. * @returns the list of ramp gradients
  21714. */
  21715. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21716. /** Gets or sets a boolean indicating that ramp gradients must be used
  21717. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21718. */
  21719. useRampGradients: boolean;
  21720. /**
  21721. * Adds a new color remap gradient
  21722. * @param gradient defines the gradient to use (between 0 and 1)
  21723. * @param min defines the color remap minimal range
  21724. * @param max defines the color remap maximal range
  21725. * @returns the current particle system
  21726. */
  21727. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21728. /**
  21729. * Gets the current list of color remap gradients.
  21730. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21731. * @returns the list of color remap gradients
  21732. */
  21733. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21734. /**
  21735. * Adds a new alpha remap gradient
  21736. * @param gradient defines the gradient to use (between 0 and 1)
  21737. * @param min defines the alpha remap minimal range
  21738. * @param max defines the alpha remap maximal range
  21739. * @returns the current particle system
  21740. */
  21741. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21742. /**
  21743. * Gets the current list of alpha remap gradients.
  21744. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21745. * @returns the list of alpha remap gradients
  21746. */
  21747. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21748. /**
  21749. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21752. * @returns the emitter
  21753. */
  21754. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21755. /**
  21756. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21757. * @param radius The radius of the hemisphere to emit from
  21758. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21759. * @returns the emitter
  21760. */
  21761. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21762. /**
  21763. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21764. * @param radius The radius of the sphere to emit from
  21765. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21766. * @returns the emitter
  21767. */
  21768. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21769. /**
  21770. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21771. * @param radius The radius of the sphere to emit from
  21772. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21773. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21774. * @returns the emitter
  21775. */
  21776. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21777. /**
  21778. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21779. * @param radius The radius of the emission cylinder
  21780. * @param height The height of the emission cylinder
  21781. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21782. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21783. * @returns the emitter
  21784. */
  21785. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21786. /**
  21787. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21788. * @param radius The radius of the cylinder to emit from
  21789. * @param height The height of the emission cylinder
  21790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21791. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21792. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21793. * @returns the emitter
  21794. */
  21795. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21796. /**
  21797. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21798. * @param radius The radius of the cone to emit from
  21799. * @param angle The base angle of the cone
  21800. * @returns the emitter
  21801. */
  21802. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21803. /**
  21804. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21805. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21806. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21807. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21808. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21809. * @returns the emitter
  21810. */
  21811. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21812. /**
  21813. * Get hosting scene
  21814. * @returns the scene
  21815. */
  21816. getScene(): Scene;
  21817. }
  21818. }
  21819. declare module "babylonjs/Shaders/line.fragment" {
  21820. /** @hidden */
  21821. export var linePixelShader: {
  21822. name: string;
  21823. shader: string;
  21824. };
  21825. }
  21826. declare module "babylonjs/Shaders/line.vertex" {
  21827. /** @hidden */
  21828. export var lineVertexShader: {
  21829. name: string;
  21830. shader: string;
  21831. };
  21832. }
  21833. declare module "babylonjs/Rendering/edgesRenderer" {
  21834. import { Nullable } from "babylonjs/types";
  21835. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21837. import { Vector3 } from "babylonjs/Maths/math";
  21838. import { IDisposable } from "babylonjs/scene";
  21839. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21840. import "babylonjs/Shaders/line.fragment";
  21841. import "babylonjs/Shaders/line.vertex";
  21842. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21843. module "babylonjs/Meshes/abstractMesh" {
  21844. interface AbstractMesh {
  21845. /**
  21846. * Gets the edgesRenderer associated with the mesh
  21847. */
  21848. edgesRenderer: Nullable<EdgesRenderer>;
  21849. }
  21850. }
  21851. module "babylonjs/Meshes/linesMesh" {
  21852. interface LinesMesh {
  21853. /**
  21854. * Enables the edge rendering mode on the mesh.
  21855. * This mode makes the mesh edges visible
  21856. * @param epsilon defines the maximal distance between two angles to detect a face
  21857. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21858. * @returns the currentAbstractMesh
  21859. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21860. */
  21861. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21862. }
  21863. }
  21864. module "babylonjs/Meshes/linesMesh" {
  21865. interface InstancedLinesMesh {
  21866. /**
  21867. * Enables the edge rendering mode on the mesh.
  21868. * This mode makes the mesh edges visible
  21869. * @param epsilon defines the maximal distance between two angles to detect a face
  21870. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21871. * @returns the current InstancedLinesMesh
  21872. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21873. */
  21874. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21875. }
  21876. }
  21877. /**
  21878. * Defines the minimum contract an Edges renderer should follow.
  21879. */
  21880. export interface IEdgesRenderer extends IDisposable {
  21881. /**
  21882. * Gets or sets a boolean indicating if the edgesRenderer is active
  21883. */
  21884. isEnabled: boolean;
  21885. /**
  21886. * Renders the edges of the attached mesh,
  21887. */
  21888. render(): void;
  21889. /**
  21890. * Checks wether or not the edges renderer is ready to render.
  21891. * @return true if ready, otherwise false.
  21892. */
  21893. isReady(): boolean;
  21894. }
  21895. /**
  21896. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21897. */
  21898. export class EdgesRenderer implements IEdgesRenderer {
  21899. /**
  21900. * Define the size of the edges with an orthographic camera
  21901. */
  21902. edgesWidthScalerForOrthographic: number;
  21903. /**
  21904. * Define the size of the edges with a perspective camera
  21905. */
  21906. edgesWidthScalerForPerspective: number;
  21907. protected _source: AbstractMesh;
  21908. protected _linesPositions: number[];
  21909. protected _linesNormals: number[];
  21910. protected _linesIndices: number[];
  21911. protected _epsilon: number;
  21912. protected _indicesCount: number;
  21913. protected _lineShader: ShaderMaterial;
  21914. protected _ib: DataBuffer;
  21915. protected _buffers: {
  21916. [key: string]: Nullable<VertexBuffer>;
  21917. };
  21918. protected _checkVerticesInsteadOfIndices: boolean;
  21919. private _meshRebuildObserver;
  21920. private _meshDisposeObserver;
  21921. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21922. isEnabled: boolean;
  21923. /**
  21924. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21925. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21926. * @param source Mesh used to create edges
  21927. * @param epsilon sum of angles in adjacency to check for edge
  21928. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21929. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21930. */
  21931. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21932. protected _prepareRessources(): void;
  21933. /** @hidden */
  21934. _rebuild(): void;
  21935. /**
  21936. * Releases the required resources for the edges renderer
  21937. */
  21938. dispose(): void;
  21939. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21940. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21941. /**
  21942. * Checks if the pair of p0 and p1 is en edge
  21943. * @param faceIndex
  21944. * @param edge
  21945. * @param faceNormals
  21946. * @param p0
  21947. * @param p1
  21948. * @private
  21949. */
  21950. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21951. /**
  21952. * push line into the position, normal and index buffer
  21953. * @protected
  21954. */
  21955. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21956. /**
  21957. * Generates lines edges from adjacencjes
  21958. * @private
  21959. */
  21960. _generateEdgesLines(): void;
  21961. /**
  21962. * Checks wether or not the edges renderer is ready to render.
  21963. * @return true if ready, otherwise false.
  21964. */
  21965. isReady(): boolean;
  21966. /**
  21967. * Renders the edges of the attached mesh,
  21968. */
  21969. render(): void;
  21970. }
  21971. /**
  21972. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21973. */
  21974. export class LineEdgesRenderer extends EdgesRenderer {
  21975. /**
  21976. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21977. * @param source LineMesh used to generate edges
  21978. * @param epsilon not important (specified angle for edge detection)
  21979. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21980. */
  21981. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21982. /**
  21983. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21984. */
  21985. _generateEdgesLines(): void;
  21986. }
  21987. }
  21988. declare module "babylonjs/Rendering/renderingGroup" {
  21989. import { SmartArray } from "babylonjs/Misc/smartArray";
  21990. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21992. import { Nullable } from "babylonjs/types";
  21993. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  21994. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  21995. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  21996. import { Material } from "babylonjs/Materials/material";
  21997. import { Scene } from "babylonjs/scene";
  21998. /**
  21999. * This represents the object necessary to create a rendering group.
  22000. * This is exclusively used and created by the rendering manager.
  22001. * To modify the behavior, you use the available helpers in your scene or meshes.
  22002. * @hidden
  22003. */
  22004. export class RenderingGroup {
  22005. index: number;
  22006. private static _zeroVector;
  22007. private _scene;
  22008. private _opaqueSubMeshes;
  22009. private _transparentSubMeshes;
  22010. private _alphaTestSubMeshes;
  22011. private _depthOnlySubMeshes;
  22012. private _particleSystems;
  22013. private _spriteManagers;
  22014. private _opaqueSortCompareFn;
  22015. private _alphaTestSortCompareFn;
  22016. private _transparentSortCompareFn;
  22017. private _renderOpaque;
  22018. private _renderAlphaTest;
  22019. private _renderTransparent;
  22020. /** @hidden */
  22021. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22022. onBeforeTransparentRendering: () => void;
  22023. /**
  22024. * Set the opaque sort comparison function.
  22025. * If null the sub meshes will be render in the order they were created
  22026. */
  22027. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22028. /**
  22029. * Set the alpha test sort comparison function.
  22030. * If null the sub meshes will be render in the order they were created
  22031. */
  22032. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22033. /**
  22034. * Set the transparent sort comparison function.
  22035. * If null the sub meshes will be render in the order they were created
  22036. */
  22037. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22038. /**
  22039. * Creates a new rendering group.
  22040. * @param index The rendering group index
  22041. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22042. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22043. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22044. */
  22045. 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>);
  22046. /**
  22047. * Render all the sub meshes contained in the group.
  22048. * @param customRenderFunction Used to override the default render behaviour of the group.
  22049. * @returns true if rendered some submeshes.
  22050. */
  22051. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22052. /**
  22053. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22054. * @param subMeshes The submeshes to render
  22055. */
  22056. private renderOpaqueSorted;
  22057. /**
  22058. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22059. * @param subMeshes The submeshes to render
  22060. */
  22061. private renderAlphaTestSorted;
  22062. /**
  22063. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22064. * @param subMeshes The submeshes to render
  22065. */
  22066. private renderTransparentSorted;
  22067. /**
  22068. * Renders the submeshes in a specified order.
  22069. * @param subMeshes The submeshes to sort before render
  22070. * @param sortCompareFn The comparison function use to sort
  22071. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22072. * @param transparent Specifies to activate blending if true
  22073. */
  22074. private static renderSorted;
  22075. /**
  22076. * Renders the submeshes in the order they were dispatched (no sort applied).
  22077. * @param subMeshes The submeshes to render
  22078. */
  22079. private static renderUnsorted;
  22080. /**
  22081. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22082. * are rendered back to front if in the same alpha index.
  22083. *
  22084. * @param a The first submesh
  22085. * @param b The second submesh
  22086. * @returns The result of the comparison
  22087. */
  22088. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22089. /**
  22090. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22091. * are rendered back to front.
  22092. *
  22093. * @param a The first submesh
  22094. * @param b The second submesh
  22095. * @returns The result of the comparison
  22096. */
  22097. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22098. /**
  22099. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22100. * are rendered front to back (prevent overdraw).
  22101. *
  22102. * @param a The first submesh
  22103. * @param b The second submesh
  22104. * @returns The result of the comparison
  22105. */
  22106. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22107. /**
  22108. * Resets the different lists of submeshes to prepare a new frame.
  22109. */
  22110. prepare(): void;
  22111. dispose(): void;
  22112. /**
  22113. * Inserts the submesh in its correct queue depending on its material.
  22114. * @param subMesh The submesh to dispatch
  22115. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22116. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22117. */
  22118. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22119. dispatchSprites(spriteManager: ISpriteManager): void;
  22120. dispatchParticles(particleSystem: IParticleSystem): void;
  22121. private _renderParticles;
  22122. private _renderSprites;
  22123. }
  22124. }
  22125. declare module "babylonjs/Rendering/renderingManager" {
  22126. import { Nullable } from "babylonjs/types";
  22127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22128. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22129. import { SmartArray } from "babylonjs/Misc/smartArray";
  22130. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22131. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22132. import { Material } from "babylonjs/Materials/material";
  22133. import { Scene } from "babylonjs/scene";
  22134. import { Camera } from "babylonjs/Cameras/camera";
  22135. /**
  22136. * Interface describing the different options available in the rendering manager
  22137. * regarding Auto Clear between groups.
  22138. */
  22139. export interface IRenderingManagerAutoClearSetup {
  22140. /**
  22141. * Defines whether or not autoclear is enable.
  22142. */
  22143. autoClear: boolean;
  22144. /**
  22145. * Defines whether or not to autoclear the depth buffer.
  22146. */
  22147. depth: boolean;
  22148. /**
  22149. * Defines whether or not to autoclear the stencil buffer.
  22150. */
  22151. stencil: boolean;
  22152. }
  22153. /**
  22154. * This class is used by the onRenderingGroupObservable
  22155. */
  22156. export class RenderingGroupInfo {
  22157. /**
  22158. * The Scene that being rendered
  22159. */
  22160. scene: Scene;
  22161. /**
  22162. * The camera currently used for the rendering pass
  22163. */
  22164. camera: Nullable<Camera>;
  22165. /**
  22166. * The ID of the renderingGroup being processed
  22167. */
  22168. renderingGroupId: number;
  22169. }
  22170. /**
  22171. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22172. * It is enable to manage the different groups as well as the different necessary sort functions.
  22173. * This should not be used directly aside of the few static configurations
  22174. */
  22175. export class RenderingManager {
  22176. /**
  22177. * The max id used for rendering groups (not included)
  22178. */
  22179. static MAX_RENDERINGGROUPS: number;
  22180. /**
  22181. * The min id used for rendering groups (included)
  22182. */
  22183. static MIN_RENDERINGGROUPS: number;
  22184. /**
  22185. * Used to globally prevent autoclearing scenes.
  22186. */
  22187. static AUTOCLEAR: boolean;
  22188. /**
  22189. * @hidden
  22190. */
  22191. _useSceneAutoClearSetup: boolean;
  22192. private _scene;
  22193. private _renderingGroups;
  22194. private _depthStencilBufferAlreadyCleaned;
  22195. private _autoClearDepthStencil;
  22196. private _customOpaqueSortCompareFn;
  22197. private _customAlphaTestSortCompareFn;
  22198. private _customTransparentSortCompareFn;
  22199. private _renderingGroupInfo;
  22200. /**
  22201. * Instantiates a new rendering group for a particular scene
  22202. * @param scene Defines the scene the groups belongs to
  22203. */
  22204. constructor(scene: Scene);
  22205. private _clearDepthStencilBuffer;
  22206. /**
  22207. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22208. * @hidden
  22209. */
  22210. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22211. /**
  22212. * Resets the different information of the group to prepare a new frame
  22213. * @hidden
  22214. */
  22215. reset(): void;
  22216. /**
  22217. * Dispose and release the group and its associated resources.
  22218. * @hidden
  22219. */
  22220. dispose(): void;
  22221. /**
  22222. * Clear the info related to rendering groups preventing retention points during dispose.
  22223. */
  22224. freeRenderingGroups(): void;
  22225. private _prepareRenderingGroup;
  22226. /**
  22227. * Add a sprite manager to the rendering manager in order to render it this frame.
  22228. * @param spriteManager Define the sprite manager to render
  22229. */
  22230. dispatchSprites(spriteManager: ISpriteManager): void;
  22231. /**
  22232. * Add a particle system to the rendering manager in order to render it this frame.
  22233. * @param particleSystem Define the particle system to render
  22234. */
  22235. dispatchParticles(particleSystem: IParticleSystem): void;
  22236. /**
  22237. * Add a submesh to the manager in order to render it this frame
  22238. * @param subMesh The submesh to dispatch
  22239. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22240. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22241. */
  22242. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22243. /**
  22244. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22245. * This allowed control for front to back rendering or reversly depending of the special needs.
  22246. *
  22247. * @param renderingGroupId The rendering group id corresponding to its index
  22248. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22249. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22250. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22251. */
  22252. 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;
  22253. /**
  22254. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22255. *
  22256. * @param renderingGroupId The rendering group id corresponding to its index
  22257. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22258. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22259. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22260. */
  22261. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22262. /**
  22263. * Gets the current auto clear configuration for one rendering group of the rendering
  22264. * manager.
  22265. * @param index the rendering group index to get the information for
  22266. * @returns The auto clear setup for the requested rendering group
  22267. */
  22268. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22269. }
  22270. }
  22271. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22272. import { Observable } from "babylonjs/Misc/observable";
  22273. import { SmartArray } from "babylonjs/Misc/smartArray";
  22274. import { Nullable } from "babylonjs/types";
  22275. import { Camera } from "babylonjs/Cameras/camera";
  22276. import { Scene } from "babylonjs/scene";
  22277. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22278. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22280. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22281. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22282. import { Texture } from "babylonjs/Materials/Textures/texture";
  22283. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22284. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22285. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22286. import { Engine } from "babylonjs/Engines/engine";
  22287. /**
  22288. * This Helps creating a texture that will be created from a camera in your scene.
  22289. * It is basically a dynamic texture that could be used to create special effects for instance.
  22290. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22291. */
  22292. export class RenderTargetTexture extends Texture {
  22293. isCube: boolean;
  22294. /**
  22295. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22296. */
  22297. static readonly REFRESHRATE_RENDER_ONCE: number;
  22298. /**
  22299. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22300. */
  22301. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22302. /**
  22303. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22304. * the central point of your effect and can save a lot of performances.
  22305. */
  22306. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22307. /**
  22308. * Use this predicate to dynamically define the list of mesh you want to render.
  22309. * If set, the renderList property will be overwritten.
  22310. */
  22311. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22312. private _renderList;
  22313. /**
  22314. * Use this list to define the list of mesh you want to render.
  22315. */
  22316. renderList: Nullable<Array<AbstractMesh>>;
  22317. private _hookArray;
  22318. /**
  22319. * Define if particles should be rendered in your texture.
  22320. */
  22321. renderParticles: boolean;
  22322. /**
  22323. * Define if sprites should be rendered in your texture.
  22324. */
  22325. renderSprites: boolean;
  22326. /**
  22327. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22328. */
  22329. coordinatesMode: number;
  22330. /**
  22331. * Define the camera used to render the texture.
  22332. */
  22333. activeCamera: Nullable<Camera>;
  22334. /**
  22335. * Override the render function of the texture with your own one.
  22336. */
  22337. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22338. /**
  22339. * Define if camera post processes should be use while rendering the texture.
  22340. */
  22341. useCameraPostProcesses: boolean;
  22342. /**
  22343. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22344. */
  22345. ignoreCameraViewport: boolean;
  22346. private _postProcessManager;
  22347. private _postProcesses;
  22348. private _resizeObserver;
  22349. /**
  22350. * An event triggered when the texture is unbind.
  22351. */
  22352. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22353. /**
  22354. * An event triggered when the texture is unbind.
  22355. */
  22356. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22357. private _onAfterUnbindObserver;
  22358. /**
  22359. * Set a after unbind callback in the texture.
  22360. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22361. */
  22362. onAfterUnbind: () => void;
  22363. /**
  22364. * An event triggered before rendering the texture
  22365. */
  22366. onBeforeRenderObservable: Observable<number>;
  22367. private _onBeforeRenderObserver;
  22368. /**
  22369. * Set a before render callback in the texture.
  22370. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22371. */
  22372. onBeforeRender: (faceIndex: number) => void;
  22373. /**
  22374. * An event triggered after rendering the texture
  22375. */
  22376. onAfterRenderObservable: Observable<number>;
  22377. private _onAfterRenderObserver;
  22378. /**
  22379. * Set a after render callback in the texture.
  22380. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22381. */
  22382. onAfterRender: (faceIndex: number) => void;
  22383. /**
  22384. * An event triggered after the texture clear
  22385. */
  22386. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22387. private _onClearObserver;
  22388. /**
  22389. * Set a clear callback in the texture.
  22390. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22391. */
  22392. onClear: (Engine: Engine) => void;
  22393. /**
  22394. * Define the clear color of the Render Target if it should be different from the scene.
  22395. */
  22396. clearColor: Color4;
  22397. protected _size: number | {
  22398. width: number;
  22399. height: number;
  22400. };
  22401. protected _initialSizeParameter: number | {
  22402. width: number;
  22403. height: number;
  22404. } | {
  22405. ratio: number;
  22406. };
  22407. protected _sizeRatio: Nullable<number>;
  22408. /** @hidden */
  22409. _generateMipMaps: boolean;
  22410. protected _renderingManager: RenderingManager;
  22411. /** @hidden */
  22412. _waitingRenderList: string[];
  22413. protected _doNotChangeAspectRatio: boolean;
  22414. protected _currentRefreshId: number;
  22415. protected _refreshRate: number;
  22416. protected _textureMatrix: Matrix;
  22417. protected _samples: number;
  22418. protected _renderTargetOptions: RenderTargetCreationOptions;
  22419. /**
  22420. * Gets render target creation options that were used.
  22421. */
  22422. readonly renderTargetOptions: RenderTargetCreationOptions;
  22423. protected _engine: Engine;
  22424. protected _onRatioRescale(): void;
  22425. /**
  22426. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22427. * It must define where the camera used to render the texture is set
  22428. */
  22429. boundingBoxPosition: Vector3;
  22430. private _boundingBoxSize;
  22431. /**
  22432. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22433. * When defined, the cubemap will switch to local mode
  22434. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22435. * @example https://www.babylonjs-playground.com/#RNASML
  22436. */
  22437. boundingBoxSize: Vector3;
  22438. /**
  22439. * In case the RTT has been created with a depth texture, get the associated
  22440. * depth texture.
  22441. * Otherwise, return null.
  22442. */
  22443. depthStencilTexture: Nullable<InternalTexture>;
  22444. /**
  22445. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22446. * or used a shadow, depth texture...
  22447. * @param name The friendly name of the texture
  22448. * @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)
  22449. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22450. * @param generateMipMaps True if mip maps need to be generated after render.
  22451. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22452. * @param type The type of the buffer in the RTT (int, half float, float...)
  22453. * @param isCube True if a cube texture needs to be created
  22454. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22455. * @param generateDepthBuffer True to generate a depth buffer
  22456. * @param generateStencilBuffer True to generate a stencil buffer
  22457. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22458. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22459. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22460. */
  22461. constructor(name: string, size: number | {
  22462. width: number;
  22463. height: number;
  22464. } | {
  22465. ratio: number;
  22466. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22467. /**
  22468. * Creates a depth stencil texture.
  22469. * This is only available in WebGL 2 or with the depth texture extension available.
  22470. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22471. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22472. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22473. */
  22474. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22475. private _processSizeParameter;
  22476. /**
  22477. * Define the number of samples to use in case of MSAA.
  22478. * It defaults to one meaning no MSAA has been enabled.
  22479. */
  22480. samples: number;
  22481. /**
  22482. * Resets the refresh counter of the texture and start bak from scratch.
  22483. * Could be useful to regenerate the texture if it is setup to render only once.
  22484. */
  22485. resetRefreshCounter(): void;
  22486. /**
  22487. * Define the refresh rate of the texture or the rendering frequency.
  22488. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22489. */
  22490. refreshRate: number;
  22491. /**
  22492. * Adds a post process to the render target rendering passes.
  22493. * @param postProcess define the post process to add
  22494. */
  22495. addPostProcess(postProcess: PostProcess): void;
  22496. /**
  22497. * Clear all the post processes attached to the render target
  22498. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22499. */
  22500. clearPostProcesses(dispose?: boolean): void;
  22501. /**
  22502. * Remove one of the post process from the list of attached post processes to the texture
  22503. * @param postProcess define the post process to remove from the list
  22504. */
  22505. removePostProcess(postProcess: PostProcess): void;
  22506. /** @hidden */
  22507. _shouldRender(): boolean;
  22508. /**
  22509. * Gets the actual render size of the texture.
  22510. * @returns the width of the render size
  22511. */
  22512. getRenderSize(): number;
  22513. /**
  22514. * Gets the actual render width of the texture.
  22515. * @returns the width of the render size
  22516. */
  22517. getRenderWidth(): number;
  22518. /**
  22519. * Gets the actual render height of the texture.
  22520. * @returns the height of the render size
  22521. */
  22522. getRenderHeight(): number;
  22523. /**
  22524. * Get if the texture can be rescaled or not.
  22525. */
  22526. readonly canRescale: boolean;
  22527. /**
  22528. * Resize the texture using a ratio.
  22529. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22530. */
  22531. scale(ratio: number): void;
  22532. /**
  22533. * Get the texture reflection matrix used to rotate/transform the reflection.
  22534. * @returns the reflection matrix
  22535. */
  22536. getReflectionTextureMatrix(): Matrix;
  22537. /**
  22538. * Resize the texture to a new desired size.
  22539. * Be carrefull as it will recreate all the data in the new texture.
  22540. * @param size Define the new size. It can be:
  22541. * - a number for squared texture,
  22542. * - an object containing { width: number, height: number }
  22543. * - or an object containing a ratio { ratio: number }
  22544. */
  22545. resize(size: number | {
  22546. width: number;
  22547. height: number;
  22548. } | {
  22549. ratio: number;
  22550. }): void;
  22551. /**
  22552. * Renders all the objects from the render list into the texture.
  22553. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22554. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22555. */
  22556. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22557. private _bestReflectionRenderTargetDimension;
  22558. /**
  22559. * @hidden
  22560. * @param faceIndex face index to bind to if this is a cubetexture
  22561. */
  22562. _bindFrameBuffer(faceIndex?: number): void;
  22563. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22564. private renderToTarget;
  22565. /**
  22566. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22567. * This allowed control for front to back rendering or reversly depending of the special needs.
  22568. *
  22569. * @param renderingGroupId The rendering group id corresponding to its index
  22570. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22571. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22572. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22573. */
  22574. 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;
  22575. /**
  22576. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22577. *
  22578. * @param renderingGroupId The rendering group id corresponding to its index
  22579. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22580. */
  22581. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22582. /**
  22583. * Clones the texture.
  22584. * @returns the cloned texture
  22585. */
  22586. clone(): RenderTargetTexture;
  22587. /**
  22588. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22589. * @returns The JSON representation of the texture
  22590. */
  22591. serialize(): any;
  22592. /**
  22593. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22594. */
  22595. disposeFramebufferObjects(): void;
  22596. /**
  22597. * Dispose the texture and release its associated resources.
  22598. */
  22599. dispose(): void;
  22600. /** @hidden */
  22601. _rebuild(): void;
  22602. /**
  22603. * Clear the info related to rendering groups preventing retention point in material dispose.
  22604. */
  22605. freeRenderingGroups(): void;
  22606. /**
  22607. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22608. * @returns the view count
  22609. */
  22610. getViewCount(): number;
  22611. }
  22612. }
  22613. declare module "babylonjs/Materials/material" {
  22614. import { IAnimatable } from "babylonjs/Misc/tools";
  22615. import { SmartArray } from "babylonjs/Misc/smartArray";
  22616. import { Observable } from "babylonjs/Misc/observable";
  22617. import { Nullable } from "babylonjs/types";
  22618. import { Scene } from "babylonjs/scene";
  22619. import { Matrix } from "babylonjs/Maths/math";
  22620. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22622. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22623. import { Effect } from "babylonjs/Materials/effect";
  22624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22625. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22626. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22627. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22628. import { Mesh } from "babylonjs/Meshes/mesh";
  22629. import { Animation } from "babylonjs/Animations/animation";
  22630. /**
  22631. * Base class for the main features of a material in Babylon.js
  22632. */
  22633. export class Material implements IAnimatable {
  22634. /**
  22635. * Returns the triangle fill mode
  22636. */
  22637. static readonly TriangleFillMode: number;
  22638. /**
  22639. * Returns the wireframe mode
  22640. */
  22641. static readonly WireFrameFillMode: number;
  22642. /**
  22643. * Returns the point fill mode
  22644. */
  22645. static readonly PointFillMode: number;
  22646. /**
  22647. * Returns the point list draw mode
  22648. */
  22649. static readonly PointListDrawMode: number;
  22650. /**
  22651. * Returns the line list draw mode
  22652. */
  22653. static readonly LineListDrawMode: number;
  22654. /**
  22655. * Returns the line loop draw mode
  22656. */
  22657. static readonly LineLoopDrawMode: number;
  22658. /**
  22659. * Returns the line strip draw mode
  22660. */
  22661. static readonly LineStripDrawMode: number;
  22662. /**
  22663. * Returns the triangle strip draw mode
  22664. */
  22665. static readonly TriangleStripDrawMode: number;
  22666. /**
  22667. * Returns the triangle fan draw mode
  22668. */
  22669. static readonly TriangleFanDrawMode: number;
  22670. /**
  22671. * Stores the clock-wise side orientation
  22672. */
  22673. static readonly ClockWiseSideOrientation: number;
  22674. /**
  22675. * Stores the counter clock-wise side orientation
  22676. */
  22677. static readonly CounterClockWiseSideOrientation: number;
  22678. /**
  22679. * The dirty texture flag value
  22680. */
  22681. static readonly TextureDirtyFlag: number;
  22682. /**
  22683. * The dirty light flag value
  22684. */
  22685. static readonly LightDirtyFlag: number;
  22686. /**
  22687. * The dirty fresnel flag value
  22688. */
  22689. static readonly FresnelDirtyFlag: number;
  22690. /**
  22691. * The dirty attribute flag value
  22692. */
  22693. static readonly AttributesDirtyFlag: number;
  22694. /**
  22695. * The dirty misc flag value
  22696. */
  22697. static readonly MiscDirtyFlag: number;
  22698. /**
  22699. * The all dirty flag value
  22700. */
  22701. static readonly AllDirtyFlag: number;
  22702. /**
  22703. * The ID of the material
  22704. */
  22705. id: string;
  22706. /**
  22707. * Gets or sets the unique id of the material
  22708. */
  22709. uniqueId: number;
  22710. /**
  22711. * The name of the material
  22712. */
  22713. name: string;
  22714. /**
  22715. * Gets or sets user defined metadata
  22716. */
  22717. metadata: any;
  22718. /**
  22719. * For internal use only. Please do not use.
  22720. */
  22721. reservedDataStore: any;
  22722. /**
  22723. * Specifies if the ready state should be checked on each call
  22724. */
  22725. checkReadyOnEveryCall: boolean;
  22726. /**
  22727. * Specifies if the ready state should be checked once
  22728. */
  22729. checkReadyOnlyOnce: boolean;
  22730. /**
  22731. * The state of the material
  22732. */
  22733. state: string;
  22734. /**
  22735. * The alpha value of the material
  22736. */
  22737. protected _alpha: number;
  22738. /**
  22739. * List of inspectable custom properties (used by the Inspector)
  22740. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22741. */
  22742. inspectableCustomProperties: IInspectable[];
  22743. /**
  22744. * Sets the alpha value of the material
  22745. */
  22746. /**
  22747. * Gets the alpha value of the material
  22748. */
  22749. alpha: number;
  22750. /**
  22751. * Specifies if back face culling is enabled
  22752. */
  22753. protected _backFaceCulling: boolean;
  22754. /**
  22755. * Sets the back-face culling state
  22756. */
  22757. /**
  22758. * Gets the back-face culling state
  22759. */
  22760. backFaceCulling: boolean;
  22761. /**
  22762. * Stores the value for side orientation
  22763. */
  22764. sideOrientation: number;
  22765. /**
  22766. * Callback triggered when the material is compiled
  22767. */
  22768. onCompiled: Nullable<(effect: Effect) => void>;
  22769. /**
  22770. * Callback triggered when an error occurs
  22771. */
  22772. onError: Nullable<(effect: Effect, errors: string) => void>;
  22773. /**
  22774. * Callback triggered to get the render target textures
  22775. */
  22776. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22777. /**
  22778. * Gets a boolean indicating that current material needs to register RTT
  22779. */
  22780. readonly hasRenderTargetTextures: boolean;
  22781. /**
  22782. * Specifies if the material should be serialized
  22783. */
  22784. doNotSerialize: boolean;
  22785. /**
  22786. * @hidden
  22787. */
  22788. _storeEffectOnSubMeshes: boolean;
  22789. /**
  22790. * Stores the animations for the material
  22791. */
  22792. animations: Nullable<Array<Animation>>;
  22793. /**
  22794. * An event triggered when the material is disposed
  22795. */
  22796. onDisposeObservable: Observable<Material>;
  22797. /**
  22798. * An observer which watches for dispose events
  22799. */
  22800. private _onDisposeObserver;
  22801. private _onUnBindObservable;
  22802. /**
  22803. * Called during a dispose event
  22804. */
  22805. onDispose: () => void;
  22806. private _onBindObservable;
  22807. /**
  22808. * An event triggered when the material is bound
  22809. */
  22810. readonly onBindObservable: Observable<AbstractMesh>;
  22811. /**
  22812. * An observer which watches for bind events
  22813. */
  22814. private _onBindObserver;
  22815. /**
  22816. * Called during a bind event
  22817. */
  22818. onBind: (Mesh: AbstractMesh) => void;
  22819. /**
  22820. * An event triggered when the material is unbound
  22821. */
  22822. readonly onUnBindObservable: Observable<Material>;
  22823. /**
  22824. * Stores the value of the alpha mode
  22825. */
  22826. private _alphaMode;
  22827. /**
  22828. * Sets the value of the alpha mode.
  22829. *
  22830. * | Value | Type | Description |
  22831. * | --- | --- | --- |
  22832. * | 0 | ALPHA_DISABLE | |
  22833. * | 1 | ALPHA_ADD | |
  22834. * | 2 | ALPHA_COMBINE | |
  22835. * | 3 | ALPHA_SUBTRACT | |
  22836. * | 4 | ALPHA_MULTIPLY | |
  22837. * | 5 | ALPHA_MAXIMIZED | |
  22838. * | 6 | ALPHA_ONEONE | |
  22839. * | 7 | ALPHA_PREMULTIPLIED | |
  22840. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22841. * | 9 | ALPHA_INTERPOLATE | |
  22842. * | 10 | ALPHA_SCREENMODE | |
  22843. *
  22844. */
  22845. /**
  22846. * Gets the value of the alpha mode
  22847. */
  22848. alphaMode: number;
  22849. /**
  22850. * Stores the state of the need depth pre-pass value
  22851. */
  22852. private _needDepthPrePass;
  22853. /**
  22854. * Sets the need depth pre-pass value
  22855. */
  22856. /**
  22857. * Gets the depth pre-pass value
  22858. */
  22859. needDepthPrePass: boolean;
  22860. /**
  22861. * Specifies if depth writing should be disabled
  22862. */
  22863. disableDepthWrite: boolean;
  22864. /**
  22865. * Specifies if depth writing should be forced
  22866. */
  22867. forceDepthWrite: boolean;
  22868. /**
  22869. * Specifies if there should be a separate pass for culling
  22870. */
  22871. separateCullingPass: boolean;
  22872. /**
  22873. * Stores the state specifing if fog should be enabled
  22874. */
  22875. private _fogEnabled;
  22876. /**
  22877. * Sets the state for enabling fog
  22878. */
  22879. /**
  22880. * Gets the value of the fog enabled state
  22881. */
  22882. fogEnabled: boolean;
  22883. /**
  22884. * Stores the size of points
  22885. */
  22886. pointSize: number;
  22887. /**
  22888. * Stores the z offset value
  22889. */
  22890. zOffset: number;
  22891. /**
  22892. * Gets a value specifying if wireframe mode is enabled
  22893. */
  22894. /**
  22895. * Sets the state of wireframe mode
  22896. */
  22897. wireframe: boolean;
  22898. /**
  22899. * Gets the value specifying if point clouds are enabled
  22900. */
  22901. /**
  22902. * Sets the state of point cloud mode
  22903. */
  22904. pointsCloud: boolean;
  22905. /**
  22906. * Gets the material fill mode
  22907. */
  22908. /**
  22909. * Sets the material fill mode
  22910. */
  22911. fillMode: number;
  22912. /**
  22913. * @hidden
  22914. * Stores the effects for the material
  22915. */
  22916. _effect: Nullable<Effect>;
  22917. /**
  22918. * @hidden
  22919. * Specifies if the material was previously ready
  22920. */
  22921. _wasPreviouslyReady: boolean;
  22922. /**
  22923. * Specifies if uniform buffers should be used
  22924. */
  22925. private _useUBO;
  22926. /**
  22927. * Stores a reference to the scene
  22928. */
  22929. private _scene;
  22930. /**
  22931. * Stores the fill mode state
  22932. */
  22933. private _fillMode;
  22934. /**
  22935. * Specifies if the depth write state should be cached
  22936. */
  22937. private _cachedDepthWriteState;
  22938. /**
  22939. * Stores the uniform buffer
  22940. */
  22941. protected _uniformBuffer: UniformBuffer;
  22942. /** @hidden */
  22943. _indexInSceneMaterialArray: number;
  22944. /** @hidden */
  22945. meshMap: Nullable<{
  22946. [id: string]: AbstractMesh | undefined;
  22947. }>;
  22948. /**
  22949. * Creates a material instance
  22950. * @param name defines the name of the material
  22951. * @param scene defines the scene to reference
  22952. * @param doNotAdd specifies if the material should be added to the scene
  22953. */
  22954. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22955. /**
  22956. * Returns a string representation of the current material
  22957. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22958. * @returns a string with material information
  22959. */
  22960. toString(fullDetails?: boolean): string;
  22961. /**
  22962. * Gets the class name of the material
  22963. * @returns a string with the class name of the material
  22964. */
  22965. getClassName(): string;
  22966. /**
  22967. * Specifies if updates for the material been locked
  22968. */
  22969. readonly isFrozen: boolean;
  22970. /**
  22971. * Locks updates for the material
  22972. */
  22973. freeze(): void;
  22974. /**
  22975. * Unlocks updates for the material
  22976. */
  22977. unfreeze(): void;
  22978. /**
  22979. * Specifies if the material is ready to be used
  22980. * @param mesh defines the mesh to check
  22981. * @param useInstances specifies if instances should be used
  22982. * @returns a boolean indicating if the material is ready to be used
  22983. */
  22984. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22985. /**
  22986. * Specifies that the submesh is ready to be used
  22987. * @param mesh defines the mesh to check
  22988. * @param subMesh defines which submesh to check
  22989. * @param useInstances specifies that instances should be used
  22990. * @returns a boolean indicating that the submesh is ready or not
  22991. */
  22992. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22993. /**
  22994. * Returns the material effect
  22995. * @returns the effect associated with the material
  22996. */
  22997. getEffect(): Nullable<Effect>;
  22998. /**
  22999. * Returns the current scene
  23000. * @returns a Scene
  23001. */
  23002. getScene(): Scene;
  23003. /**
  23004. * Specifies if the material will require alpha blending
  23005. * @returns a boolean specifying if alpha blending is needed
  23006. */
  23007. needAlphaBlending(): boolean;
  23008. /**
  23009. * Specifies if the mesh will require alpha blending
  23010. * @param mesh defines the mesh to check
  23011. * @returns a boolean specifying if alpha blending is needed for the mesh
  23012. */
  23013. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23014. /**
  23015. * Specifies if this material should be rendered in alpha test mode
  23016. * @returns a boolean specifying if an alpha test is needed.
  23017. */
  23018. needAlphaTesting(): boolean;
  23019. /**
  23020. * Gets the texture used for the alpha test
  23021. * @returns the texture to use for alpha testing
  23022. */
  23023. getAlphaTestTexture(): Nullable<BaseTexture>;
  23024. /**
  23025. * Marks the material to indicate that it needs to be re-calculated
  23026. */
  23027. markDirty(): void;
  23028. /** @hidden */
  23029. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23030. /**
  23031. * Binds the material to the mesh
  23032. * @param world defines the world transformation matrix
  23033. * @param mesh defines the mesh to bind the material to
  23034. */
  23035. bind(world: Matrix, mesh?: Mesh): void;
  23036. /**
  23037. * Binds the submesh to the material
  23038. * @param world defines the world transformation matrix
  23039. * @param mesh defines the mesh containing the submesh
  23040. * @param subMesh defines the submesh to bind the material to
  23041. */
  23042. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23043. /**
  23044. * Binds the world matrix to the material
  23045. * @param world defines the world transformation matrix
  23046. */
  23047. bindOnlyWorldMatrix(world: Matrix): void;
  23048. /**
  23049. * Binds the scene's uniform buffer to the effect.
  23050. * @param effect defines the effect to bind to the scene uniform buffer
  23051. * @param sceneUbo defines the uniform buffer storing scene data
  23052. */
  23053. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23054. /**
  23055. * Binds the view matrix to the effect
  23056. * @param effect defines the effect to bind the view matrix to
  23057. */
  23058. bindView(effect: Effect): void;
  23059. /**
  23060. * Binds the view projection matrix to the effect
  23061. * @param effect defines the effect to bind the view projection matrix to
  23062. */
  23063. bindViewProjection(effect: Effect): void;
  23064. /**
  23065. * Specifies if material alpha testing should be turned on for the mesh
  23066. * @param mesh defines the mesh to check
  23067. */
  23068. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23069. /**
  23070. * Processes to execute after binding the material to a mesh
  23071. * @param mesh defines the rendered mesh
  23072. */
  23073. protected _afterBind(mesh?: Mesh): void;
  23074. /**
  23075. * Unbinds the material from the mesh
  23076. */
  23077. unbind(): void;
  23078. /**
  23079. * Gets the active textures from the material
  23080. * @returns an array of textures
  23081. */
  23082. getActiveTextures(): BaseTexture[];
  23083. /**
  23084. * Specifies if the material uses a texture
  23085. * @param texture defines the texture to check against the material
  23086. * @returns a boolean specifying if the material uses the texture
  23087. */
  23088. hasTexture(texture: BaseTexture): boolean;
  23089. /**
  23090. * Makes a duplicate of the material, and gives it a new name
  23091. * @param name defines the new name for the duplicated material
  23092. * @returns the cloned material
  23093. */
  23094. clone(name: string): Nullable<Material>;
  23095. /**
  23096. * Gets the meshes bound to the material
  23097. * @returns an array of meshes bound to the material
  23098. */
  23099. getBindedMeshes(): AbstractMesh[];
  23100. /**
  23101. * Force shader compilation
  23102. * @param mesh defines the mesh associated with this material
  23103. * @param onCompiled defines a function to execute once the material is compiled
  23104. * @param options defines the options to configure the compilation
  23105. */
  23106. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23107. clipPlane: boolean;
  23108. }>): void;
  23109. /**
  23110. * Force shader compilation
  23111. * @param mesh defines the mesh that will use this material
  23112. * @param options defines additional options for compiling the shaders
  23113. * @returns a promise that resolves when the compilation completes
  23114. */
  23115. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23116. clipPlane: boolean;
  23117. }>): Promise<void>;
  23118. private static readonly _AllDirtyCallBack;
  23119. private static readonly _ImageProcessingDirtyCallBack;
  23120. private static readonly _TextureDirtyCallBack;
  23121. private static readonly _FresnelDirtyCallBack;
  23122. private static readonly _MiscDirtyCallBack;
  23123. private static readonly _LightsDirtyCallBack;
  23124. private static readonly _AttributeDirtyCallBack;
  23125. private static _FresnelAndMiscDirtyCallBack;
  23126. private static _TextureAndMiscDirtyCallBack;
  23127. private static readonly _DirtyCallbackArray;
  23128. private static readonly _RunDirtyCallBacks;
  23129. /**
  23130. * Marks a define in the material to indicate that it needs to be re-computed
  23131. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23132. */
  23133. markAsDirty(flag: number): void;
  23134. /**
  23135. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23136. * @param func defines a function which checks material defines against the submeshes
  23137. */
  23138. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23139. /**
  23140. * Indicates that we need to re-calculated for all submeshes
  23141. */
  23142. protected _markAllSubMeshesAsAllDirty(): void;
  23143. /**
  23144. * Indicates that image processing needs to be re-calculated for all submeshes
  23145. */
  23146. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23147. /**
  23148. * Indicates that textures need to be re-calculated for all submeshes
  23149. */
  23150. protected _markAllSubMeshesAsTexturesDirty(): void;
  23151. /**
  23152. * Indicates that fresnel needs to be re-calculated for all submeshes
  23153. */
  23154. protected _markAllSubMeshesAsFresnelDirty(): void;
  23155. /**
  23156. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23157. */
  23158. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23159. /**
  23160. * Indicates that lights need to be re-calculated for all submeshes
  23161. */
  23162. protected _markAllSubMeshesAsLightsDirty(): void;
  23163. /**
  23164. * Indicates that attributes need to be re-calculated for all submeshes
  23165. */
  23166. protected _markAllSubMeshesAsAttributesDirty(): void;
  23167. /**
  23168. * Indicates that misc needs to be re-calculated for all submeshes
  23169. */
  23170. protected _markAllSubMeshesAsMiscDirty(): void;
  23171. /**
  23172. * Indicates that textures and misc need to be re-calculated for all submeshes
  23173. */
  23174. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23175. /**
  23176. * Disposes the material
  23177. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23178. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23179. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23180. */
  23181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23182. /** @hidden */
  23183. private releaseVertexArrayObject;
  23184. /**
  23185. * Serializes this material
  23186. * @returns the serialized material object
  23187. */
  23188. serialize(): any;
  23189. /**
  23190. * Creates a material from parsed material data
  23191. * @param parsedMaterial defines parsed material data
  23192. * @param scene defines the hosting scene
  23193. * @param rootUrl defines the root URL to use to load textures
  23194. * @returns a new material
  23195. */
  23196. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23197. }
  23198. }
  23199. declare module "babylonjs/Meshes/subMesh" {
  23200. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23201. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23202. import { Engine } from "babylonjs/Engines/engine";
  23203. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23204. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23205. import { Effect } from "babylonjs/Materials/effect";
  23206. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23207. import { Collider } from "babylonjs/Collisions/collider";
  23208. import { Material } from "babylonjs/Materials/material";
  23209. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23211. import { Mesh } from "babylonjs/Meshes/mesh";
  23212. import { Ray } from "babylonjs/Culling/ray";
  23213. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23214. /**
  23215. * Base class for submeshes
  23216. */
  23217. export class BaseSubMesh {
  23218. /** @hidden */
  23219. _materialDefines: Nullable<MaterialDefines>;
  23220. /** @hidden */
  23221. _materialEffect: Nullable<Effect>;
  23222. /**
  23223. * Gets associated effect
  23224. */
  23225. readonly effect: Nullable<Effect>;
  23226. /**
  23227. * Sets associated effect (effect used to render this submesh)
  23228. * @param effect defines the effect to associate with
  23229. * @param defines defines the set of defines used to compile this effect
  23230. */
  23231. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23232. }
  23233. /**
  23234. * Defines a subdivision inside a mesh
  23235. */
  23236. export class SubMesh extends BaseSubMesh implements ICullable {
  23237. /** the material index to use */
  23238. materialIndex: number;
  23239. /** vertex index start */
  23240. verticesStart: number;
  23241. /** vertices count */
  23242. verticesCount: number;
  23243. /** index start */
  23244. indexStart: number;
  23245. /** indices count */
  23246. indexCount: number;
  23247. /** @hidden */
  23248. _linesIndexCount: number;
  23249. private _mesh;
  23250. private _renderingMesh;
  23251. private _boundingInfo;
  23252. private _linesIndexBuffer;
  23253. /** @hidden */
  23254. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23255. /** @hidden */
  23256. _trianglePlanes: Plane[];
  23257. /** @hidden */
  23258. _lastColliderTransformMatrix: Nullable<Matrix>;
  23259. /** @hidden */
  23260. _renderId: number;
  23261. /** @hidden */
  23262. _alphaIndex: number;
  23263. /** @hidden */
  23264. _distanceToCamera: number;
  23265. /** @hidden */
  23266. _id: number;
  23267. private _currentMaterial;
  23268. /**
  23269. * Add a new submesh to a mesh
  23270. * @param materialIndex defines the material index to use
  23271. * @param verticesStart defines vertex index start
  23272. * @param verticesCount defines vertices count
  23273. * @param indexStart defines index start
  23274. * @param indexCount defines indices count
  23275. * @param mesh defines the parent mesh
  23276. * @param renderingMesh defines an optional rendering mesh
  23277. * @param createBoundingBox defines if bounding box should be created for this submesh
  23278. * @returns the new submesh
  23279. */
  23280. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23281. /**
  23282. * Creates a new submesh
  23283. * @param materialIndex defines the material index to use
  23284. * @param verticesStart defines vertex index start
  23285. * @param verticesCount defines vertices count
  23286. * @param indexStart defines index start
  23287. * @param indexCount defines indices count
  23288. * @param mesh defines the parent mesh
  23289. * @param renderingMesh defines an optional rendering mesh
  23290. * @param createBoundingBox defines if bounding box should be created for this submesh
  23291. */
  23292. constructor(
  23293. /** the material index to use */
  23294. materialIndex: number,
  23295. /** vertex index start */
  23296. verticesStart: number,
  23297. /** vertices count */
  23298. verticesCount: number,
  23299. /** index start */
  23300. indexStart: number,
  23301. /** indices count */
  23302. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23303. /**
  23304. * Returns true if this submesh covers the entire parent mesh
  23305. * @ignorenaming
  23306. */
  23307. readonly IsGlobal: boolean;
  23308. /**
  23309. * Returns the submesh BoudingInfo object
  23310. * @returns current bounding info (or mesh's one if the submesh is global)
  23311. */
  23312. getBoundingInfo(): BoundingInfo;
  23313. /**
  23314. * Sets the submesh BoundingInfo
  23315. * @param boundingInfo defines the new bounding info to use
  23316. * @returns the SubMesh
  23317. */
  23318. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23319. /**
  23320. * Returns the mesh of the current submesh
  23321. * @return the parent mesh
  23322. */
  23323. getMesh(): AbstractMesh;
  23324. /**
  23325. * Returns the rendering mesh of the submesh
  23326. * @returns the rendering mesh (could be different from parent mesh)
  23327. */
  23328. getRenderingMesh(): Mesh;
  23329. /**
  23330. * Returns the submesh material
  23331. * @returns null or the current material
  23332. */
  23333. getMaterial(): Nullable<Material>;
  23334. /**
  23335. * Sets a new updated BoundingInfo object to the submesh
  23336. * @param data defines an optional position array to use to determine the bounding info
  23337. * @returns the SubMesh
  23338. */
  23339. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23340. /** @hidden */
  23341. _checkCollision(collider: Collider): boolean;
  23342. /**
  23343. * Updates the submesh BoundingInfo
  23344. * @param world defines the world matrix to use to update the bounding info
  23345. * @returns the submesh
  23346. */
  23347. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23348. /**
  23349. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23350. * @param frustumPlanes defines the frustum planes
  23351. * @returns true if the submesh is intersecting with the frustum
  23352. */
  23353. isInFrustum(frustumPlanes: Plane[]): boolean;
  23354. /**
  23355. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23356. * @param frustumPlanes defines the frustum planes
  23357. * @returns true if the submesh is inside the frustum
  23358. */
  23359. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23360. /**
  23361. * Renders the submesh
  23362. * @param enableAlphaMode defines if alpha needs to be used
  23363. * @returns the submesh
  23364. */
  23365. render(enableAlphaMode: boolean): SubMesh;
  23366. /**
  23367. * @hidden
  23368. */
  23369. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23370. /**
  23371. * Checks if the submesh intersects with a ray
  23372. * @param ray defines the ray to test
  23373. * @returns true is the passed ray intersects the submesh bounding box
  23374. */
  23375. canIntersects(ray: Ray): boolean;
  23376. /**
  23377. * Intersects current submesh with a ray
  23378. * @param ray defines the ray to test
  23379. * @param positions defines mesh's positions array
  23380. * @param indices defines mesh's indices array
  23381. * @param fastCheck defines if only bounding info should be used
  23382. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23383. * @returns intersection info or null if no intersection
  23384. */
  23385. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23386. /** @hidden */
  23387. private _intersectLines;
  23388. /** @hidden */
  23389. private _intersectUnIndexedLines;
  23390. /** @hidden */
  23391. private _intersectTriangles;
  23392. /** @hidden */
  23393. private _intersectUnIndexedTriangles;
  23394. /** @hidden */
  23395. _rebuild(): void;
  23396. /**
  23397. * Creates a new submesh from the passed mesh
  23398. * @param newMesh defines the new hosting mesh
  23399. * @param newRenderingMesh defines an optional rendering mesh
  23400. * @returns the new submesh
  23401. */
  23402. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23403. /**
  23404. * Release associated resources
  23405. */
  23406. dispose(): void;
  23407. /**
  23408. * Gets the class name
  23409. * @returns the string "SubMesh".
  23410. */
  23411. getClassName(): string;
  23412. /**
  23413. * Creates a new submesh from indices data
  23414. * @param materialIndex the index of the main mesh material
  23415. * @param startIndex the index where to start the copy in the mesh indices array
  23416. * @param indexCount the number of indices to copy then from the startIndex
  23417. * @param mesh the main mesh to create the submesh from
  23418. * @param renderingMesh the optional rendering mesh
  23419. * @returns a new submesh
  23420. */
  23421. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23422. }
  23423. }
  23424. declare module "babylonjs/Meshes/geometry" {
  23425. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23426. import { Scene } from "babylonjs/scene";
  23427. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23428. import { Engine } from "babylonjs/Engines/engine";
  23429. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23430. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23431. import { Effect } from "babylonjs/Materials/effect";
  23432. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23433. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23434. import { Mesh } from "babylonjs/Meshes/mesh";
  23435. /**
  23436. * Class used to store geometry data (vertex buffers + index buffer)
  23437. */
  23438. export class Geometry implements IGetSetVerticesData {
  23439. /**
  23440. * Gets or sets the ID of the geometry
  23441. */
  23442. id: string;
  23443. /**
  23444. * Gets or sets the unique ID of the geometry
  23445. */
  23446. uniqueId: number;
  23447. /**
  23448. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23449. */
  23450. delayLoadState: number;
  23451. /**
  23452. * Gets the file containing the data to load when running in delay load state
  23453. */
  23454. delayLoadingFile: Nullable<string>;
  23455. /**
  23456. * Callback called when the geometry is updated
  23457. */
  23458. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23459. private _scene;
  23460. private _engine;
  23461. private _meshes;
  23462. private _totalVertices;
  23463. /** @hidden */
  23464. _indices: IndicesArray;
  23465. /** @hidden */
  23466. _vertexBuffers: {
  23467. [key: string]: VertexBuffer;
  23468. };
  23469. private _isDisposed;
  23470. private _extend;
  23471. private _boundingBias;
  23472. /** @hidden */
  23473. _delayInfo: Array<string>;
  23474. private _indexBuffer;
  23475. private _indexBufferIsUpdatable;
  23476. /** @hidden */
  23477. _boundingInfo: Nullable<BoundingInfo>;
  23478. /** @hidden */
  23479. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23480. /** @hidden */
  23481. _softwareSkinningFrameId: number;
  23482. private _vertexArrayObjects;
  23483. private _updatable;
  23484. /** @hidden */
  23485. _positions: Nullable<Vector3[]>;
  23486. /**
  23487. * 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
  23488. */
  23489. /**
  23490. * 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
  23491. */
  23492. boundingBias: Vector2;
  23493. /**
  23494. * Static function used to attach a new empty geometry to a mesh
  23495. * @param mesh defines the mesh to attach the geometry to
  23496. * @returns the new Geometry
  23497. */
  23498. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23499. /**
  23500. * Creates a new geometry
  23501. * @param id defines the unique ID
  23502. * @param scene defines the hosting scene
  23503. * @param vertexData defines the VertexData used to get geometry data
  23504. * @param updatable defines if geometry must be updatable (false by default)
  23505. * @param mesh defines the mesh that will be associated with the geometry
  23506. */
  23507. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23508. /**
  23509. * Gets the current extend of the geometry
  23510. */
  23511. readonly extend: {
  23512. minimum: Vector3;
  23513. maximum: Vector3;
  23514. };
  23515. /**
  23516. * Gets the hosting scene
  23517. * @returns the hosting Scene
  23518. */
  23519. getScene(): Scene;
  23520. /**
  23521. * Gets the hosting engine
  23522. * @returns the hosting Engine
  23523. */
  23524. getEngine(): Engine;
  23525. /**
  23526. * Defines if the geometry is ready to use
  23527. * @returns true if the geometry is ready to be used
  23528. */
  23529. isReady(): boolean;
  23530. /**
  23531. * Gets a value indicating that the geometry should not be serialized
  23532. */
  23533. readonly doNotSerialize: boolean;
  23534. /** @hidden */
  23535. _rebuild(): void;
  23536. /**
  23537. * Affects all geometry data in one call
  23538. * @param vertexData defines the geometry data
  23539. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23540. */
  23541. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23542. /**
  23543. * Set specific vertex data
  23544. * @param kind defines the data kind (Position, normal, etc...)
  23545. * @param data defines the vertex data to use
  23546. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23547. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23548. */
  23549. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23550. /**
  23551. * Removes a specific vertex data
  23552. * @param kind defines the data kind (Position, normal, etc...)
  23553. */
  23554. removeVerticesData(kind: string): void;
  23555. /**
  23556. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23557. * @param buffer defines the vertex buffer to use
  23558. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23559. */
  23560. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23561. /**
  23562. * Update a specific vertex buffer
  23563. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23564. * It will do nothing if the buffer is not updatable
  23565. * @param kind defines the data kind (Position, normal, etc...)
  23566. * @param data defines the data to use
  23567. * @param offset defines the offset in the target buffer where to store the data
  23568. * @param useBytes set to true if the offset is in bytes
  23569. */
  23570. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23571. /**
  23572. * Update a specific vertex buffer
  23573. * This function will create a new buffer if the current one is not updatable
  23574. * @param kind defines the data kind (Position, normal, etc...)
  23575. * @param data defines the data to use
  23576. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23577. */
  23578. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23579. private _updateBoundingInfo;
  23580. /** @hidden */
  23581. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23582. /**
  23583. * Gets total number of vertices
  23584. * @returns the total number of vertices
  23585. */
  23586. getTotalVertices(): number;
  23587. /**
  23588. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23589. * @param kind defines the data kind (Position, normal, etc...)
  23590. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23591. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23592. * @returns a float array containing vertex data
  23593. */
  23594. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23595. /**
  23596. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23597. * @param kind defines the data kind (Position, normal, etc...)
  23598. * @returns true if the vertex buffer with the specified kind is updatable
  23599. */
  23600. isVertexBufferUpdatable(kind: string): boolean;
  23601. /**
  23602. * Gets a specific vertex buffer
  23603. * @param kind defines the data kind (Position, normal, etc...)
  23604. * @returns a VertexBuffer
  23605. */
  23606. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23607. /**
  23608. * Returns all vertex buffers
  23609. * @return an object holding all vertex buffers indexed by kind
  23610. */
  23611. getVertexBuffers(): Nullable<{
  23612. [key: string]: VertexBuffer;
  23613. }>;
  23614. /**
  23615. * Gets a boolean indicating if specific vertex buffer is present
  23616. * @param kind defines the data kind (Position, normal, etc...)
  23617. * @returns true if data is present
  23618. */
  23619. isVerticesDataPresent(kind: string): boolean;
  23620. /**
  23621. * Gets a list of all attached data kinds (Position, normal, etc...)
  23622. * @returns a list of string containing all kinds
  23623. */
  23624. getVerticesDataKinds(): string[];
  23625. /**
  23626. * Update index buffer
  23627. * @param indices defines the indices to store in the index buffer
  23628. * @param offset defines the offset in the target buffer where to store the data
  23629. * @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)
  23630. */
  23631. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23632. /**
  23633. * Creates a new index buffer
  23634. * @param indices defines the indices to store in the index buffer
  23635. * @param totalVertices defines the total number of vertices (could be null)
  23636. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23637. */
  23638. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23639. /**
  23640. * Return the total number of indices
  23641. * @returns the total number of indices
  23642. */
  23643. getTotalIndices(): number;
  23644. /**
  23645. * Gets the index buffer array
  23646. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23647. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23648. * @returns the index buffer array
  23649. */
  23650. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23651. /**
  23652. * Gets the index buffer
  23653. * @return the index buffer
  23654. */
  23655. getIndexBuffer(): Nullable<DataBuffer>;
  23656. /** @hidden */
  23657. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23658. /**
  23659. * Release the associated resources for a specific mesh
  23660. * @param mesh defines the source mesh
  23661. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23662. */
  23663. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23664. /**
  23665. * Apply current geometry to a given mesh
  23666. * @param mesh defines the mesh to apply geometry to
  23667. */
  23668. applyToMesh(mesh: Mesh): void;
  23669. private _updateExtend;
  23670. private _applyToMesh;
  23671. private notifyUpdate;
  23672. /**
  23673. * Load the geometry if it was flagged as delay loaded
  23674. * @param scene defines the hosting scene
  23675. * @param onLoaded defines a callback called when the geometry is loaded
  23676. */
  23677. load(scene: Scene, onLoaded?: () => void): void;
  23678. private _queueLoad;
  23679. /**
  23680. * Invert the geometry to move from a right handed system to a left handed one.
  23681. */
  23682. toLeftHanded(): void;
  23683. /** @hidden */
  23684. _resetPointsArrayCache(): void;
  23685. /** @hidden */
  23686. _generatePointsArray(): boolean;
  23687. /**
  23688. * Gets a value indicating if the geometry is disposed
  23689. * @returns true if the geometry was disposed
  23690. */
  23691. isDisposed(): boolean;
  23692. private _disposeVertexArrayObjects;
  23693. /**
  23694. * Free all associated resources
  23695. */
  23696. dispose(): void;
  23697. /**
  23698. * Clone the current geometry into a new geometry
  23699. * @param id defines the unique ID of the new geometry
  23700. * @returns a new geometry object
  23701. */
  23702. copy(id: string): Geometry;
  23703. /**
  23704. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23705. * @return a JSON representation of the current geometry data (without the vertices data)
  23706. */
  23707. serialize(): any;
  23708. private toNumberArray;
  23709. /**
  23710. * Serialize all vertices data into a JSON oject
  23711. * @returns a JSON representation of the current geometry data
  23712. */
  23713. serializeVerticeData(): any;
  23714. /**
  23715. * Extracts a clone of a mesh geometry
  23716. * @param mesh defines the source mesh
  23717. * @param id defines the unique ID of the new geometry object
  23718. * @returns the new geometry object
  23719. */
  23720. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23721. /**
  23722. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23723. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23724. * Be aware Math.random() could cause collisions, but:
  23725. * "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"
  23726. * @returns a string containing a new GUID
  23727. */
  23728. static RandomId(): string;
  23729. /** @hidden */
  23730. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23731. private static _CleanMatricesWeights;
  23732. /**
  23733. * Create a new geometry from persisted data (Using .babylon file format)
  23734. * @param parsedVertexData defines the persisted data
  23735. * @param scene defines the hosting scene
  23736. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23737. * @returns the new geometry object
  23738. */
  23739. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23740. }
  23741. }
  23742. declare module "babylonjs/Meshes/mesh.vertexData" {
  23743. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23744. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23745. import { Geometry } from "babylonjs/Meshes/geometry";
  23746. import { Mesh } from "babylonjs/Meshes/mesh";
  23747. /**
  23748. * Define an interface for all classes that will get and set the data on vertices
  23749. */
  23750. export interface IGetSetVerticesData {
  23751. /**
  23752. * Gets a boolean indicating if specific vertex data is present
  23753. * @param kind defines the vertex data kind to use
  23754. * @returns true is data kind is present
  23755. */
  23756. isVerticesDataPresent(kind: string): boolean;
  23757. /**
  23758. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23759. * @param kind defines the data kind (Position, normal, etc...)
  23760. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23761. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23762. * @returns a float array containing vertex data
  23763. */
  23764. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23765. /**
  23766. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23767. * @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.
  23768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23769. * @returns the indices array or an empty array if the mesh has no geometry
  23770. */
  23771. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23772. /**
  23773. * Set specific vertex data
  23774. * @param kind defines the data kind (Position, normal, etc...)
  23775. * @param data defines the vertex data to use
  23776. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23777. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23778. */
  23779. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23780. /**
  23781. * Update a specific associated vertex buffer
  23782. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23783. * - VertexBuffer.PositionKind
  23784. * - VertexBuffer.UVKind
  23785. * - VertexBuffer.UV2Kind
  23786. * - VertexBuffer.UV3Kind
  23787. * - VertexBuffer.UV4Kind
  23788. * - VertexBuffer.UV5Kind
  23789. * - VertexBuffer.UV6Kind
  23790. * - VertexBuffer.ColorKind
  23791. * - VertexBuffer.MatricesIndicesKind
  23792. * - VertexBuffer.MatricesIndicesExtraKind
  23793. * - VertexBuffer.MatricesWeightsKind
  23794. * - VertexBuffer.MatricesWeightsExtraKind
  23795. * @param data defines the data source
  23796. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23797. * @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)
  23798. */
  23799. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23800. /**
  23801. * Creates a new index buffer
  23802. * @param indices defines the indices to store in the index buffer
  23803. * @param totalVertices defines the total number of vertices (could be null)
  23804. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23805. */
  23806. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23807. }
  23808. /**
  23809. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23810. */
  23811. export class VertexData {
  23812. /**
  23813. * Mesh side orientation : usually the external or front surface
  23814. */
  23815. static readonly FRONTSIDE: number;
  23816. /**
  23817. * Mesh side orientation : usually the internal or back surface
  23818. */
  23819. static readonly BACKSIDE: number;
  23820. /**
  23821. * Mesh side orientation : both internal and external or front and back surfaces
  23822. */
  23823. static readonly DOUBLESIDE: number;
  23824. /**
  23825. * Mesh side orientation : by default, `FRONTSIDE`
  23826. */
  23827. static readonly DEFAULTSIDE: number;
  23828. /**
  23829. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23830. */
  23831. positions: Nullable<FloatArray>;
  23832. /**
  23833. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23834. */
  23835. normals: Nullable<FloatArray>;
  23836. /**
  23837. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23838. */
  23839. tangents: Nullable<FloatArray>;
  23840. /**
  23841. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23842. */
  23843. uvs: Nullable<FloatArray>;
  23844. /**
  23845. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23846. */
  23847. uvs2: Nullable<FloatArray>;
  23848. /**
  23849. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23850. */
  23851. uvs3: Nullable<FloatArray>;
  23852. /**
  23853. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23854. */
  23855. uvs4: Nullable<FloatArray>;
  23856. /**
  23857. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23858. */
  23859. uvs5: Nullable<FloatArray>;
  23860. /**
  23861. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23862. */
  23863. uvs6: Nullable<FloatArray>;
  23864. /**
  23865. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23866. */
  23867. colors: Nullable<FloatArray>;
  23868. /**
  23869. * 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).
  23870. */
  23871. matricesIndices: Nullable<FloatArray>;
  23872. /**
  23873. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23874. */
  23875. matricesWeights: Nullable<FloatArray>;
  23876. /**
  23877. * An array extending the number of possible indices
  23878. */
  23879. matricesIndicesExtra: Nullable<FloatArray>;
  23880. /**
  23881. * An array extending the number of possible weights when the number of indices is extended
  23882. */
  23883. matricesWeightsExtra: Nullable<FloatArray>;
  23884. /**
  23885. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23886. */
  23887. indices: Nullable<IndicesArray>;
  23888. /**
  23889. * Uses the passed data array to set the set the values for the specified kind of data
  23890. * @param data a linear array of floating numbers
  23891. * @param kind the type of data that is being set, eg positions, colors etc
  23892. */
  23893. set(data: FloatArray, kind: string): void;
  23894. /**
  23895. * Associates the vertexData to the passed Mesh.
  23896. * Sets it as updatable or not (default `false`)
  23897. * @param mesh the mesh the vertexData is applied to
  23898. * @param updatable when used and having the value true allows new data to update the vertexData
  23899. * @returns the VertexData
  23900. */
  23901. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23902. /**
  23903. * Associates the vertexData to the passed Geometry.
  23904. * Sets it as updatable or not (default `false`)
  23905. * @param geometry the geometry the vertexData is applied to
  23906. * @param updatable when used and having the value true allows new data to update the vertexData
  23907. * @returns VertexData
  23908. */
  23909. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23910. /**
  23911. * Updates the associated mesh
  23912. * @param mesh the mesh to be updated
  23913. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23914. * @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
  23915. * @returns VertexData
  23916. */
  23917. updateMesh(mesh: Mesh): VertexData;
  23918. /**
  23919. * Updates the associated geometry
  23920. * @param geometry the geometry to be updated
  23921. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23922. * @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
  23923. * @returns VertexData.
  23924. */
  23925. updateGeometry(geometry: Geometry): VertexData;
  23926. private _applyTo;
  23927. private _update;
  23928. /**
  23929. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23930. * @param matrix the transforming matrix
  23931. * @returns the VertexData
  23932. */
  23933. transform(matrix: Matrix): VertexData;
  23934. /**
  23935. * Merges the passed VertexData into the current one
  23936. * @param other the VertexData to be merged into the current one
  23937. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23938. * @returns the modified VertexData
  23939. */
  23940. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23941. private _mergeElement;
  23942. private _validate;
  23943. /**
  23944. * Serializes the VertexData
  23945. * @returns a serialized object
  23946. */
  23947. serialize(): any;
  23948. /**
  23949. * Extracts the vertexData from a mesh
  23950. * @param mesh the mesh from which to extract the VertexData
  23951. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23952. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23953. * @returns the object VertexData associated to the passed mesh
  23954. */
  23955. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23956. /**
  23957. * Extracts the vertexData from the geometry
  23958. * @param geometry the geometry from which to extract the VertexData
  23959. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23960. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23961. * @returns the object VertexData associated to the passed mesh
  23962. */
  23963. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23964. private static _ExtractFrom;
  23965. /**
  23966. * Creates the VertexData for a Ribbon
  23967. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23968. * * pathArray array of paths, each of which an array of successive Vector3
  23969. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23970. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23971. * * 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
  23972. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23973. * * 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)
  23974. * * 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)
  23975. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23976. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23977. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23978. * @returns the VertexData of the ribbon
  23979. */
  23980. static CreateRibbon(options: {
  23981. pathArray: Vector3[][];
  23982. closeArray?: boolean;
  23983. closePath?: boolean;
  23984. offset?: number;
  23985. sideOrientation?: number;
  23986. frontUVs?: Vector4;
  23987. backUVs?: Vector4;
  23988. invertUV?: boolean;
  23989. uvs?: Vector2[];
  23990. colors?: Color4[];
  23991. }): VertexData;
  23992. /**
  23993. * Creates the VertexData for a box
  23994. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23995. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23996. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23997. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23998. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23999. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24000. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24002. * * 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)
  24003. * * 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)
  24004. * @returns the VertexData of the box
  24005. */
  24006. static CreateBox(options: {
  24007. size?: number;
  24008. width?: number;
  24009. height?: number;
  24010. depth?: number;
  24011. faceUV?: Vector4[];
  24012. faceColors?: Color4[];
  24013. sideOrientation?: number;
  24014. frontUVs?: Vector4;
  24015. backUVs?: Vector4;
  24016. }): VertexData;
  24017. /**
  24018. * Creates the VertexData for a tiled box
  24019. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24020. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24021. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24022. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24024. * @returns the VertexData of the box
  24025. */
  24026. static CreateTiledBox(options: {
  24027. pattern?: number;
  24028. width?: number;
  24029. height?: number;
  24030. depth?: number;
  24031. tileSize?: number;
  24032. tileWidth?: number;
  24033. tileHeight?: number;
  24034. alignHorizontal?: number;
  24035. alignVertical?: number;
  24036. faceUV?: Vector4[];
  24037. faceColors?: Color4[];
  24038. sideOrientation?: number;
  24039. }): VertexData;
  24040. /**
  24041. * Creates the VertexData for a tiled plane
  24042. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24043. * * pattern a limited pattern arrangement depending on the number
  24044. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24045. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24046. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24047. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24048. * * 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)
  24049. * * 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)
  24050. * @returns the VertexData of the tiled plane
  24051. */
  24052. static CreateTiledPlane(options: {
  24053. pattern?: number;
  24054. tileSize?: number;
  24055. tileWidth?: number;
  24056. tileHeight?: number;
  24057. size?: number;
  24058. width?: number;
  24059. height?: number;
  24060. alignHorizontal?: number;
  24061. alignVertical?: number;
  24062. sideOrientation?: number;
  24063. frontUVs?: Vector4;
  24064. backUVs?: Vector4;
  24065. }): VertexData;
  24066. /**
  24067. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24068. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24069. * * segments sets the number of horizontal strips optional, default 32
  24070. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24071. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24072. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24073. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24074. * * 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
  24075. * * 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
  24076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24077. * * 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)
  24078. * * 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)
  24079. * @returns the VertexData of the ellipsoid
  24080. */
  24081. static CreateSphere(options: {
  24082. segments?: number;
  24083. diameter?: number;
  24084. diameterX?: number;
  24085. diameterY?: number;
  24086. diameterZ?: number;
  24087. arc?: number;
  24088. slice?: number;
  24089. sideOrientation?: number;
  24090. frontUVs?: Vector4;
  24091. backUVs?: Vector4;
  24092. }): VertexData;
  24093. /**
  24094. * Creates the VertexData for a cylinder, cone or prism
  24095. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24096. * * height sets the height (y direction) of the cylinder, optional, default 2
  24097. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24098. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24099. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24100. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24101. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24102. * * 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
  24103. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24104. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24105. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24106. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24107. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24108. * * 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)
  24109. * * 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)
  24110. * @returns the VertexData of the cylinder, cone or prism
  24111. */
  24112. static CreateCylinder(options: {
  24113. height?: number;
  24114. diameterTop?: number;
  24115. diameterBottom?: number;
  24116. diameter?: number;
  24117. tessellation?: number;
  24118. subdivisions?: number;
  24119. arc?: number;
  24120. faceColors?: Color4[];
  24121. faceUV?: Vector4[];
  24122. hasRings?: boolean;
  24123. enclose?: boolean;
  24124. sideOrientation?: number;
  24125. frontUVs?: Vector4;
  24126. backUVs?: Vector4;
  24127. }): VertexData;
  24128. /**
  24129. * Creates the VertexData for a torus
  24130. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24131. * * diameter the diameter of the torus, optional default 1
  24132. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24133. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24134. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24135. * * 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)
  24136. * * 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)
  24137. * @returns the VertexData of the torus
  24138. */
  24139. static CreateTorus(options: {
  24140. diameter?: number;
  24141. thickness?: number;
  24142. tessellation?: number;
  24143. sideOrientation?: number;
  24144. frontUVs?: Vector4;
  24145. backUVs?: Vector4;
  24146. }): VertexData;
  24147. /**
  24148. * Creates the VertexData of the LineSystem
  24149. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24150. * - lines an array of lines, each line being an array of successive Vector3
  24151. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24152. * @returns the VertexData of the LineSystem
  24153. */
  24154. static CreateLineSystem(options: {
  24155. lines: Vector3[][];
  24156. colors?: Nullable<Color4[][]>;
  24157. }): VertexData;
  24158. /**
  24159. * Create the VertexData for a DashedLines
  24160. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24161. * - points an array successive Vector3
  24162. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24163. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24164. * - dashNb the intended total number of dashes, optional, default 200
  24165. * @returns the VertexData for the DashedLines
  24166. */
  24167. static CreateDashedLines(options: {
  24168. points: Vector3[];
  24169. dashSize?: number;
  24170. gapSize?: number;
  24171. dashNb?: number;
  24172. }): VertexData;
  24173. /**
  24174. * Creates the VertexData for a Ground
  24175. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24176. * - width the width (x direction) of the ground, optional, default 1
  24177. * - height the height (z direction) of the ground, optional, default 1
  24178. * - subdivisions the number of subdivisions per side, optional, default 1
  24179. * @returns the VertexData of the Ground
  24180. */
  24181. static CreateGround(options: {
  24182. width?: number;
  24183. height?: number;
  24184. subdivisions?: number;
  24185. subdivisionsX?: number;
  24186. subdivisionsY?: number;
  24187. }): VertexData;
  24188. /**
  24189. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24190. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24191. * * xmin the ground minimum X coordinate, optional, default -1
  24192. * * zmin the ground minimum Z coordinate, optional, default -1
  24193. * * xmax the ground maximum X coordinate, optional, default 1
  24194. * * zmax the ground maximum Z coordinate, optional, default 1
  24195. * * 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}
  24196. * * 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}
  24197. * @returns the VertexData of the TiledGround
  24198. */
  24199. static CreateTiledGround(options: {
  24200. xmin: number;
  24201. zmin: number;
  24202. xmax: number;
  24203. zmax: number;
  24204. subdivisions?: {
  24205. w: number;
  24206. h: number;
  24207. };
  24208. precision?: {
  24209. w: number;
  24210. h: number;
  24211. };
  24212. }): VertexData;
  24213. /**
  24214. * Creates the VertexData of the Ground designed from a heightmap
  24215. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24216. * * width the width (x direction) of the ground
  24217. * * height the height (z direction) of the ground
  24218. * * subdivisions the number of subdivisions per side
  24219. * * minHeight the minimum altitude on the ground, optional, default 0
  24220. * * maxHeight the maximum altitude on the ground, optional default 1
  24221. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24222. * * buffer the array holding the image color data
  24223. * * bufferWidth the width of image
  24224. * * bufferHeight the height of image
  24225. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24226. * @returns the VertexData of the Ground designed from a heightmap
  24227. */
  24228. static CreateGroundFromHeightMap(options: {
  24229. width: number;
  24230. height: number;
  24231. subdivisions: number;
  24232. minHeight: number;
  24233. maxHeight: number;
  24234. colorFilter: Color3;
  24235. buffer: Uint8Array;
  24236. bufferWidth: number;
  24237. bufferHeight: number;
  24238. alphaFilter: number;
  24239. }): VertexData;
  24240. /**
  24241. * Creates the VertexData for a Plane
  24242. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24243. * * size sets the width and height of the plane to the value of size, optional default 1
  24244. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24245. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24247. * * 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)
  24248. * * 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)
  24249. * @returns the VertexData of the box
  24250. */
  24251. static CreatePlane(options: {
  24252. size?: number;
  24253. width?: number;
  24254. height?: number;
  24255. sideOrientation?: number;
  24256. frontUVs?: Vector4;
  24257. backUVs?: Vector4;
  24258. }): VertexData;
  24259. /**
  24260. * Creates the VertexData of the Disc or regular Polygon
  24261. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24262. * * radius the radius of the disc, optional default 0.5
  24263. * * tessellation the number of polygon sides, optional, default 64
  24264. * * 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
  24265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24266. * * 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)
  24267. * * 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)
  24268. * @returns the VertexData of the box
  24269. */
  24270. static CreateDisc(options: {
  24271. radius?: number;
  24272. tessellation?: number;
  24273. arc?: number;
  24274. sideOrientation?: number;
  24275. frontUVs?: Vector4;
  24276. backUVs?: Vector4;
  24277. }): VertexData;
  24278. /**
  24279. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24280. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24281. * @param polygon a mesh built from polygonTriangulation.build()
  24282. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24283. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24284. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24285. * @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)
  24286. * @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)
  24287. * @returns the VertexData of the Polygon
  24288. */
  24289. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24290. /**
  24291. * Creates the VertexData of the IcoSphere
  24292. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24293. * * radius the radius of the IcoSphere, optional default 1
  24294. * * radiusX allows stretching in the x direction, optional, default radius
  24295. * * radiusY allows stretching in the y direction, optional, default radius
  24296. * * radiusZ allows stretching in the z direction, optional, default radius
  24297. * * flat when true creates a flat shaded mesh, optional, default true
  24298. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24299. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24300. * * 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)
  24301. * * 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)
  24302. * @returns the VertexData of the IcoSphere
  24303. */
  24304. static CreateIcoSphere(options: {
  24305. radius?: number;
  24306. radiusX?: number;
  24307. radiusY?: number;
  24308. radiusZ?: number;
  24309. flat?: boolean;
  24310. subdivisions?: number;
  24311. sideOrientation?: number;
  24312. frontUVs?: Vector4;
  24313. backUVs?: Vector4;
  24314. }): VertexData;
  24315. /**
  24316. * Creates the VertexData for a Polyhedron
  24317. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24318. * * type provided types are:
  24319. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24320. * * 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)
  24321. * * size the size of the IcoSphere, optional default 1
  24322. * * sizeX allows stretching in the x direction, optional, default size
  24323. * * sizeY allows stretching in the y direction, optional, default size
  24324. * * sizeZ allows stretching in the z direction, optional, default size
  24325. * * 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
  24326. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24327. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24328. * * flat when true creates a flat shaded mesh, optional, default true
  24329. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24331. * * 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)
  24332. * * 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)
  24333. * @returns the VertexData of the Polyhedron
  24334. */
  24335. static CreatePolyhedron(options: {
  24336. type?: number;
  24337. size?: number;
  24338. sizeX?: number;
  24339. sizeY?: number;
  24340. sizeZ?: number;
  24341. custom?: any;
  24342. faceUV?: Vector4[];
  24343. faceColors?: Color4[];
  24344. flat?: boolean;
  24345. sideOrientation?: number;
  24346. frontUVs?: Vector4;
  24347. backUVs?: Vector4;
  24348. }): VertexData;
  24349. /**
  24350. * Creates the VertexData for a TorusKnot
  24351. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24352. * * radius the radius of the torus knot, optional, default 2
  24353. * * tube the thickness of the tube, optional, default 0.5
  24354. * * radialSegments the number of sides on each tube segments, optional, default 32
  24355. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24356. * * p the number of windings around the z axis, optional, default 2
  24357. * * q the number of windings around the x axis, optional, default 3
  24358. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24359. * * 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)
  24360. * * 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)
  24361. * @returns the VertexData of the Torus Knot
  24362. */
  24363. static CreateTorusKnot(options: {
  24364. radius?: number;
  24365. tube?: number;
  24366. radialSegments?: number;
  24367. tubularSegments?: number;
  24368. p?: number;
  24369. q?: number;
  24370. sideOrientation?: number;
  24371. frontUVs?: Vector4;
  24372. backUVs?: Vector4;
  24373. }): VertexData;
  24374. /**
  24375. * Compute normals for given positions and indices
  24376. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24377. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24378. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24379. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24380. * * facetNormals : optional array of facet normals (vector3)
  24381. * * facetPositions : optional array of facet positions (vector3)
  24382. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24383. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24384. * * bInfo : optional bounding info, required for facetPartitioning computation
  24385. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24386. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24387. * * useRightHandedSystem: optional boolean to for right handed system computation
  24388. * * depthSort : optional boolean to enable the facet depth sort computation
  24389. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24390. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24391. */
  24392. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24393. facetNormals?: any;
  24394. facetPositions?: any;
  24395. facetPartitioning?: any;
  24396. ratio?: number;
  24397. bInfo?: any;
  24398. bbSize?: Vector3;
  24399. subDiv?: any;
  24400. useRightHandedSystem?: boolean;
  24401. depthSort?: boolean;
  24402. distanceTo?: Vector3;
  24403. depthSortedFacets?: any;
  24404. }): void;
  24405. /** @hidden */
  24406. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24407. /**
  24408. * Applies VertexData created from the imported parameters to the geometry
  24409. * @param parsedVertexData the parsed data from an imported file
  24410. * @param geometry the geometry to apply the VertexData to
  24411. */
  24412. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24413. }
  24414. }
  24415. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24416. import { Nullable } from "babylonjs/types";
  24417. import { Scene } from "babylonjs/scene";
  24418. import { Vector4 } from "babylonjs/Maths/math";
  24419. import { Mesh } from "babylonjs/Meshes/mesh";
  24420. /**
  24421. * Class containing static functions to help procedurally build meshes
  24422. */
  24423. export class DiscBuilder {
  24424. /**
  24425. * Creates a plane polygonal mesh. By default, this is a disc
  24426. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24427. * * 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
  24428. * * 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
  24429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24432. * @param name defines the name of the mesh
  24433. * @param options defines the options used to create the mesh
  24434. * @param scene defines the hosting scene
  24435. * @returns the plane polygonal mesh
  24436. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24437. */
  24438. static CreateDisc(name: string, options: {
  24439. radius?: number;
  24440. tessellation?: number;
  24441. arc?: number;
  24442. updatable?: boolean;
  24443. sideOrientation?: number;
  24444. frontUVs?: Vector4;
  24445. backUVs?: Vector4;
  24446. }, scene?: Nullable<Scene>): Mesh;
  24447. }
  24448. }
  24449. declare module "babylonjs/Particles/solidParticleSystem" {
  24450. import { Vector3 } from "babylonjs/Maths/math";
  24451. import { Mesh } from "babylonjs/Meshes/mesh";
  24452. import { Scene, IDisposable } from "babylonjs/scene";
  24453. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24454. /**
  24455. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24456. *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.
  24457. * The SPS is also a particle system. It provides some methods to manage the particles.
  24458. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24459. *
  24460. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24461. */
  24462. export class SolidParticleSystem implements IDisposable {
  24463. /**
  24464. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24465. * Example : var p = SPS.particles[i];
  24466. */
  24467. particles: SolidParticle[];
  24468. /**
  24469. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24470. */
  24471. nbParticles: number;
  24472. /**
  24473. * If the particles must ever face the camera (default false). Useful for planar particles.
  24474. */
  24475. billboard: boolean;
  24476. /**
  24477. * Recompute normals when adding a shape
  24478. */
  24479. recomputeNormals: boolean;
  24480. /**
  24481. * This a counter ofr your own usage. It's not set by any SPS functions.
  24482. */
  24483. counter: number;
  24484. /**
  24485. * The SPS name. This name is also given to the underlying mesh.
  24486. */
  24487. name: string;
  24488. /**
  24489. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24490. */
  24491. mesh: Mesh;
  24492. /**
  24493. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24494. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24495. */
  24496. vars: any;
  24497. /**
  24498. * This array is populated when the SPS is set as 'pickable'.
  24499. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24500. * Each element of this array is an object `{idx: int, faceId: int}`.
  24501. * `idx` is the picked particle index in the `SPS.particles` array
  24502. * `faceId` is the picked face index counted within this particle.
  24503. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24504. */
  24505. pickedParticles: {
  24506. idx: number;
  24507. faceId: number;
  24508. }[];
  24509. /**
  24510. * This array is populated when `enableDepthSort` is set to true.
  24511. * Each element of this array is an instance of the class DepthSortedParticle.
  24512. */
  24513. depthSortedParticles: DepthSortedParticle[];
  24514. /**
  24515. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24516. * @hidden
  24517. */
  24518. _bSphereOnly: boolean;
  24519. /**
  24520. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24521. * @hidden
  24522. */
  24523. _bSphereRadiusFactor: number;
  24524. private _scene;
  24525. private _positions;
  24526. private _indices;
  24527. private _normals;
  24528. private _colors;
  24529. private _uvs;
  24530. private _indices32;
  24531. private _positions32;
  24532. private _normals32;
  24533. private _fixedNormal32;
  24534. private _colors32;
  24535. private _uvs32;
  24536. private _index;
  24537. private _updatable;
  24538. private _pickable;
  24539. private _isVisibilityBoxLocked;
  24540. private _alwaysVisible;
  24541. private _depthSort;
  24542. private _shapeCounter;
  24543. private _copy;
  24544. private _color;
  24545. private _computeParticleColor;
  24546. private _computeParticleTexture;
  24547. private _computeParticleRotation;
  24548. private _computeParticleVertex;
  24549. private _computeBoundingBox;
  24550. private _depthSortParticles;
  24551. private _camera;
  24552. private _mustUnrotateFixedNormals;
  24553. private _particlesIntersect;
  24554. private _needs32Bits;
  24555. /**
  24556. * Creates a SPS (Solid Particle System) object.
  24557. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24558. * @param scene (Scene) is the scene in which the SPS is added.
  24559. * @param options defines the options of the sps e.g.
  24560. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24561. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24562. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24563. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24564. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24565. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24566. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24567. */
  24568. constructor(name: string, scene: Scene, options?: {
  24569. updatable?: boolean;
  24570. isPickable?: boolean;
  24571. enableDepthSort?: boolean;
  24572. particleIntersection?: boolean;
  24573. boundingSphereOnly?: boolean;
  24574. bSphereRadiusFactor?: number;
  24575. });
  24576. /**
  24577. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24578. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24579. * @returns the created mesh
  24580. */
  24581. buildMesh(): Mesh;
  24582. /**
  24583. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24584. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24585. * Thus the particles generated from `digest()` have their property `position` set yet.
  24586. * @param mesh ( Mesh ) is the mesh to be digested
  24587. * @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
  24588. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24589. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24590. * @returns the current SPS
  24591. */
  24592. digest(mesh: Mesh, options?: {
  24593. facetNb?: number;
  24594. number?: number;
  24595. delta?: number;
  24596. }): SolidParticleSystem;
  24597. private _unrotateFixedNormals;
  24598. private _resetCopy;
  24599. private _meshBuilder;
  24600. private _posToShape;
  24601. private _uvsToShapeUV;
  24602. private _addParticle;
  24603. /**
  24604. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24605. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24606. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24607. * @param nb (positive integer) the number of particles to be created from this model
  24608. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24609. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24610. * @returns the number of shapes in the system
  24611. */
  24612. addShape(mesh: Mesh, nb: number, options?: {
  24613. positionFunction?: any;
  24614. vertexFunction?: any;
  24615. }): number;
  24616. private _rebuildParticle;
  24617. /**
  24618. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24619. * @returns the SPS.
  24620. */
  24621. rebuildMesh(): SolidParticleSystem;
  24622. /**
  24623. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24624. * This method calls `updateParticle()` for each particle of the SPS.
  24625. * For an animated SPS, it is usually called within the render loop.
  24626. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24627. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24628. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24629. * @returns the SPS.
  24630. */
  24631. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24632. /**
  24633. * Disposes the SPS.
  24634. */
  24635. dispose(): void;
  24636. /**
  24637. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24638. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24639. * @returns the SPS.
  24640. */
  24641. refreshVisibleSize(): SolidParticleSystem;
  24642. /**
  24643. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24644. * @param size the size (float) of the visibility box
  24645. * note : this doesn't lock the SPS mesh bounding box.
  24646. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24647. */
  24648. setVisibilityBox(size: number): void;
  24649. /**
  24650. * Gets whether the SPS as always visible or not
  24651. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24652. */
  24653. /**
  24654. * Sets the SPS as always visible or not
  24655. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24656. */
  24657. isAlwaysVisible: boolean;
  24658. /**
  24659. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24660. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24661. */
  24662. /**
  24663. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24664. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24665. */
  24666. isVisibilityBoxLocked: boolean;
  24667. /**
  24668. * Tells to `setParticles()` to compute the particle rotations or not.
  24669. * Default value : true. The SPS is faster when it's set to false.
  24670. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24671. */
  24672. /**
  24673. * Gets if `setParticles()` computes the particle rotations or not.
  24674. * Default value : true. The SPS is faster when it's set to false.
  24675. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24676. */
  24677. computeParticleRotation: boolean;
  24678. /**
  24679. * Tells to `setParticles()` to compute the particle colors or not.
  24680. * Default value : true. The SPS is faster when it's set to false.
  24681. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24682. */
  24683. /**
  24684. * Gets if `setParticles()` computes the particle colors or not.
  24685. * Default value : true. The SPS is faster when it's set to false.
  24686. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24687. */
  24688. computeParticleColor: boolean;
  24689. /**
  24690. * Gets if `setParticles()` computes the particle textures or not.
  24691. * Default value : true. The SPS is faster when it's set to false.
  24692. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24693. */
  24694. computeParticleTexture: boolean;
  24695. /**
  24696. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24697. * Default value : false. The SPS is faster when it's set to false.
  24698. * Note : the particle custom vertex positions aren't stored values.
  24699. */
  24700. /**
  24701. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24702. * Default value : false. The SPS is faster when it's set to false.
  24703. * Note : the particle custom vertex positions aren't stored values.
  24704. */
  24705. computeParticleVertex: boolean;
  24706. /**
  24707. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24708. */
  24709. /**
  24710. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24711. */
  24712. computeBoundingBox: boolean;
  24713. /**
  24714. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24715. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24716. * Default : `true`
  24717. */
  24718. /**
  24719. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24720. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24721. * Default : `true`
  24722. */
  24723. depthSortParticles: boolean;
  24724. /**
  24725. * This function does nothing. It may be overwritten to set all the particle first values.
  24726. * The SPS doesn't call this function, you may have to call it by your own.
  24727. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24728. */
  24729. initParticles(): void;
  24730. /**
  24731. * This function does nothing. It may be overwritten to recycle a particle.
  24732. * The SPS doesn't call this function, you may have to call it by your own.
  24733. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24734. * @param particle The particle to recycle
  24735. * @returns the recycled particle
  24736. */
  24737. recycleParticle(particle: SolidParticle): SolidParticle;
  24738. /**
  24739. * Updates a particle : this function should be overwritten by the user.
  24740. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24741. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24742. * @example : just set a particle position or velocity and recycle conditions
  24743. * @param particle The particle to update
  24744. * @returns the updated particle
  24745. */
  24746. updateParticle(particle: SolidParticle): SolidParticle;
  24747. /**
  24748. * Updates a vertex of a particle : it can be overwritten by the user.
  24749. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24750. * @param particle the current particle
  24751. * @param vertex the current index of the current particle
  24752. * @param pt the index of the current vertex in the particle shape
  24753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24754. * @example : just set a vertex particle position
  24755. * @returns the updated vertex
  24756. */
  24757. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24758. /**
  24759. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24760. * This does nothing and may be overwritten by the user.
  24761. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24762. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24763. * @param update the boolean update value actually passed to setParticles()
  24764. */
  24765. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24766. /**
  24767. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24768. * This will be passed three parameters.
  24769. * This does nothing and may be overwritten by the user.
  24770. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24771. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24772. * @param update the boolean update value actually passed to setParticles()
  24773. */
  24774. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24775. }
  24776. }
  24777. declare module "babylonjs/Particles/solidParticle" {
  24778. import { Nullable } from "babylonjs/types";
  24779. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24780. import { Mesh } from "babylonjs/Meshes/mesh";
  24781. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24782. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24783. /**
  24784. * Represents one particle of a solid particle system.
  24785. */
  24786. export class SolidParticle {
  24787. /**
  24788. * particle global index
  24789. */
  24790. idx: number;
  24791. /**
  24792. * The color of the particle
  24793. */
  24794. color: Nullable<Color4>;
  24795. /**
  24796. * The world space position of the particle.
  24797. */
  24798. position: Vector3;
  24799. /**
  24800. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24801. */
  24802. rotation: Vector3;
  24803. /**
  24804. * The world space rotation quaternion of the particle.
  24805. */
  24806. rotationQuaternion: Nullable<Quaternion>;
  24807. /**
  24808. * The scaling of the particle.
  24809. */
  24810. scaling: Vector3;
  24811. /**
  24812. * The uvs of the particle.
  24813. */
  24814. uvs: Vector4;
  24815. /**
  24816. * The current speed of the particle.
  24817. */
  24818. velocity: Vector3;
  24819. /**
  24820. * The pivot point in the particle local space.
  24821. */
  24822. pivot: Vector3;
  24823. /**
  24824. * Must the particle be translated from its pivot point in its local space ?
  24825. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24826. * Default : false
  24827. */
  24828. translateFromPivot: boolean;
  24829. /**
  24830. * Is the particle active or not ?
  24831. */
  24832. alive: boolean;
  24833. /**
  24834. * Is the particle visible or not ?
  24835. */
  24836. isVisible: boolean;
  24837. /**
  24838. * Index of this particle in the global "positions" array (Internal use)
  24839. * @hidden
  24840. */
  24841. _pos: number;
  24842. /**
  24843. * @hidden Index of this particle in the global "indices" array (Internal use)
  24844. */
  24845. _ind: number;
  24846. /**
  24847. * @hidden ModelShape of this particle (Internal use)
  24848. */
  24849. _model: ModelShape;
  24850. /**
  24851. * ModelShape id of this particle
  24852. */
  24853. shapeId: number;
  24854. /**
  24855. * Index of the particle in its shape id (Internal use)
  24856. */
  24857. idxInShape: number;
  24858. /**
  24859. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24860. */
  24861. _modelBoundingInfo: BoundingInfo;
  24862. /**
  24863. * @hidden Particle BoundingInfo object (Internal use)
  24864. */
  24865. _boundingInfo: BoundingInfo;
  24866. /**
  24867. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24868. */
  24869. _sps: SolidParticleSystem;
  24870. /**
  24871. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24872. */
  24873. _stillInvisible: boolean;
  24874. /**
  24875. * @hidden Last computed particle rotation matrix
  24876. */
  24877. _rotationMatrix: number[];
  24878. /**
  24879. * Parent particle Id, if any.
  24880. * Default null.
  24881. */
  24882. parentId: Nullable<number>;
  24883. /**
  24884. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24885. * The possible values are :
  24886. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24887. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24888. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24889. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24890. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24891. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24892. * */
  24893. cullingStrategy: number;
  24894. /**
  24895. * @hidden Internal global position in the SPS.
  24896. */
  24897. _globalPosition: Vector3;
  24898. /**
  24899. * Creates a Solid Particle object.
  24900. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24901. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24902. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24903. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24904. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24905. * @param shapeId (integer) is the model shape identifier in the SPS.
  24906. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24907. * @param sps defines the sps it is associated to
  24908. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24909. */
  24910. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24911. /**
  24912. * Legacy support, changed scale to scaling
  24913. */
  24914. /**
  24915. * Legacy support, changed scale to scaling
  24916. */
  24917. scale: Vector3;
  24918. /**
  24919. * Legacy support, changed quaternion to rotationQuaternion
  24920. */
  24921. /**
  24922. * Legacy support, changed quaternion to rotationQuaternion
  24923. */
  24924. quaternion: Nullable<Quaternion>;
  24925. /**
  24926. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24927. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24928. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24929. * @returns true if it intersects
  24930. */
  24931. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24932. /**
  24933. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24934. * A particle is in the frustum if its bounding box intersects the frustum
  24935. * @param frustumPlanes defines the frustum to test
  24936. * @returns true if the particle is in the frustum planes
  24937. */
  24938. isInFrustum(frustumPlanes: Plane[]): boolean;
  24939. /**
  24940. * get the rotation matrix of the particle
  24941. * @hidden
  24942. */
  24943. getRotationMatrix(m: Matrix): void;
  24944. }
  24945. /**
  24946. * Represents the shape of the model used by one particle of a solid particle system.
  24947. * SPS internal tool, don't use it manually.
  24948. */
  24949. export class ModelShape {
  24950. /**
  24951. * The shape id
  24952. * @hidden
  24953. */
  24954. shapeID: number;
  24955. /**
  24956. * flat array of model positions (internal use)
  24957. * @hidden
  24958. */
  24959. _shape: Vector3[];
  24960. /**
  24961. * flat array of model UVs (internal use)
  24962. * @hidden
  24963. */
  24964. _shapeUV: number[];
  24965. /**
  24966. * length of the shape in the model indices array (internal use)
  24967. * @hidden
  24968. */
  24969. _indicesLength: number;
  24970. /**
  24971. * Custom position function (internal use)
  24972. * @hidden
  24973. */
  24974. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24975. /**
  24976. * Custom vertex function (internal use)
  24977. * @hidden
  24978. */
  24979. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24980. /**
  24981. * 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.
  24982. * SPS internal tool, don't use it manually.
  24983. * @hidden
  24984. */
  24985. 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>);
  24986. }
  24987. /**
  24988. * Represents a Depth Sorted Particle in the solid particle system.
  24989. */
  24990. export class DepthSortedParticle {
  24991. /**
  24992. * Index of the particle in the "indices" array
  24993. */
  24994. ind: number;
  24995. /**
  24996. * Length of the particle shape in the "indices" array
  24997. */
  24998. indicesLength: number;
  24999. /**
  25000. * Squared distance from the particle to the camera
  25001. */
  25002. sqDistance: number;
  25003. }
  25004. }
  25005. declare module "babylonjs/Collisions/meshCollisionData" {
  25006. import { Collider } from "babylonjs/Collisions/collider";
  25007. import { Vector3 } from "babylonjs/Maths/math";
  25008. import { Nullable } from "babylonjs/types";
  25009. import { Observer } from "babylonjs/Misc/observable";
  25010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25011. /**
  25012. * @hidden
  25013. */
  25014. export class _MeshCollisionData {
  25015. _checkCollisions: boolean;
  25016. _collisionMask: number;
  25017. _collisionGroup: number;
  25018. _collider: Nullable<Collider>;
  25019. _oldPositionForCollisions: Vector3;
  25020. _diffPositionForCollisions: Vector3;
  25021. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25022. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25023. }
  25024. }
  25025. declare module "babylonjs/Meshes/abstractMesh" {
  25026. import { Observable } from "babylonjs/Misc/observable";
  25027. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25028. import { Camera } from "babylonjs/Cameras/camera";
  25029. import { Scene, IDisposable } from "babylonjs/scene";
  25030. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25031. import { Node } from "babylonjs/node";
  25032. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25033. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25034. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25035. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25036. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25037. import { Material } from "babylonjs/Materials/material";
  25038. import { Light } from "babylonjs/Lights/light";
  25039. import { Skeleton } from "babylonjs/Bones/skeleton";
  25040. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25041. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25042. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25043. import { Ray } from "babylonjs/Culling/ray";
  25044. import { Collider } from "babylonjs/Collisions/collider";
  25045. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25046. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25047. /** @hidden */
  25048. class _FacetDataStorage {
  25049. facetPositions: Vector3[];
  25050. facetNormals: Vector3[];
  25051. facetPartitioning: number[][];
  25052. facetNb: number;
  25053. partitioningSubdivisions: number;
  25054. partitioningBBoxRatio: number;
  25055. facetDataEnabled: boolean;
  25056. facetParameters: any;
  25057. bbSize: Vector3;
  25058. subDiv: {
  25059. max: number;
  25060. X: number;
  25061. Y: number;
  25062. Z: number;
  25063. };
  25064. facetDepthSort: boolean;
  25065. facetDepthSortEnabled: boolean;
  25066. depthSortedIndices: IndicesArray;
  25067. depthSortedFacets: {
  25068. ind: number;
  25069. sqDistance: number;
  25070. }[];
  25071. facetDepthSortFunction: (f1: {
  25072. ind: number;
  25073. sqDistance: number;
  25074. }, f2: {
  25075. ind: number;
  25076. sqDistance: number;
  25077. }) => number;
  25078. facetDepthSortFrom: Vector3;
  25079. facetDepthSortOrigin: Vector3;
  25080. invertedMatrix: Matrix;
  25081. }
  25082. /**
  25083. * @hidden
  25084. **/
  25085. class _InternalAbstractMeshDataInfo {
  25086. _hasVertexAlpha: boolean;
  25087. _useVertexColors: boolean;
  25088. _numBoneInfluencers: number;
  25089. _applyFog: boolean;
  25090. _receiveShadows: boolean;
  25091. _facetData: _FacetDataStorage;
  25092. _visibility: number;
  25093. _skeleton: Nullable<Skeleton>;
  25094. _layerMask: number;
  25095. _computeBonesUsingShaders: boolean;
  25096. _isActive: boolean;
  25097. _onlyForInstances: boolean;
  25098. _isActiveIntermediate: boolean;
  25099. _onlyForInstancesIntermediate: boolean;
  25100. }
  25101. /**
  25102. * Class used to store all common mesh properties
  25103. */
  25104. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25105. /** No occlusion */
  25106. static OCCLUSION_TYPE_NONE: number;
  25107. /** Occlusion set to optimisitic */
  25108. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25109. /** Occlusion set to strict */
  25110. static OCCLUSION_TYPE_STRICT: number;
  25111. /** Use an accurante occlusion algorithm */
  25112. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25113. /** Use a conservative occlusion algorithm */
  25114. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25115. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25116. * Test order :
  25117. * Is the bounding sphere outside the frustum ?
  25118. * If not, are the bounding box vertices outside the frustum ?
  25119. * It not, then the cullable object is in the frustum.
  25120. */
  25121. static readonly CULLINGSTRATEGY_STANDARD: number;
  25122. /** Culling strategy : Bounding Sphere Only.
  25123. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25124. * It's also less accurate than the standard because some not visible objects can still be selected.
  25125. * Test : is the bounding sphere outside the frustum ?
  25126. * If not, then the cullable object is in the frustum.
  25127. */
  25128. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25129. /** Culling strategy : Optimistic Inclusion.
  25130. * This in an inclusion test first, then the standard exclusion test.
  25131. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25132. * 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.
  25133. * Anyway, it's as accurate as the standard strategy.
  25134. * Test :
  25135. * Is the cullable object bounding sphere center in the frustum ?
  25136. * If not, apply the default culling strategy.
  25137. */
  25138. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25139. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25140. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25141. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25142. * 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.
  25143. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25144. * Test :
  25145. * Is the cullable object bounding sphere center in the frustum ?
  25146. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25147. */
  25148. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25149. /**
  25150. * No billboard
  25151. */
  25152. static readonly BILLBOARDMODE_NONE: number;
  25153. /** Billboard on X axis */
  25154. static readonly BILLBOARDMODE_X: number;
  25155. /** Billboard on Y axis */
  25156. static readonly BILLBOARDMODE_Y: number;
  25157. /** Billboard on Z axis */
  25158. static readonly BILLBOARDMODE_Z: number;
  25159. /** Billboard on all axes */
  25160. static readonly BILLBOARDMODE_ALL: number;
  25161. /** @hidden */
  25162. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25163. /**
  25164. * The culling strategy to use to check whether the mesh must be rendered or not.
  25165. * This value can be changed at any time and will be used on the next render mesh selection.
  25166. * The possible values are :
  25167. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25168. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25169. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25170. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25171. * Please read each static variable documentation to get details about the culling process.
  25172. * */
  25173. cullingStrategy: number;
  25174. /**
  25175. * Gets the number of facets in the mesh
  25176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25177. */
  25178. readonly facetNb: number;
  25179. /**
  25180. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25182. */
  25183. partitioningSubdivisions: number;
  25184. /**
  25185. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25186. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25188. */
  25189. partitioningBBoxRatio: number;
  25190. /**
  25191. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25192. * Works only for updatable meshes.
  25193. * Doesn't work with multi-materials
  25194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25195. */
  25196. mustDepthSortFacets: boolean;
  25197. /**
  25198. * The location (Vector3) where the facet depth sort must be computed from.
  25199. * By default, the active camera position.
  25200. * Used only when facet depth sort is enabled
  25201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25202. */
  25203. facetDepthSortFrom: Vector3;
  25204. /**
  25205. * gets a boolean indicating if facetData is enabled
  25206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25207. */
  25208. readonly isFacetDataEnabled: boolean;
  25209. /** @hidden */
  25210. _updateNonUniformScalingState(value: boolean): boolean;
  25211. /**
  25212. * An event triggered when this mesh collides with another one
  25213. */
  25214. onCollideObservable: Observable<AbstractMesh>;
  25215. /** Set a function to call when this mesh collides with another one */
  25216. onCollide: () => void;
  25217. /**
  25218. * An event triggered when the collision's position changes
  25219. */
  25220. onCollisionPositionChangeObservable: Observable<Vector3>;
  25221. /** Set a function to call when the collision's position changes */
  25222. onCollisionPositionChange: () => void;
  25223. /**
  25224. * An event triggered when material is changed
  25225. */
  25226. onMaterialChangedObservable: Observable<AbstractMesh>;
  25227. /**
  25228. * Gets or sets the orientation for POV movement & rotation
  25229. */
  25230. definedFacingForward: boolean;
  25231. /** @hidden */
  25232. _occlusionQuery: Nullable<WebGLQuery>;
  25233. /** @hidden */
  25234. _renderingGroup: Nullable<RenderingGroup>;
  25235. /**
  25236. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25237. */
  25238. /**
  25239. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25240. */
  25241. visibility: number;
  25242. /** Gets or sets the alpha index used to sort transparent meshes
  25243. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25244. */
  25245. alphaIndex: number;
  25246. /**
  25247. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25248. */
  25249. isVisible: boolean;
  25250. /**
  25251. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25252. */
  25253. isPickable: boolean;
  25254. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25255. showSubMeshesBoundingBox: boolean;
  25256. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25257. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25258. */
  25259. isBlocker: boolean;
  25260. /**
  25261. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25262. */
  25263. enablePointerMoveEvents: boolean;
  25264. /**
  25265. * Specifies the rendering group id for this mesh (0 by default)
  25266. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25267. */
  25268. renderingGroupId: number;
  25269. private _material;
  25270. /** Gets or sets current material */
  25271. material: Nullable<Material>;
  25272. /**
  25273. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25274. * @see http://doc.babylonjs.com/babylon101/shadows
  25275. */
  25276. receiveShadows: boolean;
  25277. /** Defines color to use when rendering outline */
  25278. outlineColor: Color3;
  25279. /** Define width to use when rendering outline */
  25280. outlineWidth: number;
  25281. /** Defines color to use when rendering overlay */
  25282. overlayColor: Color3;
  25283. /** Defines alpha to use when rendering overlay */
  25284. overlayAlpha: number;
  25285. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25286. hasVertexAlpha: boolean;
  25287. /** 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) */
  25288. useVertexColors: boolean;
  25289. /**
  25290. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25291. */
  25292. computeBonesUsingShaders: boolean;
  25293. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25294. numBoneInfluencers: number;
  25295. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25296. applyFog: boolean;
  25297. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25298. useOctreeForRenderingSelection: boolean;
  25299. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25300. useOctreeForPicking: boolean;
  25301. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25302. useOctreeForCollisions: boolean;
  25303. /**
  25304. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25305. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25306. */
  25307. layerMask: number;
  25308. /**
  25309. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25310. */
  25311. alwaysSelectAsActiveMesh: boolean;
  25312. /**
  25313. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25314. */
  25315. doNotSyncBoundingInfo: boolean;
  25316. /**
  25317. * Gets or sets the current action manager
  25318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25319. */
  25320. actionManager: Nullable<AbstractActionManager>;
  25321. private _meshCollisionData;
  25322. /**
  25323. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25325. */
  25326. ellipsoid: Vector3;
  25327. /**
  25328. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25329. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25330. */
  25331. ellipsoidOffset: Vector3;
  25332. /**
  25333. * Gets or sets a collision mask used to mask collisions (default is -1).
  25334. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25335. */
  25336. collisionMask: number;
  25337. /**
  25338. * Gets or sets the current collision group mask (-1 by default).
  25339. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25340. */
  25341. collisionGroup: number;
  25342. /**
  25343. * Defines edge width used when edgesRenderer is enabled
  25344. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25345. */
  25346. edgesWidth: number;
  25347. /**
  25348. * Defines edge color used when edgesRenderer is enabled
  25349. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25350. */
  25351. edgesColor: Color4;
  25352. /** @hidden */
  25353. _edgesRenderer: Nullable<IEdgesRenderer>;
  25354. /** @hidden */
  25355. _masterMesh: Nullable<AbstractMesh>;
  25356. /** @hidden */
  25357. _boundingInfo: Nullable<BoundingInfo>;
  25358. /** @hidden */
  25359. _renderId: number;
  25360. /**
  25361. * Gets or sets the list of subMeshes
  25362. * @see http://doc.babylonjs.com/how_to/multi_materials
  25363. */
  25364. subMeshes: SubMesh[];
  25365. /** @hidden */
  25366. _intersectionsInProgress: AbstractMesh[];
  25367. /** @hidden */
  25368. _unIndexed: boolean;
  25369. /** @hidden */
  25370. _lightSources: Light[];
  25371. /** Gets the list of lights affecting that mesh */
  25372. readonly lightSources: Light[];
  25373. /** @hidden */
  25374. readonly _positions: Nullable<Vector3[]>;
  25375. /** @hidden */
  25376. _waitingData: {
  25377. lods: Nullable<any>;
  25378. actions: Nullable<any>;
  25379. freezeWorldMatrix: Nullable<boolean>;
  25380. };
  25381. /** @hidden */
  25382. _bonesTransformMatrices: Nullable<Float32Array>;
  25383. /**
  25384. * Gets or sets a skeleton to apply skining transformations
  25385. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25386. */
  25387. skeleton: Nullable<Skeleton>;
  25388. /**
  25389. * An event triggered when the mesh is rebuilt.
  25390. */
  25391. onRebuildObservable: Observable<AbstractMesh>;
  25392. /**
  25393. * Creates a new AbstractMesh
  25394. * @param name defines the name of the mesh
  25395. * @param scene defines the hosting scene
  25396. */
  25397. constructor(name: string, scene?: Nullable<Scene>);
  25398. /**
  25399. * Returns the string "AbstractMesh"
  25400. * @returns "AbstractMesh"
  25401. */
  25402. getClassName(): string;
  25403. /**
  25404. * Gets a string representation of the current mesh
  25405. * @param fullDetails defines a boolean indicating if full details must be included
  25406. * @returns a string representation of the current mesh
  25407. */
  25408. toString(fullDetails?: boolean): string;
  25409. /**
  25410. * @hidden
  25411. */
  25412. protected _getEffectiveParent(): Nullable<Node>;
  25413. /** @hidden */
  25414. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25415. /** @hidden */
  25416. _rebuild(): void;
  25417. /** @hidden */
  25418. _resyncLightSources(): void;
  25419. /** @hidden */
  25420. _resyncLighSource(light: Light): void;
  25421. /** @hidden */
  25422. _unBindEffect(): void;
  25423. /** @hidden */
  25424. _removeLightSource(light: Light): void;
  25425. private _markSubMeshesAsDirty;
  25426. /** @hidden */
  25427. _markSubMeshesAsLightDirty(): void;
  25428. /** @hidden */
  25429. _markSubMeshesAsAttributesDirty(): void;
  25430. /** @hidden */
  25431. _markSubMeshesAsMiscDirty(): void;
  25432. /**
  25433. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25434. */
  25435. scaling: Vector3;
  25436. /**
  25437. * Returns true if the mesh is blocked. Implemented by child classes
  25438. */
  25439. readonly isBlocked: boolean;
  25440. /**
  25441. * Returns the mesh itself by default. Implemented by child classes
  25442. * @param camera defines the camera to use to pick the right LOD level
  25443. * @returns the currentAbstractMesh
  25444. */
  25445. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25446. /**
  25447. * Returns 0 by default. Implemented by child classes
  25448. * @returns an integer
  25449. */
  25450. getTotalVertices(): number;
  25451. /**
  25452. * Returns a positive integer : the total number of indices in this mesh geometry.
  25453. * @returns the numner of indices or zero if the mesh has no geometry.
  25454. */
  25455. getTotalIndices(): number;
  25456. /**
  25457. * Returns null by default. Implemented by child classes
  25458. * @returns null
  25459. */
  25460. getIndices(): Nullable<IndicesArray>;
  25461. /**
  25462. * Returns the array of the requested vertex data kind. Implemented by child classes
  25463. * @param kind defines the vertex data kind to use
  25464. * @returns null
  25465. */
  25466. getVerticesData(kind: string): Nullable<FloatArray>;
  25467. /**
  25468. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25469. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25470. * Note that a new underlying VertexBuffer object is created each call.
  25471. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25472. * @param kind defines vertex data kind:
  25473. * * VertexBuffer.PositionKind
  25474. * * VertexBuffer.UVKind
  25475. * * VertexBuffer.UV2Kind
  25476. * * VertexBuffer.UV3Kind
  25477. * * VertexBuffer.UV4Kind
  25478. * * VertexBuffer.UV5Kind
  25479. * * VertexBuffer.UV6Kind
  25480. * * VertexBuffer.ColorKind
  25481. * * VertexBuffer.MatricesIndicesKind
  25482. * * VertexBuffer.MatricesIndicesExtraKind
  25483. * * VertexBuffer.MatricesWeightsKind
  25484. * * VertexBuffer.MatricesWeightsExtraKind
  25485. * @param data defines the data source
  25486. * @param updatable defines if the data must be flagged as updatable (or static)
  25487. * @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
  25488. * @returns the current mesh
  25489. */
  25490. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25491. /**
  25492. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25493. * If the mesh has no geometry, it is simply returned as it is.
  25494. * @param kind defines vertex data kind:
  25495. * * VertexBuffer.PositionKind
  25496. * * VertexBuffer.UVKind
  25497. * * VertexBuffer.UV2Kind
  25498. * * VertexBuffer.UV3Kind
  25499. * * VertexBuffer.UV4Kind
  25500. * * VertexBuffer.UV5Kind
  25501. * * VertexBuffer.UV6Kind
  25502. * * VertexBuffer.ColorKind
  25503. * * VertexBuffer.MatricesIndicesKind
  25504. * * VertexBuffer.MatricesIndicesExtraKind
  25505. * * VertexBuffer.MatricesWeightsKind
  25506. * * VertexBuffer.MatricesWeightsExtraKind
  25507. * @param data defines the data source
  25508. * @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
  25509. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25510. * @returns the current mesh
  25511. */
  25512. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25513. /**
  25514. * Sets the mesh indices,
  25515. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25516. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25517. * @param totalVertices Defines the total number of vertices
  25518. * @returns the current mesh
  25519. */
  25520. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25521. /**
  25522. * Gets a boolean indicating if specific vertex data is present
  25523. * @param kind defines the vertex data kind to use
  25524. * @returns true is data kind is present
  25525. */
  25526. isVerticesDataPresent(kind: string): boolean;
  25527. /**
  25528. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25529. * @returns a BoundingInfo
  25530. */
  25531. getBoundingInfo(): BoundingInfo;
  25532. /**
  25533. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25534. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25535. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25536. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25537. * @returns the current mesh
  25538. */
  25539. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25540. /**
  25541. * Overwrite the current bounding info
  25542. * @param boundingInfo defines the new bounding info
  25543. * @returns the current mesh
  25544. */
  25545. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25546. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25547. readonly useBones: boolean;
  25548. /** @hidden */
  25549. _preActivate(): void;
  25550. /** @hidden */
  25551. _preActivateForIntermediateRendering(renderId: number): void;
  25552. /** @hidden */
  25553. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25554. /** @hidden */
  25555. _postActivate(): void;
  25556. /** @hidden */
  25557. _freeze(): void;
  25558. /** @hidden */
  25559. _unFreeze(): void;
  25560. /**
  25561. * Gets the current world matrix
  25562. * @returns a Matrix
  25563. */
  25564. getWorldMatrix(): Matrix;
  25565. /** @hidden */
  25566. _getWorldMatrixDeterminant(): number;
  25567. /**
  25568. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25569. */
  25570. readonly isAnInstance: boolean;
  25571. /**
  25572. * Perform relative position change from the point of view of behind the front of the mesh.
  25573. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25574. * Supports definition of mesh facing forward or backward
  25575. * @param amountRight defines the distance on the right axis
  25576. * @param amountUp defines the distance on the up axis
  25577. * @param amountForward defines the distance on the forward axis
  25578. * @returns the current mesh
  25579. */
  25580. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25581. /**
  25582. * Calculate relative position change from the point of view of behind the front of the mesh.
  25583. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25584. * Supports definition of mesh facing forward or backward
  25585. * @param amountRight defines the distance on the right axis
  25586. * @param amountUp defines the distance on the up axis
  25587. * @param amountForward defines the distance on the forward axis
  25588. * @returns the new displacement vector
  25589. */
  25590. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25591. /**
  25592. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25593. * Supports definition of mesh facing forward or backward
  25594. * @param flipBack defines the flip
  25595. * @param twirlClockwise defines the twirl
  25596. * @param tiltRight defines the tilt
  25597. * @returns the current mesh
  25598. */
  25599. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25600. /**
  25601. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25602. * Supports definition of mesh facing forward or backward.
  25603. * @param flipBack defines the flip
  25604. * @param twirlClockwise defines the twirl
  25605. * @param tiltRight defines the tilt
  25606. * @returns the new rotation vector
  25607. */
  25608. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25609. /**
  25610. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25611. * This means the mesh underlying bounding box and sphere are recomputed.
  25612. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25613. * @returns the current mesh
  25614. */
  25615. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25616. /** @hidden */
  25617. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25618. /** @hidden */
  25619. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25620. /** @hidden */
  25621. _updateBoundingInfo(): AbstractMesh;
  25622. /** @hidden */
  25623. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25624. /** @hidden */
  25625. protected _afterComputeWorldMatrix(): void;
  25626. /** @hidden */
  25627. readonly _effectiveMesh: AbstractMesh;
  25628. /**
  25629. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25630. * A mesh is in the frustum if its bounding box intersects the frustum
  25631. * @param frustumPlanes defines the frustum to test
  25632. * @returns true if the mesh is in the frustum planes
  25633. */
  25634. isInFrustum(frustumPlanes: Plane[]): boolean;
  25635. /**
  25636. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25637. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25638. * @param frustumPlanes defines the frustum to test
  25639. * @returns true if the mesh is completely in the frustum planes
  25640. */
  25641. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25642. /**
  25643. * True if the mesh intersects another mesh or a SolidParticle object
  25644. * @param mesh defines a target mesh or SolidParticle to test
  25645. * @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)
  25646. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25647. * @returns true if there is an intersection
  25648. */
  25649. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25650. /**
  25651. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25652. * @param point defines the point to test
  25653. * @returns true if there is an intersection
  25654. */
  25655. intersectsPoint(point: Vector3): boolean;
  25656. /**
  25657. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25658. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25659. */
  25660. checkCollisions: boolean;
  25661. /**
  25662. * Gets Collider object used to compute collisions (not physics)
  25663. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25664. */
  25665. readonly collider: Nullable<Collider>;
  25666. /**
  25667. * Move the mesh using collision engine
  25668. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25669. * @param displacement defines the requested displacement vector
  25670. * @returns the current mesh
  25671. */
  25672. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25673. private _onCollisionPositionChange;
  25674. /** @hidden */
  25675. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25676. /** @hidden */
  25677. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25678. /** @hidden */
  25679. _checkCollision(collider: Collider): AbstractMesh;
  25680. /** @hidden */
  25681. _generatePointsArray(): boolean;
  25682. /**
  25683. * Checks if the passed Ray intersects with the mesh
  25684. * @param ray defines the ray to use
  25685. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25686. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25687. * @returns the picking info
  25688. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25689. */
  25690. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25691. /**
  25692. * Clones the current mesh
  25693. * @param name defines the mesh name
  25694. * @param newParent defines the new mesh parent
  25695. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25696. * @returns the new mesh
  25697. */
  25698. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25699. /**
  25700. * Disposes all the submeshes of the current meshnp
  25701. * @returns the current mesh
  25702. */
  25703. releaseSubMeshes(): AbstractMesh;
  25704. /**
  25705. * Releases resources associated with this abstract mesh.
  25706. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25707. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25708. */
  25709. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25710. /**
  25711. * Adds the passed mesh as a child to the current mesh
  25712. * @param mesh defines the child mesh
  25713. * @returns the current mesh
  25714. */
  25715. addChild(mesh: AbstractMesh): AbstractMesh;
  25716. /**
  25717. * Removes the passed mesh from the current mesh children list
  25718. * @param mesh defines the child mesh
  25719. * @returns the current mesh
  25720. */
  25721. removeChild(mesh: AbstractMesh): AbstractMesh;
  25722. /** @hidden */
  25723. private _initFacetData;
  25724. /**
  25725. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25726. * This method can be called within the render loop.
  25727. * 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
  25728. * @returns the current mesh
  25729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25730. */
  25731. updateFacetData(): AbstractMesh;
  25732. /**
  25733. * Returns the facetLocalNormals array.
  25734. * The normals are expressed in the mesh local spac
  25735. * @returns an array of Vector3
  25736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25737. */
  25738. getFacetLocalNormals(): Vector3[];
  25739. /**
  25740. * Returns the facetLocalPositions array.
  25741. * The facet positions are expressed in the mesh local space
  25742. * @returns an array of Vector3
  25743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25744. */
  25745. getFacetLocalPositions(): Vector3[];
  25746. /**
  25747. * Returns the facetLocalPartioning array
  25748. * @returns an array of array of numbers
  25749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25750. */
  25751. getFacetLocalPartitioning(): number[][];
  25752. /**
  25753. * Returns the i-th facet position in the world system.
  25754. * This method allocates a new Vector3 per call
  25755. * @param i defines the facet index
  25756. * @returns a new Vector3
  25757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25758. */
  25759. getFacetPosition(i: number): Vector3;
  25760. /**
  25761. * Sets the reference Vector3 with the i-th facet position in the world system
  25762. * @param i defines the facet index
  25763. * @param ref defines the target vector
  25764. * @returns the current mesh
  25765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25766. */
  25767. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25768. /**
  25769. * Returns the i-th facet normal in the world system.
  25770. * This method allocates a new Vector3 per call
  25771. * @param i defines the facet index
  25772. * @returns a new Vector3
  25773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25774. */
  25775. getFacetNormal(i: number): Vector3;
  25776. /**
  25777. * Sets the reference Vector3 with the i-th facet normal in the world system
  25778. * @param i defines the facet index
  25779. * @param ref defines the target vector
  25780. * @returns the current mesh
  25781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25782. */
  25783. getFacetNormalToRef(i: number, ref: Vector3): this;
  25784. /**
  25785. * 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)
  25786. * @param x defines x coordinate
  25787. * @param y defines y coordinate
  25788. * @param z defines z coordinate
  25789. * @returns the array of facet indexes
  25790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25791. */
  25792. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25793. /**
  25794. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25795. * @param projected sets as the (x,y,z) world projection on the facet
  25796. * @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
  25797. * @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
  25798. * @param x defines x coordinate
  25799. * @param y defines y coordinate
  25800. * @param z defines z coordinate
  25801. * @returns the face index if found (or null instead)
  25802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25803. */
  25804. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25805. /**
  25806. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25807. * @param projected sets as the (x,y,z) local projection on the facet
  25808. * @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
  25809. * @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
  25810. * @param x defines x coordinate
  25811. * @param y defines y coordinate
  25812. * @param z defines z coordinate
  25813. * @returns the face index if found (or null instead)
  25814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25815. */
  25816. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25817. /**
  25818. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25819. * @returns the parameters
  25820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25821. */
  25822. getFacetDataParameters(): any;
  25823. /**
  25824. * Disables the feature FacetData and frees the related memory
  25825. * @returns the current mesh
  25826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25827. */
  25828. disableFacetData(): AbstractMesh;
  25829. /**
  25830. * Updates the AbstractMesh indices array
  25831. * @param indices defines the data source
  25832. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25833. * @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)
  25834. * @returns the current mesh
  25835. */
  25836. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25837. /**
  25838. * Creates new normals data for the mesh
  25839. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25840. * @returns the current mesh
  25841. */
  25842. createNormals(updatable: boolean): AbstractMesh;
  25843. /**
  25844. * Align the mesh with a normal
  25845. * @param normal defines the normal to use
  25846. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25847. * @returns the current mesh
  25848. */
  25849. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25850. /** @hidden */
  25851. _checkOcclusionQuery(): boolean;
  25852. /**
  25853. * Disables the mesh edge rendering mode
  25854. * @returns the currentAbstractMesh
  25855. */
  25856. disableEdgesRendering(): AbstractMesh;
  25857. /**
  25858. * Enables the edge rendering mode on the mesh.
  25859. * This mode makes the mesh edges visible
  25860. * @param epsilon defines the maximal distance between two angles to detect a face
  25861. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25862. * @returns the currentAbstractMesh
  25863. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25864. */
  25865. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25866. }
  25867. }
  25868. declare module "babylonjs/Actions/actionEvent" {
  25869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25870. import { Nullable } from "babylonjs/types";
  25871. import { Sprite } from "babylonjs/Sprites/sprite";
  25872. import { Scene } from "babylonjs/scene";
  25873. import { Vector2 } from "babylonjs/Maths/math";
  25874. /**
  25875. * Interface used to define ActionEvent
  25876. */
  25877. export interface IActionEvent {
  25878. /** The mesh or sprite that triggered the action */
  25879. source: any;
  25880. /** The X mouse cursor position at the time of the event */
  25881. pointerX: number;
  25882. /** The Y mouse cursor position at the time of the event */
  25883. pointerY: number;
  25884. /** The mesh that is currently pointed at (can be null) */
  25885. meshUnderPointer: Nullable<AbstractMesh>;
  25886. /** the original (browser) event that triggered the ActionEvent */
  25887. sourceEvent?: any;
  25888. /** additional data for the event */
  25889. additionalData?: any;
  25890. }
  25891. /**
  25892. * ActionEvent is the event being sent when an action is triggered.
  25893. */
  25894. export class ActionEvent implements IActionEvent {
  25895. /** The mesh or sprite that triggered the action */
  25896. source: any;
  25897. /** The X mouse cursor position at the time of the event */
  25898. pointerX: number;
  25899. /** The Y mouse cursor position at the time of the event */
  25900. pointerY: number;
  25901. /** The mesh that is currently pointed at (can be null) */
  25902. meshUnderPointer: Nullable<AbstractMesh>;
  25903. /** the original (browser) event that triggered the ActionEvent */
  25904. sourceEvent?: any;
  25905. /** additional data for the event */
  25906. additionalData?: any;
  25907. /**
  25908. * Creates a new ActionEvent
  25909. * @param source The mesh or sprite that triggered the action
  25910. * @param pointerX The X mouse cursor position at the time of the event
  25911. * @param pointerY The Y mouse cursor position at the time of the event
  25912. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25913. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25914. * @param additionalData additional data for the event
  25915. */
  25916. constructor(
  25917. /** The mesh or sprite that triggered the action */
  25918. source: any,
  25919. /** The X mouse cursor position at the time of the event */
  25920. pointerX: number,
  25921. /** The Y mouse cursor position at the time of the event */
  25922. pointerY: number,
  25923. /** The mesh that is currently pointed at (can be null) */
  25924. meshUnderPointer: Nullable<AbstractMesh>,
  25925. /** the original (browser) event that triggered the ActionEvent */
  25926. sourceEvent?: any,
  25927. /** additional data for the event */
  25928. additionalData?: any);
  25929. /**
  25930. * Helper function to auto-create an ActionEvent from a source mesh.
  25931. * @param source The source mesh that triggered the event
  25932. * @param evt The original (browser) event
  25933. * @param additionalData additional data for the event
  25934. * @returns the new ActionEvent
  25935. */
  25936. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25937. /**
  25938. * Helper function to auto-create an ActionEvent from a source sprite
  25939. * @param source The source sprite that triggered the event
  25940. * @param scene Scene associated with the sprite
  25941. * @param evt The original (browser) event
  25942. * @param additionalData additional data for the event
  25943. * @returns the new ActionEvent
  25944. */
  25945. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25946. /**
  25947. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25948. * @param scene the scene where the event occurred
  25949. * @param evt The original (browser) event
  25950. * @returns the new ActionEvent
  25951. */
  25952. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25953. /**
  25954. * Helper function to auto-create an ActionEvent from a primitive
  25955. * @param prim defines the target primitive
  25956. * @param pointerPos defines the pointer position
  25957. * @param evt The original (browser) event
  25958. * @param additionalData additional data for the event
  25959. * @returns the new ActionEvent
  25960. */
  25961. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25962. }
  25963. }
  25964. declare module "babylonjs/Actions/abstractActionManager" {
  25965. import { IDisposable } from "babylonjs/scene";
  25966. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25967. import { IAction } from "babylonjs/Actions/action";
  25968. import { Nullable } from "babylonjs/types";
  25969. /**
  25970. * Abstract class used to decouple action Manager from scene and meshes.
  25971. * Do not instantiate.
  25972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25973. */
  25974. export abstract class AbstractActionManager implements IDisposable {
  25975. /** Gets the list of active triggers */
  25976. static Triggers: {
  25977. [key: string]: number;
  25978. };
  25979. /** Gets the cursor to use when hovering items */
  25980. hoverCursor: string;
  25981. /** Gets the list of actions */
  25982. actions: IAction[];
  25983. /**
  25984. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25985. */
  25986. isRecursive: boolean;
  25987. /**
  25988. * Releases all associated resources
  25989. */
  25990. abstract dispose(): void;
  25991. /**
  25992. * Does this action manager has pointer triggers
  25993. */
  25994. abstract readonly hasPointerTriggers: boolean;
  25995. /**
  25996. * Does this action manager has pick triggers
  25997. */
  25998. abstract readonly hasPickTriggers: boolean;
  25999. /**
  26000. * Process a specific trigger
  26001. * @param trigger defines the trigger to process
  26002. * @param evt defines the event details to be processed
  26003. */
  26004. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26005. /**
  26006. * Does this action manager handles actions of any of the given triggers
  26007. * @param triggers defines the triggers to be tested
  26008. * @return a boolean indicating whether one (or more) of the triggers is handled
  26009. */
  26010. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26011. /**
  26012. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26013. * speed.
  26014. * @param triggerA defines the trigger to be tested
  26015. * @param triggerB defines the trigger to be tested
  26016. * @return a boolean indicating whether one (or more) of the triggers is handled
  26017. */
  26018. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26019. /**
  26020. * Does this action manager handles actions of a given trigger
  26021. * @param trigger defines the trigger to be tested
  26022. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26023. * @return whether the trigger is handled
  26024. */
  26025. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26026. /**
  26027. * Serialize this manager to a JSON object
  26028. * @param name defines the property name to store this manager
  26029. * @returns a JSON representation of this manager
  26030. */
  26031. abstract serialize(name: string): any;
  26032. /**
  26033. * Registers an action to this action manager
  26034. * @param action defines the action to be registered
  26035. * @return the action amended (prepared) after registration
  26036. */
  26037. abstract registerAction(action: IAction): Nullable<IAction>;
  26038. /**
  26039. * Unregisters an action to this action manager
  26040. * @param action defines the action to be unregistered
  26041. * @return a boolean indicating whether the action has been unregistered
  26042. */
  26043. abstract unregisterAction(action: IAction): Boolean;
  26044. /**
  26045. * Does exist one action manager with at least one trigger
  26046. **/
  26047. static readonly HasTriggers: boolean;
  26048. /**
  26049. * Does exist one action manager with at least one pick trigger
  26050. **/
  26051. static readonly HasPickTriggers: boolean;
  26052. /**
  26053. * Does exist one action manager that handles actions of a given trigger
  26054. * @param trigger defines the trigger to be tested
  26055. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26056. **/
  26057. static HasSpecificTrigger(trigger: number): boolean;
  26058. }
  26059. }
  26060. declare module "babylonjs/node" {
  26061. import { Scene } from "babylonjs/scene";
  26062. import { Nullable } from "babylonjs/types";
  26063. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26064. import { Engine } from "babylonjs/Engines/engine";
  26065. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26066. import { Observable } from "babylonjs/Misc/observable";
  26067. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26068. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26069. import { Animatable } from "babylonjs/Animations/animatable";
  26070. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26071. import { Animation } from "babylonjs/Animations/animation";
  26072. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26074. /**
  26075. * Defines how a node can be built from a string name.
  26076. */
  26077. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26078. /**
  26079. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26080. */
  26081. export class Node implements IBehaviorAware<Node> {
  26082. /** @hidden */
  26083. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26084. private static _NodeConstructors;
  26085. /**
  26086. * Add a new node constructor
  26087. * @param type defines the type name of the node to construct
  26088. * @param constructorFunc defines the constructor function
  26089. */
  26090. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26091. /**
  26092. * Returns a node constructor based on type name
  26093. * @param type defines the type name
  26094. * @param name defines the new node name
  26095. * @param scene defines the hosting scene
  26096. * @param options defines optional options to transmit to constructors
  26097. * @returns the new constructor or null
  26098. */
  26099. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26100. /**
  26101. * Gets or sets the name of the node
  26102. */
  26103. name: string;
  26104. /**
  26105. * Gets or sets the id of the node
  26106. */
  26107. id: string;
  26108. /**
  26109. * Gets or sets the unique id of the node
  26110. */
  26111. uniqueId: number;
  26112. /**
  26113. * Gets or sets a string used to store user defined state for the node
  26114. */
  26115. state: string;
  26116. /**
  26117. * Gets or sets an object used to store user defined information for the node
  26118. */
  26119. metadata: any;
  26120. /**
  26121. * For internal use only. Please do not use.
  26122. */
  26123. reservedDataStore: any;
  26124. /**
  26125. * List of inspectable custom properties (used by the Inspector)
  26126. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26127. */
  26128. inspectableCustomProperties: IInspectable[];
  26129. /**
  26130. * Gets or sets a boolean used to define if the node must be serialized
  26131. */
  26132. doNotSerialize: boolean;
  26133. /** @hidden */
  26134. _isDisposed: boolean;
  26135. /**
  26136. * Gets a list of Animations associated with the node
  26137. */
  26138. animations: import("babylonjs/Animations/animation").Animation[];
  26139. protected _ranges: {
  26140. [name: string]: Nullable<AnimationRange>;
  26141. };
  26142. /**
  26143. * Callback raised when the node is ready to be used
  26144. */
  26145. onReady: Nullable<(node: Node) => void>;
  26146. private _isEnabled;
  26147. private _isParentEnabled;
  26148. private _isReady;
  26149. /** @hidden */
  26150. _currentRenderId: number;
  26151. private _parentUpdateId;
  26152. /** @hidden */
  26153. _childUpdateId: number;
  26154. /** @hidden */
  26155. _waitingParentId: Nullable<string>;
  26156. /** @hidden */
  26157. _scene: Scene;
  26158. /** @hidden */
  26159. _cache: any;
  26160. private _parentNode;
  26161. private _children;
  26162. /** @hidden */
  26163. _worldMatrix: Matrix;
  26164. /** @hidden */
  26165. _worldMatrixDeterminant: number;
  26166. /** @hidden */
  26167. _worldMatrixDeterminantIsDirty: boolean;
  26168. /** @hidden */
  26169. private _sceneRootNodesIndex;
  26170. /**
  26171. * Gets a boolean indicating if the node has been disposed
  26172. * @returns true if the node was disposed
  26173. */
  26174. isDisposed(): boolean;
  26175. /**
  26176. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26177. * @see https://doc.babylonjs.com/how_to/parenting
  26178. */
  26179. parent: Nullable<Node>;
  26180. private addToSceneRootNodes;
  26181. private removeFromSceneRootNodes;
  26182. private _animationPropertiesOverride;
  26183. /**
  26184. * Gets or sets the animation properties override
  26185. */
  26186. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26187. /**
  26188. * Gets a string idenfifying the name of the class
  26189. * @returns "Node" string
  26190. */
  26191. getClassName(): string;
  26192. /** @hidden */
  26193. readonly _isNode: boolean;
  26194. /**
  26195. * An event triggered when the mesh is disposed
  26196. */
  26197. onDisposeObservable: Observable<Node>;
  26198. private _onDisposeObserver;
  26199. /**
  26200. * Sets a callback that will be raised when the node will be disposed
  26201. */
  26202. onDispose: () => void;
  26203. /**
  26204. * Creates a new Node
  26205. * @param name the name and id to be given to this node
  26206. * @param scene the scene this node will be added to
  26207. * @param addToRootNodes the node will be added to scene.rootNodes
  26208. */
  26209. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26210. /**
  26211. * Gets the scene of the node
  26212. * @returns a scene
  26213. */
  26214. getScene(): Scene;
  26215. /**
  26216. * Gets the engine of the node
  26217. * @returns a Engine
  26218. */
  26219. getEngine(): Engine;
  26220. private _behaviors;
  26221. /**
  26222. * Attach a behavior to the node
  26223. * @see http://doc.babylonjs.com/features/behaviour
  26224. * @param behavior defines the behavior to attach
  26225. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26226. * @returns the current Node
  26227. */
  26228. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26229. /**
  26230. * Remove an attached behavior
  26231. * @see http://doc.babylonjs.com/features/behaviour
  26232. * @param behavior defines the behavior to attach
  26233. * @returns the current Node
  26234. */
  26235. removeBehavior(behavior: Behavior<Node>): Node;
  26236. /**
  26237. * Gets the list of attached behaviors
  26238. * @see http://doc.babylonjs.com/features/behaviour
  26239. */
  26240. readonly behaviors: Behavior<Node>[];
  26241. /**
  26242. * Gets an attached behavior by name
  26243. * @param name defines the name of the behavior to look for
  26244. * @see http://doc.babylonjs.com/features/behaviour
  26245. * @returns null if behavior was not found else the requested behavior
  26246. */
  26247. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26248. /**
  26249. * Returns the latest update of the World matrix
  26250. * @returns a Matrix
  26251. */
  26252. getWorldMatrix(): Matrix;
  26253. /** @hidden */
  26254. _getWorldMatrixDeterminant(): number;
  26255. /**
  26256. * Returns directly the latest state of the mesh World matrix.
  26257. * A Matrix is returned.
  26258. */
  26259. readonly worldMatrixFromCache: Matrix;
  26260. /** @hidden */
  26261. _initCache(): void;
  26262. /** @hidden */
  26263. updateCache(force?: boolean): void;
  26264. /** @hidden */
  26265. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26266. /** @hidden */
  26267. _updateCache(ignoreParentClass?: boolean): void;
  26268. /** @hidden */
  26269. _isSynchronized(): boolean;
  26270. /** @hidden */
  26271. _markSyncedWithParent(): void;
  26272. /** @hidden */
  26273. isSynchronizedWithParent(): boolean;
  26274. /** @hidden */
  26275. isSynchronized(): boolean;
  26276. /**
  26277. * Is this node ready to be used/rendered
  26278. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26279. * @return true if the node is ready
  26280. */
  26281. isReady(completeCheck?: boolean): boolean;
  26282. /**
  26283. * Is this node enabled?
  26284. * 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
  26285. * @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
  26286. * @return whether this node (and its parent) is enabled
  26287. */
  26288. isEnabled(checkAncestors?: boolean): boolean;
  26289. /** @hidden */
  26290. protected _syncParentEnabledState(): void;
  26291. /**
  26292. * Set the enabled state of this node
  26293. * @param value defines the new enabled state
  26294. */
  26295. setEnabled(value: boolean): void;
  26296. /**
  26297. * Is this node a descendant of the given node?
  26298. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26299. * @param ancestor defines the parent node to inspect
  26300. * @returns a boolean indicating if this node is a descendant of the given node
  26301. */
  26302. isDescendantOf(ancestor: Node): boolean;
  26303. /** @hidden */
  26304. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26305. /**
  26306. * Will return all nodes that have this node as ascendant
  26307. * @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
  26308. * @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
  26309. * @return all children nodes of all types
  26310. */
  26311. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26312. /**
  26313. * Get all child-meshes of this node
  26314. * @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)
  26315. * @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
  26316. * @returns an array of AbstractMesh
  26317. */
  26318. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26319. /**
  26320. * Get all direct children of this node
  26321. * @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
  26322. * @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)
  26323. * @returns an array of Node
  26324. */
  26325. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26326. /** @hidden */
  26327. _setReady(state: boolean): void;
  26328. /**
  26329. * Get an animation by name
  26330. * @param name defines the name of the animation to look for
  26331. * @returns null if not found else the requested animation
  26332. */
  26333. getAnimationByName(name: string): Nullable<Animation>;
  26334. /**
  26335. * Creates an animation range for this node
  26336. * @param name defines the name of the range
  26337. * @param from defines the starting key
  26338. * @param to defines the end key
  26339. */
  26340. createAnimationRange(name: string, from: number, to: number): void;
  26341. /**
  26342. * Delete a specific animation range
  26343. * @param name defines the name of the range to delete
  26344. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26345. */
  26346. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26347. /**
  26348. * Get an animation range by name
  26349. * @param name defines the name of the animation range to look for
  26350. * @returns null if not found else the requested animation range
  26351. */
  26352. getAnimationRange(name: string): Nullable<AnimationRange>;
  26353. /**
  26354. * Gets the list of all animation ranges defined on this node
  26355. * @returns an array
  26356. */
  26357. getAnimationRanges(): Nullable<AnimationRange>[];
  26358. /**
  26359. * Will start the animation sequence
  26360. * @param name defines the range frames for animation sequence
  26361. * @param loop defines if the animation should loop (false by default)
  26362. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26363. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26364. * @returns the object created for this animation. If range does not exist, it will return null
  26365. */
  26366. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26367. /**
  26368. * Serialize animation ranges into a JSON compatible object
  26369. * @returns serialization object
  26370. */
  26371. serializeAnimationRanges(): any;
  26372. /**
  26373. * Computes the world matrix of the node
  26374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26375. * @returns the world matrix
  26376. */
  26377. computeWorldMatrix(force?: boolean): Matrix;
  26378. /**
  26379. * Releases resources associated with this node.
  26380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26382. */
  26383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26384. /**
  26385. * Parse animation range data from a serialization object and store them into a given node
  26386. * @param node defines where to store the animation ranges
  26387. * @param parsedNode defines the serialization object to read data from
  26388. * @param scene defines the hosting scene
  26389. */
  26390. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26391. /**
  26392. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26393. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26394. * @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
  26395. * @returns the new bounding vectors
  26396. */
  26397. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26398. min: Vector3;
  26399. max: Vector3;
  26400. };
  26401. }
  26402. }
  26403. declare module "babylonjs/Animations/animation" {
  26404. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26405. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26406. import { Nullable } from "babylonjs/types";
  26407. import { Scene } from "babylonjs/scene";
  26408. import { IAnimatable } from "babylonjs/Misc/tools";
  26409. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26410. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26411. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26412. import { Node } from "babylonjs/node";
  26413. import { Animatable } from "babylonjs/Animations/animatable";
  26414. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26415. /**
  26416. * @hidden
  26417. */
  26418. export class _IAnimationState {
  26419. key: number;
  26420. repeatCount: number;
  26421. workValue?: any;
  26422. loopMode?: number;
  26423. offsetValue?: any;
  26424. highLimitValue?: any;
  26425. }
  26426. /**
  26427. * Class used to store any kind of animation
  26428. */
  26429. export class Animation {
  26430. /**Name of the animation */
  26431. name: string;
  26432. /**Property to animate */
  26433. targetProperty: string;
  26434. /**The frames per second of the animation */
  26435. framePerSecond: number;
  26436. /**The data type of the animation */
  26437. dataType: number;
  26438. /**The loop mode of the animation */
  26439. loopMode?: number | undefined;
  26440. /**Specifies if blending should be enabled */
  26441. enableBlending?: boolean | undefined;
  26442. /**
  26443. * Use matrix interpolation instead of using direct key value when animating matrices
  26444. */
  26445. static AllowMatricesInterpolation: boolean;
  26446. /**
  26447. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26448. */
  26449. static AllowMatrixDecomposeForInterpolation: boolean;
  26450. /**
  26451. * Stores the key frames of the animation
  26452. */
  26453. private _keys;
  26454. /**
  26455. * Stores the easing function of the animation
  26456. */
  26457. private _easingFunction;
  26458. /**
  26459. * @hidden Internal use only
  26460. */
  26461. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26462. /**
  26463. * The set of event that will be linked to this animation
  26464. */
  26465. private _events;
  26466. /**
  26467. * Stores an array of target property paths
  26468. */
  26469. targetPropertyPath: string[];
  26470. /**
  26471. * Stores the blending speed of the animation
  26472. */
  26473. blendingSpeed: number;
  26474. /**
  26475. * Stores the animation ranges for the animation
  26476. */
  26477. private _ranges;
  26478. /**
  26479. * @hidden Internal use
  26480. */
  26481. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26482. /**
  26483. * Sets up an animation
  26484. * @param property The property to animate
  26485. * @param animationType The animation type to apply
  26486. * @param framePerSecond The frames per second of the animation
  26487. * @param easingFunction The easing function used in the animation
  26488. * @returns The created animation
  26489. */
  26490. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26491. /**
  26492. * Create and start an animation on a node
  26493. * @param name defines the name of the global animation that will be run on all nodes
  26494. * @param node defines the root node where the animation will take place
  26495. * @param targetProperty defines property to animate
  26496. * @param framePerSecond defines the number of frame per second yo use
  26497. * @param totalFrame defines the number of frames in total
  26498. * @param from defines the initial value
  26499. * @param to defines the final value
  26500. * @param loopMode defines which loop mode you want to use (off by default)
  26501. * @param easingFunction defines the easing function to use (linear by default)
  26502. * @param onAnimationEnd defines the callback to call when animation end
  26503. * @returns the animatable created for this animation
  26504. */
  26505. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26506. /**
  26507. * Create and start an animation on a node and its descendants
  26508. * @param name defines the name of the global animation that will be run on all nodes
  26509. * @param node defines the root node where the animation will take place
  26510. * @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
  26511. * @param targetProperty defines property to animate
  26512. * @param framePerSecond defines the number of frame per second to use
  26513. * @param totalFrame defines the number of frames in total
  26514. * @param from defines the initial value
  26515. * @param to defines the final value
  26516. * @param loopMode defines which loop mode you want to use (off by default)
  26517. * @param easingFunction defines the easing function to use (linear by default)
  26518. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26519. * @returns the list of animatables created for all nodes
  26520. * @example https://www.babylonjs-playground.com/#MH0VLI
  26521. */
  26522. 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[]>;
  26523. /**
  26524. * Creates a new animation, merges it with the existing animations and starts it
  26525. * @param name Name of the animation
  26526. * @param node Node which contains the scene that begins the animations
  26527. * @param targetProperty Specifies which property to animate
  26528. * @param framePerSecond The frames per second of the animation
  26529. * @param totalFrame The total number of frames
  26530. * @param from The frame at the beginning of the animation
  26531. * @param to The frame at the end of the animation
  26532. * @param loopMode Specifies the loop mode of the animation
  26533. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26534. * @param onAnimationEnd Callback to run once the animation is complete
  26535. * @returns Nullable animation
  26536. */
  26537. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26538. /**
  26539. * Transition property of an host to the target Value
  26540. * @param property The property to transition
  26541. * @param targetValue The target Value of the property
  26542. * @param host The object where the property to animate belongs
  26543. * @param scene Scene used to run the animation
  26544. * @param frameRate Framerate (in frame/s) to use
  26545. * @param transition The transition type we want to use
  26546. * @param duration The duration of the animation, in milliseconds
  26547. * @param onAnimationEnd Callback trigger at the end of the animation
  26548. * @returns Nullable animation
  26549. */
  26550. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26551. /**
  26552. * Return the array of runtime animations currently using this animation
  26553. */
  26554. readonly runtimeAnimations: RuntimeAnimation[];
  26555. /**
  26556. * Specifies if any of the runtime animations are currently running
  26557. */
  26558. readonly hasRunningRuntimeAnimations: boolean;
  26559. /**
  26560. * Initializes the animation
  26561. * @param name Name of the animation
  26562. * @param targetProperty Property to animate
  26563. * @param framePerSecond The frames per second of the animation
  26564. * @param dataType The data type of the animation
  26565. * @param loopMode The loop mode of the animation
  26566. * @param enableBlending Specifies if blending should be enabled
  26567. */
  26568. constructor(
  26569. /**Name of the animation */
  26570. name: string,
  26571. /**Property to animate */
  26572. targetProperty: string,
  26573. /**The frames per second of the animation */
  26574. framePerSecond: number,
  26575. /**The data type of the animation */
  26576. dataType: number,
  26577. /**The loop mode of the animation */
  26578. loopMode?: number | undefined,
  26579. /**Specifies if blending should be enabled */
  26580. enableBlending?: boolean | undefined);
  26581. /**
  26582. * Converts the animation to a string
  26583. * @param fullDetails support for multiple levels of logging within scene loading
  26584. * @returns String form of the animation
  26585. */
  26586. toString(fullDetails?: boolean): string;
  26587. /**
  26588. * Add an event to this animation
  26589. * @param event Event to add
  26590. */
  26591. addEvent(event: AnimationEvent): void;
  26592. /**
  26593. * Remove all events found at the given frame
  26594. * @param frame The frame to remove events from
  26595. */
  26596. removeEvents(frame: number): void;
  26597. /**
  26598. * Retrieves all the events from the animation
  26599. * @returns Events from the animation
  26600. */
  26601. getEvents(): AnimationEvent[];
  26602. /**
  26603. * Creates an animation range
  26604. * @param name Name of the animation range
  26605. * @param from Starting frame of the animation range
  26606. * @param to Ending frame of the animation
  26607. */
  26608. createRange(name: string, from: number, to: number): void;
  26609. /**
  26610. * Deletes an animation range by name
  26611. * @param name Name of the animation range to delete
  26612. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26613. */
  26614. deleteRange(name: string, deleteFrames?: boolean): void;
  26615. /**
  26616. * Gets the animation range by name, or null if not defined
  26617. * @param name Name of the animation range
  26618. * @returns Nullable animation range
  26619. */
  26620. getRange(name: string): Nullable<AnimationRange>;
  26621. /**
  26622. * Gets the key frames from the animation
  26623. * @returns The key frames of the animation
  26624. */
  26625. getKeys(): Array<IAnimationKey>;
  26626. /**
  26627. * Gets the highest frame rate of the animation
  26628. * @returns Highest frame rate of the animation
  26629. */
  26630. getHighestFrame(): number;
  26631. /**
  26632. * Gets the easing function of the animation
  26633. * @returns Easing function of the animation
  26634. */
  26635. getEasingFunction(): IEasingFunction;
  26636. /**
  26637. * Sets the easing function of the animation
  26638. * @param easingFunction A custom mathematical formula for animation
  26639. */
  26640. setEasingFunction(easingFunction: EasingFunction): void;
  26641. /**
  26642. * Interpolates a scalar linearly
  26643. * @param startValue Start value of the animation curve
  26644. * @param endValue End value of the animation curve
  26645. * @param gradient Scalar amount to interpolate
  26646. * @returns Interpolated scalar value
  26647. */
  26648. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26649. /**
  26650. * Interpolates a scalar cubically
  26651. * @param startValue Start value of the animation curve
  26652. * @param outTangent End tangent of the animation
  26653. * @param endValue End value of the animation curve
  26654. * @param inTangent Start tangent of the animation curve
  26655. * @param gradient Scalar amount to interpolate
  26656. * @returns Interpolated scalar value
  26657. */
  26658. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26659. /**
  26660. * Interpolates a quaternion using a spherical linear interpolation
  26661. * @param startValue Start value of the animation curve
  26662. * @param endValue End value of the animation curve
  26663. * @param gradient Scalar amount to interpolate
  26664. * @returns Interpolated quaternion value
  26665. */
  26666. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26667. /**
  26668. * Interpolates a quaternion cubically
  26669. * @param startValue Start value of the animation curve
  26670. * @param outTangent End tangent of the animation curve
  26671. * @param endValue End value of the animation curve
  26672. * @param inTangent Start tangent of the animation curve
  26673. * @param gradient Scalar amount to interpolate
  26674. * @returns Interpolated quaternion value
  26675. */
  26676. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26677. /**
  26678. * Interpolates a Vector3 linearl
  26679. * @param startValue Start value of the animation curve
  26680. * @param endValue End value of the animation curve
  26681. * @param gradient Scalar amount to interpolate
  26682. * @returns Interpolated scalar value
  26683. */
  26684. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26685. /**
  26686. * Interpolates a Vector3 cubically
  26687. * @param startValue Start value of the animation curve
  26688. * @param outTangent End tangent of the animation
  26689. * @param endValue End value of the animation curve
  26690. * @param inTangent Start tangent of the animation curve
  26691. * @param gradient Scalar amount to interpolate
  26692. * @returns InterpolatedVector3 value
  26693. */
  26694. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26695. /**
  26696. * Interpolates a Vector2 linearly
  26697. * @param startValue Start value of the animation curve
  26698. * @param endValue End value of the animation curve
  26699. * @param gradient Scalar amount to interpolate
  26700. * @returns Interpolated Vector2 value
  26701. */
  26702. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26703. /**
  26704. * Interpolates a Vector2 cubically
  26705. * @param startValue Start value of the animation curve
  26706. * @param outTangent End tangent of the animation
  26707. * @param endValue End value of the animation curve
  26708. * @param inTangent Start tangent of the animation curve
  26709. * @param gradient Scalar amount to interpolate
  26710. * @returns Interpolated Vector2 value
  26711. */
  26712. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26713. /**
  26714. * Interpolates a size linearly
  26715. * @param startValue Start value of the animation curve
  26716. * @param endValue End value of the animation curve
  26717. * @param gradient Scalar amount to interpolate
  26718. * @returns Interpolated Size value
  26719. */
  26720. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26721. /**
  26722. * Interpolates a Color3 linearly
  26723. * @param startValue Start value of the animation curve
  26724. * @param endValue End value of the animation curve
  26725. * @param gradient Scalar amount to interpolate
  26726. * @returns Interpolated Color3 value
  26727. */
  26728. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26729. /**
  26730. * @hidden Internal use only
  26731. */
  26732. _getKeyValue(value: any): any;
  26733. /**
  26734. * @hidden Internal use only
  26735. */
  26736. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26737. /**
  26738. * Defines the function to use to interpolate matrices
  26739. * @param startValue defines the start matrix
  26740. * @param endValue defines the end matrix
  26741. * @param gradient defines the gradient between both matrices
  26742. * @param result defines an optional target matrix where to store the interpolation
  26743. * @returns the interpolated matrix
  26744. */
  26745. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26746. /**
  26747. * Makes a copy of the animation
  26748. * @returns Cloned animation
  26749. */
  26750. clone(): Animation;
  26751. /**
  26752. * Sets the key frames of the animation
  26753. * @param values The animation key frames to set
  26754. */
  26755. setKeys(values: Array<IAnimationKey>): void;
  26756. /**
  26757. * Serializes the animation to an object
  26758. * @returns Serialized object
  26759. */
  26760. serialize(): any;
  26761. /**
  26762. * Float animation type
  26763. */
  26764. private static _ANIMATIONTYPE_FLOAT;
  26765. /**
  26766. * Vector3 animation type
  26767. */
  26768. private static _ANIMATIONTYPE_VECTOR3;
  26769. /**
  26770. * Quaternion animation type
  26771. */
  26772. private static _ANIMATIONTYPE_QUATERNION;
  26773. /**
  26774. * Matrix animation type
  26775. */
  26776. private static _ANIMATIONTYPE_MATRIX;
  26777. /**
  26778. * Color3 animation type
  26779. */
  26780. private static _ANIMATIONTYPE_COLOR3;
  26781. /**
  26782. * Vector2 animation type
  26783. */
  26784. private static _ANIMATIONTYPE_VECTOR2;
  26785. /**
  26786. * Size animation type
  26787. */
  26788. private static _ANIMATIONTYPE_SIZE;
  26789. /**
  26790. * Relative Loop Mode
  26791. */
  26792. private static _ANIMATIONLOOPMODE_RELATIVE;
  26793. /**
  26794. * Cycle Loop Mode
  26795. */
  26796. private static _ANIMATIONLOOPMODE_CYCLE;
  26797. /**
  26798. * Constant Loop Mode
  26799. */
  26800. private static _ANIMATIONLOOPMODE_CONSTANT;
  26801. /**
  26802. * Get the float animation type
  26803. */
  26804. static readonly ANIMATIONTYPE_FLOAT: number;
  26805. /**
  26806. * Get the Vector3 animation type
  26807. */
  26808. static readonly ANIMATIONTYPE_VECTOR3: number;
  26809. /**
  26810. * Get the Vector2 animation type
  26811. */
  26812. static readonly ANIMATIONTYPE_VECTOR2: number;
  26813. /**
  26814. * Get the Size animation type
  26815. */
  26816. static readonly ANIMATIONTYPE_SIZE: number;
  26817. /**
  26818. * Get the Quaternion animation type
  26819. */
  26820. static readonly ANIMATIONTYPE_QUATERNION: number;
  26821. /**
  26822. * Get the Matrix animation type
  26823. */
  26824. static readonly ANIMATIONTYPE_MATRIX: number;
  26825. /**
  26826. * Get the Color3 animation type
  26827. */
  26828. static readonly ANIMATIONTYPE_COLOR3: number;
  26829. /**
  26830. * Get the Relative Loop Mode
  26831. */
  26832. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26833. /**
  26834. * Get the Cycle Loop Mode
  26835. */
  26836. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26837. /**
  26838. * Get the Constant Loop Mode
  26839. */
  26840. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26841. /** @hidden */
  26842. static _UniversalLerp(left: any, right: any, amount: number): any;
  26843. /**
  26844. * Parses an animation object and creates an animation
  26845. * @param parsedAnimation Parsed animation object
  26846. * @returns Animation object
  26847. */
  26848. static Parse(parsedAnimation: any): Animation;
  26849. /**
  26850. * Appends the serialized animations from the source animations
  26851. * @param source Source containing the animations
  26852. * @param destination Target to store the animations
  26853. */
  26854. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26855. }
  26856. }
  26857. declare module "babylonjs/Materials/Textures/baseTexture" {
  26858. import { Observable } from "babylonjs/Misc/observable";
  26859. import { IAnimatable } from "babylonjs/Misc/tools";
  26860. import { Nullable } from "babylonjs/types";
  26861. import { Scene } from "babylonjs/scene";
  26862. import { Matrix, ISize } from "babylonjs/Maths/math";
  26863. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26864. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26865. /**
  26866. * Base class of all the textures in babylon.
  26867. * It groups all the common properties the materials, post process, lights... might need
  26868. * in order to make a correct use of the texture.
  26869. */
  26870. export class BaseTexture implements IAnimatable {
  26871. /**
  26872. * Default anisotropic filtering level for the application.
  26873. * It is set to 4 as a good tradeoff between perf and quality.
  26874. */
  26875. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26876. /**
  26877. * Gets or sets the unique id of the texture
  26878. */
  26879. uniqueId: number;
  26880. /**
  26881. * Define the name of the texture.
  26882. */
  26883. name: string;
  26884. /**
  26885. * Gets or sets an object used to store user defined information.
  26886. */
  26887. metadata: any;
  26888. /**
  26889. * For internal use only. Please do not use.
  26890. */
  26891. reservedDataStore: any;
  26892. private _hasAlpha;
  26893. /**
  26894. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26895. */
  26896. hasAlpha: boolean;
  26897. /**
  26898. * Defines if the alpha value should be determined via the rgb values.
  26899. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26900. */
  26901. getAlphaFromRGB: boolean;
  26902. /**
  26903. * Intensity or strength of the texture.
  26904. * It is commonly used by materials to fine tune the intensity of the texture
  26905. */
  26906. level: number;
  26907. /**
  26908. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26909. * This is part of the texture as textures usually maps to one uv set.
  26910. */
  26911. coordinatesIndex: number;
  26912. private _coordinatesMode;
  26913. /**
  26914. * How a texture is mapped.
  26915. *
  26916. * | Value | Type | Description |
  26917. * | ----- | ----------------------------------- | ----------- |
  26918. * | 0 | EXPLICIT_MODE | |
  26919. * | 1 | SPHERICAL_MODE | |
  26920. * | 2 | PLANAR_MODE | |
  26921. * | 3 | CUBIC_MODE | |
  26922. * | 4 | PROJECTION_MODE | |
  26923. * | 5 | SKYBOX_MODE | |
  26924. * | 6 | INVCUBIC_MODE | |
  26925. * | 7 | EQUIRECTANGULAR_MODE | |
  26926. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26927. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26928. */
  26929. coordinatesMode: number;
  26930. /**
  26931. * | Value | Type | Description |
  26932. * | ----- | ------------------ | ----------- |
  26933. * | 0 | CLAMP_ADDRESSMODE | |
  26934. * | 1 | WRAP_ADDRESSMODE | |
  26935. * | 2 | MIRROR_ADDRESSMODE | |
  26936. */
  26937. wrapU: number;
  26938. /**
  26939. * | Value | Type | Description |
  26940. * | ----- | ------------------ | ----------- |
  26941. * | 0 | CLAMP_ADDRESSMODE | |
  26942. * | 1 | WRAP_ADDRESSMODE | |
  26943. * | 2 | MIRROR_ADDRESSMODE | |
  26944. */
  26945. wrapV: number;
  26946. /**
  26947. * | Value | Type | Description |
  26948. * | ----- | ------------------ | ----------- |
  26949. * | 0 | CLAMP_ADDRESSMODE | |
  26950. * | 1 | WRAP_ADDRESSMODE | |
  26951. * | 2 | MIRROR_ADDRESSMODE | |
  26952. */
  26953. wrapR: number;
  26954. /**
  26955. * With compliant hardware and browser (supporting anisotropic filtering)
  26956. * this defines the level of anisotropic filtering in the texture.
  26957. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26958. */
  26959. anisotropicFilteringLevel: number;
  26960. /**
  26961. * Define if the texture is a cube texture or if false a 2d texture.
  26962. */
  26963. isCube: boolean;
  26964. /**
  26965. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26966. */
  26967. is3D: boolean;
  26968. /**
  26969. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26970. * HDR texture are usually stored in linear space.
  26971. * This only impacts the PBR and Background materials
  26972. */
  26973. gammaSpace: boolean;
  26974. /**
  26975. * Gets whether or not the texture contains RGBD data.
  26976. */
  26977. readonly isRGBD: boolean;
  26978. /**
  26979. * Is Z inverted in the texture (useful in a cube texture).
  26980. */
  26981. invertZ: boolean;
  26982. /**
  26983. * Are mip maps generated for this texture or not.
  26984. */
  26985. readonly noMipmap: boolean;
  26986. /**
  26987. * @hidden
  26988. */
  26989. lodLevelInAlpha: boolean;
  26990. /**
  26991. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26992. */
  26993. lodGenerationOffset: number;
  26994. /**
  26995. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26996. */
  26997. lodGenerationScale: number;
  26998. /**
  26999. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27000. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27001. * average roughness values.
  27002. */
  27003. linearSpecularLOD: boolean;
  27004. /**
  27005. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27006. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27007. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27008. */
  27009. irradianceTexture: Nullable<BaseTexture>;
  27010. /**
  27011. * Define if the texture is a render target.
  27012. */
  27013. isRenderTarget: boolean;
  27014. /**
  27015. * Define the unique id of the texture in the scene.
  27016. */
  27017. readonly uid: string;
  27018. /**
  27019. * Return a string representation of the texture.
  27020. * @returns the texture as a string
  27021. */
  27022. toString(): string;
  27023. /**
  27024. * Get the class name of the texture.
  27025. * @returns "BaseTexture"
  27026. */
  27027. getClassName(): string;
  27028. /**
  27029. * Define the list of animation attached to the texture.
  27030. */
  27031. animations: import("babylonjs/Animations/animation").Animation[];
  27032. /**
  27033. * An event triggered when the texture is disposed.
  27034. */
  27035. onDisposeObservable: Observable<BaseTexture>;
  27036. private _onDisposeObserver;
  27037. /**
  27038. * Callback triggered when the texture has been disposed.
  27039. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27040. */
  27041. onDispose: () => void;
  27042. /**
  27043. * Define the current state of the loading sequence when in delayed load mode.
  27044. */
  27045. delayLoadState: number;
  27046. private _scene;
  27047. /** @hidden */
  27048. _texture: Nullable<InternalTexture>;
  27049. private _uid;
  27050. /**
  27051. * Define if the texture is preventinga material to render or not.
  27052. * If not and the texture is not ready, the engine will use a default black texture instead.
  27053. */
  27054. readonly isBlocking: boolean;
  27055. /**
  27056. * Instantiates a new BaseTexture.
  27057. * Base class of all the textures in babylon.
  27058. * It groups all the common properties the materials, post process, lights... might need
  27059. * in order to make a correct use of the texture.
  27060. * @param scene Define the scene the texture blongs to
  27061. */
  27062. constructor(scene: Nullable<Scene>);
  27063. /**
  27064. * Get the scene the texture belongs to.
  27065. * @returns the scene or null if undefined
  27066. */
  27067. getScene(): Nullable<Scene>;
  27068. /**
  27069. * Get the texture transform matrix used to offset tile the texture for istance.
  27070. * @returns the transformation matrix
  27071. */
  27072. getTextureMatrix(): Matrix;
  27073. /**
  27074. * Get the texture reflection matrix used to rotate/transform the reflection.
  27075. * @returns the reflection matrix
  27076. */
  27077. getReflectionTextureMatrix(): Matrix;
  27078. /**
  27079. * Get the underlying lower level texture from Babylon.
  27080. * @returns the insternal texture
  27081. */
  27082. getInternalTexture(): Nullable<InternalTexture>;
  27083. /**
  27084. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27085. * @returns true if ready or not blocking
  27086. */
  27087. isReadyOrNotBlocking(): boolean;
  27088. /**
  27089. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27090. * @returns true if fully ready
  27091. */
  27092. isReady(): boolean;
  27093. private _cachedSize;
  27094. /**
  27095. * Get the size of the texture.
  27096. * @returns the texture size.
  27097. */
  27098. getSize(): ISize;
  27099. /**
  27100. * Get the base size of the texture.
  27101. * It can be different from the size if the texture has been resized for POT for instance
  27102. * @returns the base size
  27103. */
  27104. getBaseSize(): ISize;
  27105. /**
  27106. * Update the sampling mode of the texture.
  27107. * Default is Trilinear mode.
  27108. *
  27109. * | Value | Type | Description |
  27110. * | ----- | ------------------ | ----------- |
  27111. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27112. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27113. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27114. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27115. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27116. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27117. * | 7 | NEAREST_LINEAR | |
  27118. * | 8 | NEAREST_NEAREST | |
  27119. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27120. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27121. * | 11 | LINEAR_LINEAR | |
  27122. * | 12 | LINEAR_NEAREST | |
  27123. *
  27124. * > _mag_: magnification filter (close to the viewer)
  27125. * > _min_: minification filter (far from the viewer)
  27126. * > _mip_: filter used between mip map levels
  27127. *@param samplingMode Define the new sampling mode of the texture
  27128. */
  27129. updateSamplingMode(samplingMode: number): void;
  27130. /**
  27131. * Scales the texture if is `canRescale()`
  27132. * @param ratio the resize factor we want to use to rescale
  27133. */
  27134. scale(ratio: number): void;
  27135. /**
  27136. * Get if the texture can rescale.
  27137. */
  27138. readonly canRescale: boolean;
  27139. /** @hidden */
  27140. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27141. /** @hidden */
  27142. _rebuild(): void;
  27143. /**
  27144. * Triggers the load sequence in delayed load mode.
  27145. */
  27146. delayLoad(): void;
  27147. /**
  27148. * Clones the texture.
  27149. * @returns the cloned texture
  27150. */
  27151. clone(): Nullable<BaseTexture>;
  27152. /**
  27153. * Get the texture underlying type (INT, FLOAT...)
  27154. */
  27155. readonly textureType: number;
  27156. /**
  27157. * Get the texture underlying format (RGB, RGBA...)
  27158. */
  27159. readonly textureFormat: number;
  27160. /**
  27161. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27162. * This will returns an RGBA array buffer containing either in values (0-255) or
  27163. * float values (0-1) depending of the underlying buffer type.
  27164. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27165. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27166. * @param buffer defines a user defined buffer to fill with data (can be null)
  27167. * @returns The Array buffer containing the pixels data.
  27168. */
  27169. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27170. /**
  27171. * Release and destroy the underlying lower level texture aka internalTexture.
  27172. */
  27173. releaseInternalTexture(): void;
  27174. /**
  27175. * Get the polynomial representation of the texture data.
  27176. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27177. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27178. */
  27179. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27180. /** @hidden */
  27181. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27182. /** @hidden */
  27183. readonly _lodTextureMid: Nullable<BaseTexture>;
  27184. /** @hidden */
  27185. readonly _lodTextureLow: Nullable<BaseTexture>;
  27186. /**
  27187. * Dispose the texture and release its associated resources.
  27188. */
  27189. dispose(): void;
  27190. /**
  27191. * Serialize the texture into a JSON representation that can be parsed later on.
  27192. * @returns the JSON representation of the texture
  27193. */
  27194. serialize(): any;
  27195. /**
  27196. * Helper function to be called back once a list of texture contains only ready textures.
  27197. * @param textures Define the list of textures to wait for
  27198. * @param callback Define the callback triggered once the entire list will be ready
  27199. */
  27200. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27201. }
  27202. }
  27203. declare module "babylonjs/Materials/uniformBuffer" {
  27204. import { Nullable, FloatArray } from "babylonjs/types";
  27205. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27206. import { Engine } from "babylonjs/Engines/engine";
  27207. import { Effect } from "babylonjs/Materials/effect";
  27208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27209. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27210. /**
  27211. * Uniform buffer objects.
  27212. *
  27213. * Handles blocks of uniform on the GPU.
  27214. *
  27215. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27216. *
  27217. * For more information, please refer to :
  27218. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27219. */
  27220. export class UniformBuffer {
  27221. private _engine;
  27222. private _buffer;
  27223. private _data;
  27224. private _bufferData;
  27225. private _dynamic?;
  27226. private _uniformLocations;
  27227. private _uniformSizes;
  27228. private _uniformLocationPointer;
  27229. private _needSync;
  27230. private _noUBO;
  27231. private _currentEffect;
  27232. private static _MAX_UNIFORM_SIZE;
  27233. private static _tempBuffer;
  27234. /**
  27235. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27236. * This is dynamic to allow compat with webgl 1 and 2.
  27237. * You will need to pass the name of the uniform as well as the value.
  27238. */
  27239. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27240. /**
  27241. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27242. * This is dynamic to allow compat with webgl 1 and 2.
  27243. * You will need to pass the name of the uniform as well as the value.
  27244. */
  27245. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27246. /**
  27247. * Lambda to Update a single float in a uniform buffer.
  27248. * This is dynamic to allow compat with webgl 1 and 2.
  27249. * You will need to pass the name of the uniform as well as the value.
  27250. */
  27251. updateFloat: (name: string, x: number) => void;
  27252. /**
  27253. * Lambda to Update a vec2 of float in a uniform buffer.
  27254. * This is dynamic to allow compat with webgl 1 and 2.
  27255. * You will need to pass the name of the uniform as well as the value.
  27256. */
  27257. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27258. /**
  27259. * Lambda to Update a vec3 of float in a uniform buffer.
  27260. * This is dynamic to allow compat with webgl 1 and 2.
  27261. * You will need to pass the name of the uniform as well as the value.
  27262. */
  27263. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27264. /**
  27265. * Lambda to Update a vec4 of float in a uniform buffer.
  27266. * This is dynamic to allow compat with webgl 1 and 2.
  27267. * You will need to pass the name of the uniform as well as the value.
  27268. */
  27269. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27270. /**
  27271. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27272. * This is dynamic to allow compat with webgl 1 and 2.
  27273. * You will need to pass the name of the uniform as well as the value.
  27274. */
  27275. updateMatrix: (name: string, mat: Matrix) => void;
  27276. /**
  27277. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27278. * This is dynamic to allow compat with webgl 1 and 2.
  27279. * You will need to pass the name of the uniform as well as the value.
  27280. */
  27281. updateVector3: (name: string, vector: Vector3) => void;
  27282. /**
  27283. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27284. * This is dynamic to allow compat with webgl 1 and 2.
  27285. * You will need to pass the name of the uniform as well as the value.
  27286. */
  27287. updateVector4: (name: string, vector: Vector4) => void;
  27288. /**
  27289. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27290. * This is dynamic to allow compat with webgl 1 and 2.
  27291. * You will need to pass the name of the uniform as well as the value.
  27292. */
  27293. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27294. /**
  27295. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27296. * This is dynamic to allow compat with webgl 1 and 2.
  27297. * You will need to pass the name of the uniform as well as the value.
  27298. */
  27299. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27300. /**
  27301. * Instantiates a new Uniform buffer objects.
  27302. *
  27303. * Handles blocks of uniform on the GPU.
  27304. *
  27305. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27306. *
  27307. * For more information, please refer to :
  27308. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27309. * @param engine Define the engine the buffer is associated with
  27310. * @param data Define the data contained in the buffer
  27311. * @param dynamic Define if the buffer is updatable
  27312. */
  27313. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27314. /**
  27315. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27316. * or just falling back on setUniformXXX calls.
  27317. */
  27318. readonly useUbo: boolean;
  27319. /**
  27320. * Indicates if the WebGL underlying uniform buffer is in sync
  27321. * with the javascript cache data.
  27322. */
  27323. readonly isSync: boolean;
  27324. /**
  27325. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27326. * Also, a dynamic UniformBuffer will disable cache verification and always
  27327. * update the underlying WebGL uniform buffer to the GPU.
  27328. * @returns if Dynamic, otherwise false
  27329. */
  27330. isDynamic(): boolean;
  27331. /**
  27332. * The data cache on JS side.
  27333. * @returns the underlying data as a float array
  27334. */
  27335. getData(): Float32Array;
  27336. /**
  27337. * The underlying WebGL Uniform buffer.
  27338. * @returns the webgl buffer
  27339. */
  27340. getBuffer(): Nullable<DataBuffer>;
  27341. /**
  27342. * std140 layout specifies how to align data within an UBO structure.
  27343. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27344. * for specs.
  27345. */
  27346. private _fillAlignment;
  27347. /**
  27348. * Adds an uniform in the buffer.
  27349. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27350. * for the layout to be correct !
  27351. * @param name Name of the uniform, as used in the uniform block in the shader.
  27352. * @param size Data size, or data directly.
  27353. */
  27354. addUniform(name: string, size: number | number[]): void;
  27355. /**
  27356. * Adds a Matrix 4x4 to the uniform buffer.
  27357. * @param name Name of the uniform, as used in the uniform block in the shader.
  27358. * @param mat A 4x4 matrix.
  27359. */
  27360. addMatrix(name: string, mat: Matrix): void;
  27361. /**
  27362. * Adds a vec2 to the uniform buffer.
  27363. * @param name Name of the uniform, as used in the uniform block in the shader.
  27364. * @param x Define the x component value of the vec2
  27365. * @param y Define the y component value of the vec2
  27366. */
  27367. addFloat2(name: string, x: number, y: number): void;
  27368. /**
  27369. * Adds a vec3 to the uniform buffer.
  27370. * @param name Name of the uniform, as used in the uniform block in the shader.
  27371. * @param x Define the x component value of the vec3
  27372. * @param y Define the y component value of the vec3
  27373. * @param z Define the z component value of the vec3
  27374. */
  27375. addFloat3(name: string, x: number, y: number, z: number): void;
  27376. /**
  27377. * Adds a vec3 to the uniform buffer.
  27378. * @param name Name of the uniform, as used in the uniform block in the shader.
  27379. * @param color Define the vec3 from a Color
  27380. */
  27381. addColor3(name: string, color: Color3): void;
  27382. /**
  27383. * Adds a vec4 to the uniform buffer.
  27384. * @param name Name of the uniform, as used in the uniform block in the shader.
  27385. * @param color Define the rgb components from a Color
  27386. * @param alpha Define the a component of the vec4
  27387. */
  27388. addColor4(name: string, color: Color3, alpha: number): void;
  27389. /**
  27390. * Adds a vec3 to the uniform buffer.
  27391. * @param name Name of the uniform, as used in the uniform block in the shader.
  27392. * @param vector Define the vec3 components from a Vector
  27393. */
  27394. addVector3(name: string, vector: Vector3): void;
  27395. /**
  27396. * Adds a Matrix 3x3 to the uniform buffer.
  27397. * @param name Name of the uniform, as used in the uniform block in the shader.
  27398. */
  27399. addMatrix3x3(name: string): void;
  27400. /**
  27401. * Adds a Matrix 2x2 to the uniform buffer.
  27402. * @param name Name of the uniform, as used in the uniform block in the shader.
  27403. */
  27404. addMatrix2x2(name: string): void;
  27405. /**
  27406. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27407. */
  27408. create(): void;
  27409. /** @hidden */
  27410. _rebuild(): void;
  27411. /**
  27412. * Updates the WebGL Uniform Buffer on the GPU.
  27413. * If the `dynamic` flag is set to true, no cache comparison is done.
  27414. * Otherwise, the buffer will be updated only if the cache differs.
  27415. */
  27416. update(): void;
  27417. /**
  27418. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27419. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27420. * @param data Define the flattened data
  27421. * @param size Define the size of the data.
  27422. */
  27423. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27424. private _updateMatrix3x3ForUniform;
  27425. private _updateMatrix3x3ForEffect;
  27426. private _updateMatrix2x2ForEffect;
  27427. private _updateMatrix2x2ForUniform;
  27428. private _updateFloatForEffect;
  27429. private _updateFloatForUniform;
  27430. private _updateFloat2ForEffect;
  27431. private _updateFloat2ForUniform;
  27432. private _updateFloat3ForEffect;
  27433. private _updateFloat3ForUniform;
  27434. private _updateFloat4ForEffect;
  27435. private _updateFloat4ForUniform;
  27436. private _updateMatrixForEffect;
  27437. private _updateMatrixForUniform;
  27438. private _updateVector3ForEffect;
  27439. private _updateVector3ForUniform;
  27440. private _updateVector4ForEffect;
  27441. private _updateVector4ForUniform;
  27442. private _updateColor3ForEffect;
  27443. private _updateColor3ForUniform;
  27444. private _updateColor4ForEffect;
  27445. private _updateColor4ForUniform;
  27446. /**
  27447. * Sets a sampler uniform on the effect.
  27448. * @param name Define the name of the sampler.
  27449. * @param texture Define the texture to set in the sampler
  27450. */
  27451. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27452. /**
  27453. * Directly updates the value of the uniform in the cache AND on the GPU.
  27454. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27455. * @param data Define the flattened data
  27456. */
  27457. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27458. /**
  27459. * Binds this uniform buffer to an effect.
  27460. * @param effect Define the effect to bind the buffer to
  27461. * @param name Name of the uniform block in the shader.
  27462. */
  27463. bindToEffect(effect: Effect, name: string): void;
  27464. /**
  27465. * Disposes the uniform buffer.
  27466. */
  27467. dispose(): void;
  27468. }
  27469. }
  27470. declare module "babylonjs/Audio/analyser" {
  27471. import { Scene } from "babylonjs/scene";
  27472. /**
  27473. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27475. */
  27476. export class Analyser {
  27477. /**
  27478. * Gets or sets the smoothing
  27479. * @ignorenaming
  27480. */
  27481. SMOOTHING: number;
  27482. /**
  27483. * Gets or sets the FFT table size
  27484. * @ignorenaming
  27485. */
  27486. FFT_SIZE: number;
  27487. /**
  27488. * Gets or sets the bar graph amplitude
  27489. * @ignorenaming
  27490. */
  27491. BARGRAPHAMPLITUDE: number;
  27492. /**
  27493. * Gets or sets the position of the debug canvas
  27494. * @ignorenaming
  27495. */
  27496. DEBUGCANVASPOS: {
  27497. x: number;
  27498. y: number;
  27499. };
  27500. /**
  27501. * Gets or sets the debug canvas size
  27502. * @ignorenaming
  27503. */
  27504. DEBUGCANVASSIZE: {
  27505. width: number;
  27506. height: number;
  27507. };
  27508. private _byteFreqs;
  27509. private _byteTime;
  27510. private _floatFreqs;
  27511. private _webAudioAnalyser;
  27512. private _debugCanvas;
  27513. private _debugCanvasContext;
  27514. private _scene;
  27515. private _registerFunc;
  27516. private _audioEngine;
  27517. /**
  27518. * Creates a new analyser
  27519. * @param scene defines hosting scene
  27520. */
  27521. constructor(scene: Scene);
  27522. /**
  27523. * Get the number of data values you will have to play with for the visualization
  27524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27525. * @returns a number
  27526. */
  27527. getFrequencyBinCount(): number;
  27528. /**
  27529. * Gets the current frequency data as a byte array
  27530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27531. * @returns a Uint8Array
  27532. */
  27533. getByteFrequencyData(): Uint8Array;
  27534. /**
  27535. * Gets the current waveform as a byte array
  27536. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27537. * @returns a Uint8Array
  27538. */
  27539. getByteTimeDomainData(): Uint8Array;
  27540. /**
  27541. * Gets the current frequency data as a float array
  27542. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27543. * @returns a Float32Array
  27544. */
  27545. getFloatFrequencyData(): Float32Array;
  27546. /**
  27547. * Renders the debug canvas
  27548. */
  27549. drawDebugCanvas(): void;
  27550. /**
  27551. * Stops rendering the debug canvas and removes it
  27552. */
  27553. stopDebugCanvas(): void;
  27554. /**
  27555. * Connects two audio nodes
  27556. * @param inputAudioNode defines first node to connect
  27557. * @param outputAudioNode defines second node to connect
  27558. */
  27559. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27560. /**
  27561. * Releases all associated resources
  27562. */
  27563. dispose(): void;
  27564. }
  27565. }
  27566. declare module "babylonjs/Audio/audioEngine" {
  27567. import { IDisposable } from "babylonjs/scene";
  27568. import { Analyser } from "babylonjs/Audio/analyser";
  27569. import { Nullable } from "babylonjs/types";
  27570. import { Observable } from "babylonjs/Misc/observable";
  27571. /**
  27572. * This represents an audio engine and it is responsible
  27573. * to play, synchronize and analyse sounds throughout the application.
  27574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27575. */
  27576. export interface IAudioEngine extends IDisposable {
  27577. /**
  27578. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27579. */
  27580. readonly canUseWebAudio: boolean;
  27581. /**
  27582. * Gets the current AudioContext if available.
  27583. */
  27584. readonly audioContext: Nullable<AudioContext>;
  27585. /**
  27586. * The master gain node defines the global audio volume of your audio engine.
  27587. */
  27588. readonly masterGain: GainNode;
  27589. /**
  27590. * Gets whether or not mp3 are supported by your browser.
  27591. */
  27592. readonly isMP3supported: boolean;
  27593. /**
  27594. * Gets whether or not ogg are supported by your browser.
  27595. */
  27596. readonly isOGGsupported: boolean;
  27597. /**
  27598. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27599. * @ignoreNaming
  27600. */
  27601. WarnedWebAudioUnsupported: boolean;
  27602. /**
  27603. * Defines if the audio engine relies on a custom unlocked button.
  27604. * In this case, the embedded button will not be displayed.
  27605. */
  27606. useCustomUnlockedButton: boolean;
  27607. /**
  27608. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27609. */
  27610. readonly unlocked: boolean;
  27611. /**
  27612. * Event raised when audio has been unlocked on the browser.
  27613. */
  27614. onAudioUnlockedObservable: Observable<AudioEngine>;
  27615. /**
  27616. * Event raised when audio has been locked on the browser.
  27617. */
  27618. onAudioLockedObservable: Observable<AudioEngine>;
  27619. /**
  27620. * Flags the audio engine in Locked state.
  27621. * This happens due to new browser policies preventing audio to autoplay.
  27622. */
  27623. lock(): void;
  27624. /**
  27625. * Unlocks the audio engine once a user action has been done on the dom.
  27626. * This is helpful to resume play once browser policies have been satisfied.
  27627. */
  27628. unlock(): void;
  27629. }
  27630. /**
  27631. * This represents the default audio engine used in babylon.
  27632. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27634. */
  27635. export class AudioEngine implements IAudioEngine {
  27636. private _audioContext;
  27637. private _audioContextInitialized;
  27638. private _muteButton;
  27639. private _hostElement;
  27640. /**
  27641. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27642. */
  27643. canUseWebAudio: boolean;
  27644. /**
  27645. * The master gain node defines the global audio volume of your audio engine.
  27646. */
  27647. masterGain: GainNode;
  27648. /**
  27649. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27650. * @ignoreNaming
  27651. */
  27652. WarnedWebAudioUnsupported: boolean;
  27653. /**
  27654. * Gets whether or not mp3 are supported by your browser.
  27655. */
  27656. isMP3supported: boolean;
  27657. /**
  27658. * Gets whether or not ogg are supported by your browser.
  27659. */
  27660. isOGGsupported: boolean;
  27661. /**
  27662. * Gets whether audio has been unlocked on the device.
  27663. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27664. * a user interaction has happened.
  27665. */
  27666. unlocked: boolean;
  27667. /**
  27668. * Defines if the audio engine relies on a custom unlocked button.
  27669. * In this case, the embedded button will not be displayed.
  27670. */
  27671. useCustomUnlockedButton: boolean;
  27672. /**
  27673. * Event raised when audio has been unlocked on the browser.
  27674. */
  27675. onAudioUnlockedObservable: Observable<AudioEngine>;
  27676. /**
  27677. * Event raised when audio has been locked on the browser.
  27678. */
  27679. onAudioLockedObservable: Observable<AudioEngine>;
  27680. /**
  27681. * Gets the current AudioContext if available.
  27682. */
  27683. readonly audioContext: Nullable<AudioContext>;
  27684. private _connectedAnalyser;
  27685. /**
  27686. * Instantiates a new audio engine.
  27687. *
  27688. * There should be only one per page as some browsers restrict the number
  27689. * of audio contexts you can create.
  27690. * @param hostElement defines the host element where to display the mute icon if necessary
  27691. */
  27692. constructor(hostElement?: Nullable<HTMLElement>);
  27693. /**
  27694. * Flags the audio engine in Locked state.
  27695. * This happens due to new browser policies preventing audio to autoplay.
  27696. */
  27697. lock(): void;
  27698. /**
  27699. * Unlocks the audio engine once a user action has been done on the dom.
  27700. * This is helpful to resume play once browser policies have been satisfied.
  27701. */
  27702. unlock(): void;
  27703. private _resumeAudioContext;
  27704. private _initializeAudioContext;
  27705. private _tryToRun;
  27706. private _triggerRunningState;
  27707. private _triggerSuspendedState;
  27708. private _displayMuteButton;
  27709. private _moveButtonToTopLeft;
  27710. private _onResize;
  27711. private _hideMuteButton;
  27712. /**
  27713. * Destroy and release the resources associated with the audio ccontext.
  27714. */
  27715. dispose(): void;
  27716. /**
  27717. * Gets the global volume sets on the master gain.
  27718. * @returns the global volume if set or -1 otherwise
  27719. */
  27720. getGlobalVolume(): number;
  27721. /**
  27722. * Sets the global volume of your experience (sets on the master gain).
  27723. * @param newVolume Defines the new global volume of the application
  27724. */
  27725. setGlobalVolume(newVolume: number): void;
  27726. /**
  27727. * Connect the audio engine to an audio analyser allowing some amazing
  27728. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27730. * @param analyser The analyser to connect to the engine
  27731. */
  27732. connectToAnalyser(analyser: Analyser): void;
  27733. }
  27734. }
  27735. declare module "babylonjs/Loading/loadingScreen" {
  27736. /**
  27737. * Interface used to present a loading screen while loading a scene
  27738. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27739. */
  27740. export interface ILoadingScreen {
  27741. /**
  27742. * Function called to display the loading screen
  27743. */
  27744. displayLoadingUI: () => void;
  27745. /**
  27746. * Function called to hide the loading screen
  27747. */
  27748. hideLoadingUI: () => void;
  27749. /**
  27750. * Gets or sets the color to use for the background
  27751. */
  27752. loadingUIBackgroundColor: string;
  27753. /**
  27754. * Gets or sets the text to display while loading
  27755. */
  27756. loadingUIText: string;
  27757. }
  27758. /**
  27759. * Class used for the default loading screen
  27760. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27761. */
  27762. export class DefaultLoadingScreen implements ILoadingScreen {
  27763. private _renderingCanvas;
  27764. private _loadingText;
  27765. private _loadingDivBackgroundColor;
  27766. private _loadingDiv;
  27767. private _loadingTextDiv;
  27768. /** Gets or sets the logo url to use for the default loading screen */
  27769. static DefaultLogoUrl: string;
  27770. /** Gets or sets the spinner url to use for the default loading screen */
  27771. static DefaultSpinnerUrl: string;
  27772. /**
  27773. * Creates a new default loading screen
  27774. * @param _renderingCanvas defines the canvas used to render the scene
  27775. * @param _loadingText defines the default text to display
  27776. * @param _loadingDivBackgroundColor defines the default background color
  27777. */
  27778. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27779. /**
  27780. * Function called to display the loading screen
  27781. */
  27782. displayLoadingUI(): void;
  27783. /**
  27784. * Function called to hide the loading screen
  27785. */
  27786. hideLoadingUI(): void;
  27787. /**
  27788. * Gets or sets the text to display while loading
  27789. */
  27790. loadingUIText: string;
  27791. /**
  27792. * Gets or sets the color to use for the background
  27793. */
  27794. loadingUIBackgroundColor: string;
  27795. private _resizeLoadingUI;
  27796. }
  27797. }
  27798. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27799. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27800. import { Engine } from "babylonjs/Engines/engine";
  27801. import { Nullable } from "babylonjs/types";
  27802. /** @hidden */
  27803. export class WebGLPipelineContext implements IPipelineContext {
  27804. engine: Engine;
  27805. program: Nullable<WebGLProgram>;
  27806. context?: WebGLRenderingContext;
  27807. vertexShader?: WebGLShader;
  27808. fragmentShader?: WebGLShader;
  27809. isParallelCompiled: boolean;
  27810. onCompiled?: () => void;
  27811. transformFeedback?: WebGLTransformFeedback | null;
  27812. readonly isAsync: boolean;
  27813. readonly isReady: boolean;
  27814. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27815. }
  27816. }
  27817. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27818. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27819. /** @hidden */
  27820. export class WebGLDataBuffer extends DataBuffer {
  27821. private _buffer;
  27822. constructor(resource: WebGLBuffer);
  27823. readonly underlyingResource: any;
  27824. }
  27825. }
  27826. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27827. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27828. /** @hidden */
  27829. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27830. attributeProcessor(attribute: string): string;
  27831. varyingProcessor(varying: string, isFragment: boolean): string;
  27832. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27833. }
  27834. }
  27835. declare module "babylonjs/Materials/Textures/videoTexture" {
  27836. import { Observable } from "babylonjs/Misc/observable";
  27837. import { Nullable } from "babylonjs/types";
  27838. import { Scene } from "babylonjs/scene";
  27839. import { Texture } from "babylonjs/Materials/Textures/texture";
  27840. /**
  27841. * Settings for finer control over video usage
  27842. */
  27843. export interface VideoTextureSettings {
  27844. /**
  27845. * Applies `autoplay` to video, if specified
  27846. */
  27847. autoPlay?: boolean;
  27848. /**
  27849. * Applies `loop` to video, if specified
  27850. */
  27851. loop?: boolean;
  27852. /**
  27853. * Automatically updates internal texture from video at every frame in the render loop
  27854. */
  27855. autoUpdateTexture: boolean;
  27856. /**
  27857. * Image src displayed during the video loading or until the user interacts with the video.
  27858. */
  27859. poster?: string;
  27860. }
  27861. /**
  27862. * If you want to display a video in your scene, this is the special texture for that.
  27863. * This special texture works similar to other textures, with the exception of a few parameters.
  27864. * @see https://doc.babylonjs.com/how_to/video_texture
  27865. */
  27866. export class VideoTexture extends Texture {
  27867. /**
  27868. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27869. */
  27870. readonly autoUpdateTexture: boolean;
  27871. /**
  27872. * The video instance used by the texture internally
  27873. */
  27874. readonly video: HTMLVideoElement;
  27875. private _onUserActionRequestedObservable;
  27876. /**
  27877. * Event triggerd when a dom action is required by the user to play the video.
  27878. * This happens due to recent changes in browser policies preventing video to auto start.
  27879. */
  27880. readonly onUserActionRequestedObservable: Observable<Texture>;
  27881. private _generateMipMaps;
  27882. private _engine;
  27883. private _stillImageCaptured;
  27884. private _displayingPosterTexture;
  27885. private _settings;
  27886. private _createInternalTextureOnEvent;
  27887. /**
  27888. * Creates a video texture.
  27889. * If you want to display a video in your scene, this is the special texture for that.
  27890. * This special texture works similar to other textures, with the exception of a few parameters.
  27891. * @see https://doc.babylonjs.com/how_to/video_texture
  27892. * @param name optional name, will detect from video source, if not defined
  27893. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27894. * @param scene is obviously the current scene.
  27895. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27896. * @param invertY is false by default but can be used to invert video on Y axis
  27897. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27898. * @param settings allows finer control over video usage
  27899. */
  27900. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27901. private _getName;
  27902. private _getVideo;
  27903. private _createInternalTexture;
  27904. private reset;
  27905. /**
  27906. * @hidden Internal method to initiate `update`.
  27907. */
  27908. _rebuild(): void;
  27909. /**
  27910. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27911. */
  27912. update(): void;
  27913. /**
  27914. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27915. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27916. */
  27917. updateTexture(isVisible: boolean): void;
  27918. protected _updateInternalTexture: () => void;
  27919. /**
  27920. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27921. * @param url New url.
  27922. */
  27923. updateURL(url: string): void;
  27924. /**
  27925. * Dispose the texture and release its associated resources.
  27926. */
  27927. dispose(): void;
  27928. /**
  27929. * Creates a video texture straight from a stream.
  27930. * @param scene Define the scene the texture should be created in
  27931. * @param stream Define the stream the texture should be created from
  27932. * @returns The created video texture as a promise
  27933. */
  27934. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27935. /**
  27936. * Creates a video texture straight from your WebCam video feed.
  27937. * @param scene Define the scene the texture should be created in
  27938. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27939. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27940. * @returns The created video texture as a promise
  27941. */
  27942. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27943. minWidth: number;
  27944. maxWidth: number;
  27945. minHeight: number;
  27946. maxHeight: number;
  27947. deviceId: string;
  27948. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27949. /**
  27950. * Creates a video texture straight from your WebCam video feed.
  27951. * @param scene Define the scene the texture should be created in
  27952. * @param onReady Define a callback to triggered once the texture will be ready
  27953. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27954. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27955. */
  27956. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27957. minWidth: number;
  27958. maxWidth: number;
  27959. minHeight: number;
  27960. maxHeight: number;
  27961. deviceId: string;
  27962. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27963. }
  27964. }
  27965. declare module "babylonjs/Engines/engine" {
  27966. import { Observable } from "babylonjs/Misc/observable";
  27967. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27968. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27969. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27970. import { Camera } from "babylonjs/Cameras/camera";
  27971. import { Scene } from "babylonjs/scene";
  27972. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27973. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27974. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27975. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27976. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27977. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27979. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27980. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27981. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27982. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27983. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27984. import { WebRequest } from "babylonjs/Misc/webRequest";
  27985. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27986. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27987. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27988. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27989. import { Material } from "babylonjs/Materials/material";
  27990. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27992. /**
  27993. * Interface for attribute information associated with buffer instanciation
  27994. */
  27995. export class InstancingAttributeInfo {
  27996. /**
  27997. * Index/offset of the attribute in the vertex shader
  27998. */
  27999. index: number;
  28000. /**
  28001. * size of the attribute, 1, 2, 3 or 4
  28002. */
  28003. attributeSize: number;
  28004. /**
  28005. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28006. * default is FLOAT
  28007. */
  28008. attribyteType: number;
  28009. /**
  28010. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28011. */
  28012. normalized: boolean;
  28013. /**
  28014. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28015. */
  28016. offset: number;
  28017. /**
  28018. * Name of the GLSL attribute, for debugging purpose only
  28019. */
  28020. attributeName: string;
  28021. }
  28022. /**
  28023. * Define options used to create a depth texture
  28024. */
  28025. export class DepthTextureCreationOptions {
  28026. /** Specifies whether or not a stencil should be allocated in the texture */
  28027. generateStencil?: boolean;
  28028. /** Specifies whether or not bilinear filtering is enable on the texture */
  28029. bilinearFiltering?: boolean;
  28030. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28031. comparisonFunction?: number;
  28032. /** Specifies if the created texture is a cube texture */
  28033. isCube?: boolean;
  28034. }
  28035. /**
  28036. * Class used to describe the capabilities of the engine relatively to the current browser
  28037. */
  28038. export class EngineCapabilities {
  28039. /** Maximum textures units per fragment shader */
  28040. maxTexturesImageUnits: number;
  28041. /** Maximum texture units per vertex shader */
  28042. maxVertexTextureImageUnits: number;
  28043. /** Maximum textures units in the entire pipeline */
  28044. maxCombinedTexturesImageUnits: number;
  28045. /** Maximum texture size */
  28046. maxTextureSize: number;
  28047. /** Maximum cube texture size */
  28048. maxCubemapTextureSize: number;
  28049. /** Maximum render texture size */
  28050. maxRenderTextureSize: number;
  28051. /** Maximum number of vertex attributes */
  28052. maxVertexAttribs: number;
  28053. /** Maximum number of varyings */
  28054. maxVaryingVectors: number;
  28055. /** Maximum number of uniforms per vertex shader */
  28056. maxVertexUniformVectors: number;
  28057. /** Maximum number of uniforms per fragment shader */
  28058. maxFragmentUniformVectors: number;
  28059. /** Defines if standard derivates (dx/dy) are supported */
  28060. standardDerivatives: boolean;
  28061. /** Defines if s3tc texture compression is supported */
  28062. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28063. /** Defines if pvrtc texture compression is supported */
  28064. pvrtc: any;
  28065. /** Defines if etc1 texture compression is supported */
  28066. etc1: any;
  28067. /** Defines if etc2 texture compression is supported */
  28068. etc2: any;
  28069. /** Defines if astc texture compression is supported */
  28070. astc: any;
  28071. /** Defines if float textures are supported */
  28072. textureFloat: boolean;
  28073. /** Defines if vertex array objects are supported */
  28074. vertexArrayObject: boolean;
  28075. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28076. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28077. /** Gets the maximum level of anisotropy supported */
  28078. maxAnisotropy: number;
  28079. /** Defines if instancing is supported */
  28080. instancedArrays: boolean;
  28081. /** Defines if 32 bits indices are supported */
  28082. uintIndices: boolean;
  28083. /** Defines if high precision shaders are supported */
  28084. highPrecisionShaderSupported: boolean;
  28085. /** Defines if depth reading in the fragment shader is supported */
  28086. fragmentDepthSupported: boolean;
  28087. /** Defines if float texture linear filtering is supported*/
  28088. textureFloatLinearFiltering: boolean;
  28089. /** Defines if rendering to float textures is supported */
  28090. textureFloatRender: boolean;
  28091. /** Defines if half float textures are supported*/
  28092. textureHalfFloat: boolean;
  28093. /** Defines if half float texture linear filtering is supported*/
  28094. textureHalfFloatLinearFiltering: boolean;
  28095. /** Defines if rendering to half float textures is supported */
  28096. textureHalfFloatRender: boolean;
  28097. /** Defines if textureLOD shader command is supported */
  28098. textureLOD: boolean;
  28099. /** Defines if draw buffers extension is supported */
  28100. drawBuffersExtension: boolean;
  28101. /** Defines if depth textures are supported */
  28102. depthTextureExtension: boolean;
  28103. /** Defines if float color buffer are supported */
  28104. colorBufferFloat: boolean;
  28105. /** Gets disjoint timer query extension (null if not supported) */
  28106. timerQuery: EXT_disjoint_timer_query;
  28107. /** Defines if timestamp can be used with timer query */
  28108. canUseTimestampForTimerQuery: boolean;
  28109. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28110. multiview: any;
  28111. /** Function used to let the system compiles shaders in background */
  28112. parallelShaderCompile: {
  28113. COMPLETION_STATUS_KHR: number;
  28114. };
  28115. }
  28116. /** Interface defining initialization parameters for Engine class */
  28117. export interface EngineOptions extends WebGLContextAttributes {
  28118. /**
  28119. * Defines if the engine should no exceed a specified device ratio
  28120. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28121. */
  28122. limitDeviceRatio?: number;
  28123. /**
  28124. * Defines if webvr should be enabled automatically
  28125. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28126. */
  28127. autoEnableWebVR?: boolean;
  28128. /**
  28129. * Defines if webgl2 should be turned off even if supported
  28130. * @see http://doc.babylonjs.com/features/webgl2
  28131. */
  28132. disableWebGL2Support?: boolean;
  28133. /**
  28134. * Defines if webaudio should be initialized as well
  28135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28136. */
  28137. audioEngine?: boolean;
  28138. /**
  28139. * Defines if animations should run using a deterministic lock step
  28140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28141. */
  28142. deterministicLockstep?: boolean;
  28143. /** Defines the maximum steps to use with deterministic lock step mode */
  28144. lockstepMaxSteps?: number;
  28145. /**
  28146. * Defines that engine should ignore context lost events
  28147. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28148. */
  28149. doNotHandleContextLost?: boolean;
  28150. /**
  28151. * Defines that engine should ignore modifying touch action attribute and style
  28152. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28153. */
  28154. doNotHandleTouchAction?: boolean;
  28155. /**
  28156. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28157. */
  28158. useHighPrecisionFloats?: boolean;
  28159. }
  28160. /**
  28161. * Defines the interface used by display changed events
  28162. */
  28163. export interface IDisplayChangedEventArgs {
  28164. /** Gets the vrDisplay object (if any) */
  28165. vrDisplay: Nullable<any>;
  28166. /** Gets a boolean indicating if webVR is supported */
  28167. vrSupported: boolean;
  28168. }
  28169. /**
  28170. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28171. */
  28172. export class Engine {
  28173. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28174. static ExceptionList: ({
  28175. key: string;
  28176. capture: string;
  28177. captureConstraint: number;
  28178. targets: string[];
  28179. } | {
  28180. key: string;
  28181. capture: null;
  28182. captureConstraint: null;
  28183. targets: string[];
  28184. })[];
  28185. /** Gets the list of created engines */
  28186. static readonly Instances: Engine[];
  28187. /**
  28188. * Gets the latest created engine
  28189. */
  28190. static readonly LastCreatedEngine: Nullable<Engine>;
  28191. /**
  28192. * Gets the latest created scene
  28193. */
  28194. static readonly LastCreatedScene: Nullable<Scene>;
  28195. /**
  28196. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28197. * @param flag defines which part of the materials must be marked as dirty
  28198. * @param predicate defines a predicate used to filter which materials should be affected
  28199. */
  28200. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28201. /** @hidden */
  28202. static _TextureLoaders: IInternalTextureLoader[];
  28203. /** Defines that alpha blending is disabled */
  28204. static readonly ALPHA_DISABLE: number;
  28205. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28206. static readonly ALPHA_ADD: number;
  28207. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28208. static readonly ALPHA_COMBINE: number;
  28209. /** Defines that alpha blending to DEST - SRC * DEST */
  28210. static readonly ALPHA_SUBTRACT: number;
  28211. /** Defines that alpha blending to SRC * DEST */
  28212. static readonly ALPHA_MULTIPLY: number;
  28213. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28214. static readonly ALPHA_MAXIMIZED: number;
  28215. /** Defines that alpha blending to SRC + DEST */
  28216. static readonly ALPHA_ONEONE: number;
  28217. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28218. static readonly ALPHA_PREMULTIPLIED: number;
  28219. /**
  28220. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28221. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28222. */
  28223. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28224. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28225. static readonly ALPHA_INTERPOLATE: number;
  28226. /**
  28227. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28228. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28229. */
  28230. static readonly ALPHA_SCREENMODE: number;
  28231. /** Defines that the ressource is not delayed*/
  28232. static readonly DELAYLOADSTATE_NONE: number;
  28233. /** Defines that the ressource was successfully delay loaded */
  28234. static readonly DELAYLOADSTATE_LOADED: number;
  28235. /** Defines that the ressource is currently delay loading */
  28236. static readonly DELAYLOADSTATE_LOADING: number;
  28237. /** Defines that the ressource is delayed and has not started loading */
  28238. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28239. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28240. static readonly NEVER: number;
  28241. /** 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 */
  28242. static readonly ALWAYS: number;
  28243. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28244. static readonly LESS: number;
  28245. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28246. static readonly EQUAL: number;
  28247. /** 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 */
  28248. static readonly LEQUAL: number;
  28249. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28250. static readonly GREATER: number;
  28251. /** 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 */
  28252. static readonly GEQUAL: number;
  28253. /** 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 */
  28254. static readonly NOTEQUAL: number;
  28255. /** Passed to stencilOperation to specify that stencil value must be kept */
  28256. static readonly KEEP: number;
  28257. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28258. static readonly REPLACE: number;
  28259. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28260. static readonly INCR: number;
  28261. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28262. static readonly DECR: number;
  28263. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28264. static readonly INVERT: number;
  28265. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28266. static readonly INCR_WRAP: number;
  28267. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28268. static readonly DECR_WRAP: number;
  28269. /** Texture is not repeating outside of 0..1 UVs */
  28270. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28271. /** Texture is repeating outside of 0..1 UVs */
  28272. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28273. /** Texture is repeating and mirrored */
  28274. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28275. /** ALPHA */
  28276. static readonly TEXTUREFORMAT_ALPHA: number;
  28277. /** LUMINANCE */
  28278. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28279. /** LUMINANCE_ALPHA */
  28280. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28281. /** RGB */
  28282. static readonly TEXTUREFORMAT_RGB: number;
  28283. /** RGBA */
  28284. static readonly TEXTUREFORMAT_RGBA: number;
  28285. /** RED */
  28286. static readonly TEXTUREFORMAT_RED: number;
  28287. /** RED (2nd reference) */
  28288. static readonly TEXTUREFORMAT_R: number;
  28289. /** RG */
  28290. static readonly TEXTUREFORMAT_RG: number;
  28291. /** RED_INTEGER */
  28292. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28293. /** RED_INTEGER (2nd reference) */
  28294. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28295. /** RG_INTEGER */
  28296. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28297. /** RGB_INTEGER */
  28298. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28299. /** RGBA_INTEGER */
  28300. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28301. /** UNSIGNED_BYTE */
  28302. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28303. /** UNSIGNED_BYTE (2nd reference) */
  28304. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28305. /** FLOAT */
  28306. static readonly TEXTURETYPE_FLOAT: number;
  28307. /** HALF_FLOAT */
  28308. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28309. /** BYTE */
  28310. static readonly TEXTURETYPE_BYTE: number;
  28311. /** SHORT */
  28312. static readonly TEXTURETYPE_SHORT: number;
  28313. /** UNSIGNED_SHORT */
  28314. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28315. /** INT */
  28316. static readonly TEXTURETYPE_INT: number;
  28317. /** UNSIGNED_INT */
  28318. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28319. /** UNSIGNED_SHORT_4_4_4_4 */
  28320. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28321. /** UNSIGNED_SHORT_5_5_5_1 */
  28322. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28323. /** UNSIGNED_SHORT_5_6_5 */
  28324. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28325. /** UNSIGNED_INT_2_10_10_10_REV */
  28326. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28327. /** UNSIGNED_INT_24_8 */
  28328. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28329. /** UNSIGNED_INT_10F_11F_11F_REV */
  28330. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28331. /** UNSIGNED_INT_5_9_9_9_REV */
  28332. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28333. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28334. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28335. /** nearest is mag = nearest and min = nearest and mip = linear */
  28336. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28337. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28338. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28339. /** Trilinear is mag = linear and min = linear and mip = linear */
  28340. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28341. /** nearest is mag = nearest and min = nearest and mip = linear */
  28342. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28343. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28344. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28345. /** Trilinear is mag = linear and min = linear and mip = linear */
  28346. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28347. /** mag = nearest and min = nearest and mip = nearest */
  28348. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28349. /** mag = nearest and min = linear and mip = nearest */
  28350. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28351. /** mag = nearest and min = linear and mip = linear */
  28352. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28353. /** mag = nearest and min = linear and mip = none */
  28354. static readonly TEXTURE_NEAREST_LINEAR: number;
  28355. /** mag = nearest and min = nearest and mip = none */
  28356. static readonly TEXTURE_NEAREST_NEAREST: number;
  28357. /** mag = linear and min = nearest and mip = nearest */
  28358. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28359. /** mag = linear and min = nearest and mip = linear */
  28360. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28361. /** mag = linear and min = linear and mip = none */
  28362. static readonly TEXTURE_LINEAR_LINEAR: number;
  28363. /** mag = linear and min = nearest and mip = none */
  28364. static readonly TEXTURE_LINEAR_NEAREST: number;
  28365. /** Explicit coordinates mode */
  28366. static readonly TEXTURE_EXPLICIT_MODE: number;
  28367. /** Spherical coordinates mode */
  28368. static readonly TEXTURE_SPHERICAL_MODE: number;
  28369. /** Planar coordinates mode */
  28370. static readonly TEXTURE_PLANAR_MODE: number;
  28371. /** Cubic coordinates mode */
  28372. static readonly TEXTURE_CUBIC_MODE: number;
  28373. /** Projection coordinates mode */
  28374. static readonly TEXTURE_PROJECTION_MODE: number;
  28375. /** Skybox coordinates mode */
  28376. static readonly TEXTURE_SKYBOX_MODE: number;
  28377. /** Inverse Cubic coordinates mode */
  28378. static readonly TEXTURE_INVCUBIC_MODE: number;
  28379. /** Equirectangular coordinates mode */
  28380. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28381. /** Equirectangular Fixed coordinates mode */
  28382. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28383. /** Equirectangular Fixed Mirrored coordinates mode */
  28384. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28385. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28386. static readonly SCALEMODE_FLOOR: number;
  28387. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28388. static readonly SCALEMODE_NEAREST: number;
  28389. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28390. static readonly SCALEMODE_CEILING: number;
  28391. /**
  28392. * Returns the current npm package of the sdk
  28393. */
  28394. static readonly NpmPackage: string;
  28395. /**
  28396. * Returns the current version of the framework
  28397. */
  28398. static readonly Version: string;
  28399. /**
  28400. * Returns a string describing the current engine
  28401. */
  28402. readonly description: string;
  28403. /**
  28404. * Gets or sets the epsilon value used by collision engine
  28405. */
  28406. static CollisionsEpsilon: number;
  28407. /**
  28408. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28409. */
  28410. static ShadersRepository: string;
  28411. /**
  28412. * Method called to create the default loading screen.
  28413. * This can be overriden in your own app.
  28414. * @param canvas The rendering canvas element
  28415. * @returns The loading screen
  28416. */
  28417. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28418. /**
  28419. * Method called to create the default rescale post process on each engine.
  28420. */
  28421. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28422. /** @hidden */
  28423. _shaderProcessor: IShaderProcessor;
  28424. /**
  28425. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28426. */
  28427. forcePOTTextures: boolean;
  28428. /**
  28429. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28430. */
  28431. isFullscreen: boolean;
  28432. /**
  28433. * Gets a boolean indicating if the pointer is currently locked
  28434. */
  28435. isPointerLock: boolean;
  28436. /**
  28437. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28438. */
  28439. cullBackFaces: boolean;
  28440. /**
  28441. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28442. */
  28443. renderEvenInBackground: boolean;
  28444. /**
  28445. * Gets or sets a boolean indicating that cache can be kept between frames
  28446. */
  28447. preventCacheWipeBetweenFrames: boolean;
  28448. /**
  28449. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28450. **/
  28451. enableOfflineSupport: boolean;
  28452. /**
  28453. * 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)
  28454. **/
  28455. disableManifestCheck: boolean;
  28456. /**
  28457. * Gets the list of created scenes
  28458. */
  28459. scenes: Scene[];
  28460. /**
  28461. * Event raised when a new scene is created
  28462. */
  28463. onNewSceneAddedObservable: Observable<Scene>;
  28464. /**
  28465. * Gets the list of created postprocesses
  28466. */
  28467. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28468. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28469. validateShaderPrograms: boolean;
  28470. /**
  28471. * Observable event triggered each time the rendering canvas is resized
  28472. */
  28473. onResizeObservable: Observable<Engine>;
  28474. /**
  28475. * Observable event triggered each time the canvas loses focus
  28476. */
  28477. onCanvasBlurObservable: Observable<Engine>;
  28478. /**
  28479. * Observable event triggered each time the canvas gains focus
  28480. */
  28481. onCanvasFocusObservable: Observable<Engine>;
  28482. /**
  28483. * Observable event triggered each time the canvas receives pointerout event
  28484. */
  28485. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28486. /**
  28487. * Observable event triggered before each texture is initialized
  28488. */
  28489. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28490. /**
  28491. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28492. */
  28493. disableUniformBuffers: boolean;
  28494. /** @hidden */
  28495. _uniformBuffers: UniformBuffer[];
  28496. /**
  28497. * Gets a boolean indicating that the engine supports uniform buffers
  28498. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28499. */
  28500. readonly supportsUniformBuffers: boolean;
  28501. /**
  28502. * Observable raised when the engine begins a new frame
  28503. */
  28504. onBeginFrameObservable: Observable<Engine>;
  28505. /**
  28506. * If set, will be used to request the next animation frame for the render loop
  28507. */
  28508. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28509. /**
  28510. * Observable raised when the engine ends the current frame
  28511. */
  28512. onEndFrameObservable: Observable<Engine>;
  28513. /**
  28514. * Observable raised when the engine is about to compile a shader
  28515. */
  28516. onBeforeShaderCompilationObservable: Observable<Engine>;
  28517. /**
  28518. * Observable raised when the engine has jsut compiled a shader
  28519. */
  28520. onAfterShaderCompilationObservable: Observable<Engine>;
  28521. /** @hidden */
  28522. _gl: WebGLRenderingContext;
  28523. private _renderingCanvas;
  28524. private _windowIsBackground;
  28525. private _webGLVersion;
  28526. protected _highPrecisionShadersAllowed: boolean;
  28527. /** @hidden */
  28528. readonly _shouldUseHighPrecisionShader: boolean;
  28529. /**
  28530. * Gets a boolean indicating that only power of 2 textures are supported
  28531. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28532. */
  28533. readonly needPOTTextures: boolean;
  28534. /** @hidden */
  28535. _badOS: boolean;
  28536. /** @hidden */
  28537. _badDesktopOS: boolean;
  28538. /**
  28539. * Gets the audio engine
  28540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28541. * @ignorenaming
  28542. */
  28543. static audioEngine: IAudioEngine;
  28544. /**
  28545. * Default AudioEngine factory responsible of creating the Audio Engine.
  28546. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28547. */
  28548. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28549. /**
  28550. * Default offline support factory responsible of creating a tool used to store data locally.
  28551. * By default, this will create a Database object if the workload has been embedded.
  28552. */
  28553. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28554. private _onFocus;
  28555. private _onBlur;
  28556. private _onCanvasPointerOut;
  28557. private _onCanvasBlur;
  28558. private _onCanvasFocus;
  28559. private _onFullscreenChange;
  28560. private _onPointerLockChange;
  28561. private _hardwareScalingLevel;
  28562. /** @hidden */
  28563. _caps: EngineCapabilities;
  28564. private _pointerLockRequested;
  28565. private _isStencilEnable;
  28566. private _colorWrite;
  28567. private _loadingScreen;
  28568. /** @hidden */
  28569. _drawCalls: PerfCounter;
  28570. private _glVersion;
  28571. private _glRenderer;
  28572. private _glVendor;
  28573. private _videoTextureSupported;
  28574. private _renderingQueueLaunched;
  28575. private _activeRenderLoops;
  28576. private _deterministicLockstep;
  28577. private _lockstepMaxSteps;
  28578. /**
  28579. * Observable signaled when a context lost event is raised
  28580. */
  28581. onContextLostObservable: Observable<Engine>;
  28582. /**
  28583. * Observable signaled when a context restored event is raised
  28584. */
  28585. onContextRestoredObservable: Observable<Engine>;
  28586. private _onContextLost;
  28587. private _onContextRestored;
  28588. private _contextWasLost;
  28589. /** @hidden */
  28590. _doNotHandleContextLost: boolean;
  28591. /**
  28592. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28594. */
  28595. doNotHandleContextLost: boolean;
  28596. private _performanceMonitor;
  28597. private _fps;
  28598. private _deltaTime;
  28599. /**
  28600. * Turn this value on if you want to pause FPS computation when in background
  28601. */
  28602. disablePerformanceMonitorInBackground: boolean;
  28603. /**
  28604. * Gets the performance monitor attached to this engine
  28605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28606. */
  28607. readonly performanceMonitor: PerformanceMonitor;
  28608. /**
  28609. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28610. */
  28611. disableVertexArrayObjects: boolean;
  28612. /** @hidden */
  28613. protected _depthCullingState: _DepthCullingState;
  28614. /** @hidden */
  28615. protected _stencilState: _StencilState;
  28616. /** @hidden */
  28617. protected _alphaState: _AlphaState;
  28618. /** @hidden */
  28619. protected _alphaMode: number;
  28620. /** @hidden */
  28621. _internalTexturesCache: InternalTexture[];
  28622. /** @hidden */
  28623. protected _activeChannel: number;
  28624. private _currentTextureChannel;
  28625. /** @hidden */
  28626. protected _boundTexturesCache: {
  28627. [key: string]: Nullable<InternalTexture>;
  28628. };
  28629. /** @hidden */
  28630. protected _currentEffect: Nullable<Effect>;
  28631. /** @hidden */
  28632. protected _currentProgram: Nullable<WebGLProgram>;
  28633. private _compiledEffects;
  28634. private _vertexAttribArraysEnabled;
  28635. /** @hidden */
  28636. protected _cachedViewport: Nullable<Viewport>;
  28637. private _cachedVertexArrayObject;
  28638. /** @hidden */
  28639. protected _cachedVertexBuffers: any;
  28640. /** @hidden */
  28641. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28642. /** @hidden */
  28643. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28644. /** @hidden */
  28645. _currentRenderTarget: Nullable<InternalTexture>;
  28646. private _uintIndicesCurrentlySet;
  28647. private _currentBoundBuffer;
  28648. /** @hidden */
  28649. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28650. private _currentBufferPointers;
  28651. private _currentInstanceLocations;
  28652. private _currentInstanceBuffers;
  28653. private _textureUnits;
  28654. /** @hidden */
  28655. _workingCanvas: Nullable<HTMLCanvasElement>;
  28656. /** @hidden */
  28657. _workingContext: Nullable<CanvasRenderingContext2D>;
  28658. private _rescalePostProcess;
  28659. private _dummyFramebuffer;
  28660. private _externalData;
  28661. /** @hidden */
  28662. _bindedRenderFunction: any;
  28663. private _vaoRecordInProgress;
  28664. private _mustWipeVertexAttributes;
  28665. private _emptyTexture;
  28666. private _emptyCubeTexture;
  28667. private _emptyTexture3D;
  28668. /** @hidden */
  28669. _frameHandler: number;
  28670. private _nextFreeTextureSlots;
  28671. private _maxSimultaneousTextures;
  28672. private _activeRequests;
  28673. private _texturesSupported;
  28674. /** @hidden */
  28675. _textureFormatInUse: Nullable<string>;
  28676. /**
  28677. * Gets the list of texture formats supported
  28678. */
  28679. readonly texturesSupported: Array<string>;
  28680. /**
  28681. * Gets the list of texture formats in use
  28682. */
  28683. readonly textureFormatInUse: Nullable<string>;
  28684. /**
  28685. * Gets the current viewport
  28686. */
  28687. readonly currentViewport: Nullable<Viewport>;
  28688. /**
  28689. * Gets the default empty texture
  28690. */
  28691. readonly emptyTexture: InternalTexture;
  28692. /**
  28693. * Gets the default empty 3D texture
  28694. */
  28695. readonly emptyTexture3D: InternalTexture;
  28696. /**
  28697. * Gets the default empty cube texture
  28698. */
  28699. readonly emptyCubeTexture: InternalTexture;
  28700. /**
  28701. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28702. */
  28703. readonly premultipliedAlpha: boolean;
  28704. /**
  28705. * Creates a new engine
  28706. * @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
  28707. * @param antialias defines enable antialiasing (default: false)
  28708. * @param options defines further options to be sent to the getContext() function
  28709. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28710. */
  28711. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28712. /**
  28713. * Initializes a webVR display and starts listening to display change events
  28714. * The onVRDisplayChangedObservable will be notified upon these changes
  28715. * @returns The onVRDisplayChangedObservable
  28716. */
  28717. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28718. /** @hidden */
  28719. _prepareVRComponent(): void;
  28720. /** @hidden */
  28721. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28722. /** @hidden */
  28723. _submitVRFrame(): void;
  28724. /**
  28725. * Call this function to leave webVR mode
  28726. * Will do nothing if webVR is not supported or if there is no webVR device
  28727. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28728. */
  28729. disableVR(): void;
  28730. /**
  28731. * Gets a boolean indicating that the system is in VR mode and is presenting
  28732. * @returns true if VR mode is engaged
  28733. */
  28734. isVRPresenting(): boolean;
  28735. /** @hidden */
  28736. _requestVRFrame(): void;
  28737. private _disableTouchAction;
  28738. private _rebuildInternalTextures;
  28739. private _rebuildEffects;
  28740. /**
  28741. * Gets a boolean indicating if all created effects are ready
  28742. * @returns true if all effects are ready
  28743. */
  28744. areAllEffectsReady(): boolean;
  28745. private _rebuildBuffers;
  28746. private _initGLContext;
  28747. /**
  28748. * Gets version of the current webGL context
  28749. */
  28750. readonly webGLVersion: number;
  28751. /**
  28752. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28753. */
  28754. readonly isStencilEnable: boolean;
  28755. /** @hidden */
  28756. _prepareWorkingCanvas(): void;
  28757. /**
  28758. * Reset the texture cache to empty state
  28759. */
  28760. resetTextureCache(): void;
  28761. /**
  28762. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28764. * @returns true if engine is in deterministic lock step mode
  28765. */
  28766. isDeterministicLockStep(): boolean;
  28767. /**
  28768. * Gets the max steps when engine is running in deterministic lock step
  28769. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28770. * @returns the max steps
  28771. */
  28772. getLockstepMaxSteps(): number;
  28773. /**
  28774. * Gets an object containing information about the current webGL context
  28775. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28776. */
  28777. getGlInfo(): {
  28778. vendor: string;
  28779. renderer: string;
  28780. version: string;
  28781. };
  28782. /**
  28783. * Gets current aspect ratio
  28784. * @param camera defines the camera to use to get the aspect ratio
  28785. * @param useScreen defines if screen size must be used (or the current render target if any)
  28786. * @returns a number defining the aspect ratio
  28787. */
  28788. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28789. /**
  28790. * Gets current screen aspect ratio
  28791. * @returns a number defining the aspect ratio
  28792. */
  28793. getScreenAspectRatio(): number;
  28794. /**
  28795. * Gets the current render width
  28796. * @param useScreen defines if screen size must be used (or the current render target if any)
  28797. * @returns a number defining the current render width
  28798. */
  28799. getRenderWidth(useScreen?: boolean): number;
  28800. /**
  28801. * Gets the current render height
  28802. * @param useScreen defines if screen size must be used (or the current render target if any)
  28803. * @returns a number defining the current render height
  28804. */
  28805. getRenderHeight(useScreen?: boolean): number;
  28806. /**
  28807. * Gets the HTML canvas attached with the current webGL context
  28808. * @returns a HTML canvas
  28809. */
  28810. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28811. /**
  28812. * Gets the client rect of the HTML canvas attached with the current webGL context
  28813. * @returns a client rectanglee
  28814. */
  28815. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28816. /**
  28817. * Defines the hardware scaling level.
  28818. * By default the hardware scaling level is computed from the window device ratio.
  28819. * 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.
  28820. * @param level defines the level to use
  28821. */
  28822. setHardwareScalingLevel(level: number): void;
  28823. /**
  28824. * Gets the current hardware scaling level.
  28825. * By default the hardware scaling level is computed from the window device ratio.
  28826. * 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.
  28827. * @returns a number indicating the current hardware scaling level
  28828. */
  28829. getHardwareScalingLevel(): number;
  28830. /**
  28831. * Gets the list of loaded textures
  28832. * @returns an array containing all loaded textures
  28833. */
  28834. getLoadedTexturesCache(): InternalTexture[];
  28835. /**
  28836. * Gets the object containing all engine capabilities
  28837. * @returns the EngineCapabilities object
  28838. */
  28839. getCaps(): EngineCapabilities;
  28840. /**
  28841. * Gets the current depth function
  28842. * @returns a number defining the depth function
  28843. */
  28844. getDepthFunction(): Nullable<number>;
  28845. /**
  28846. * Sets the current depth function
  28847. * @param depthFunc defines the function to use
  28848. */
  28849. setDepthFunction(depthFunc: number): void;
  28850. /**
  28851. * Sets the current depth function to GREATER
  28852. */
  28853. setDepthFunctionToGreater(): void;
  28854. /**
  28855. * Sets the current depth function to GEQUAL
  28856. */
  28857. setDepthFunctionToGreaterOrEqual(): void;
  28858. /**
  28859. * Sets the current depth function to LESS
  28860. */
  28861. setDepthFunctionToLess(): void;
  28862. private _cachedStencilBuffer;
  28863. private _cachedStencilFunction;
  28864. private _cachedStencilMask;
  28865. private _cachedStencilOperationPass;
  28866. private _cachedStencilOperationFail;
  28867. private _cachedStencilOperationDepthFail;
  28868. private _cachedStencilReference;
  28869. /**
  28870. * Caches the the state of the stencil buffer
  28871. */
  28872. cacheStencilState(): void;
  28873. /**
  28874. * Restores the state of the stencil buffer
  28875. */
  28876. restoreStencilState(): void;
  28877. /**
  28878. * Sets the current depth function to LEQUAL
  28879. */
  28880. setDepthFunctionToLessOrEqual(): void;
  28881. /**
  28882. * Gets a boolean indicating if stencil buffer is enabled
  28883. * @returns the current stencil buffer state
  28884. */
  28885. getStencilBuffer(): boolean;
  28886. /**
  28887. * Enable or disable the stencil buffer
  28888. * @param enable defines if the stencil buffer must be enabled or disabled
  28889. */
  28890. setStencilBuffer(enable: boolean): void;
  28891. /**
  28892. * Gets the current stencil mask
  28893. * @returns a number defining the new stencil mask to use
  28894. */
  28895. getStencilMask(): number;
  28896. /**
  28897. * Sets the current stencil mask
  28898. * @param mask defines the new stencil mask to use
  28899. */
  28900. setStencilMask(mask: number): void;
  28901. /**
  28902. * Gets the current stencil function
  28903. * @returns a number defining the stencil function to use
  28904. */
  28905. getStencilFunction(): number;
  28906. /**
  28907. * Gets the current stencil reference value
  28908. * @returns a number defining the stencil reference value to use
  28909. */
  28910. getStencilFunctionReference(): number;
  28911. /**
  28912. * Gets the current stencil mask
  28913. * @returns a number defining the stencil mask to use
  28914. */
  28915. getStencilFunctionMask(): number;
  28916. /**
  28917. * Sets the current stencil function
  28918. * @param stencilFunc defines the new stencil function to use
  28919. */
  28920. setStencilFunction(stencilFunc: number): void;
  28921. /**
  28922. * Sets the current stencil reference
  28923. * @param reference defines the new stencil reference to use
  28924. */
  28925. setStencilFunctionReference(reference: number): void;
  28926. /**
  28927. * Sets the current stencil mask
  28928. * @param mask defines the new stencil mask to use
  28929. */
  28930. setStencilFunctionMask(mask: number): void;
  28931. /**
  28932. * Gets the current stencil operation when stencil fails
  28933. * @returns a number defining stencil operation to use when stencil fails
  28934. */
  28935. getStencilOperationFail(): number;
  28936. /**
  28937. * Gets the current stencil operation when depth fails
  28938. * @returns a number defining stencil operation to use when depth fails
  28939. */
  28940. getStencilOperationDepthFail(): number;
  28941. /**
  28942. * Gets the current stencil operation when stencil passes
  28943. * @returns a number defining stencil operation to use when stencil passes
  28944. */
  28945. getStencilOperationPass(): number;
  28946. /**
  28947. * Sets the stencil operation to use when stencil fails
  28948. * @param operation defines the stencil operation to use when stencil fails
  28949. */
  28950. setStencilOperationFail(operation: number): void;
  28951. /**
  28952. * Sets the stencil operation to use when depth fails
  28953. * @param operation defines the stencil operation to use when depth fails
  28954. */
  28955. setStencilOperationDepthFail(operation: number): void;
  28956. /**
  28957. * Sets the stencil operation to use when stencil passes
  28958. * @param operation defines the stencil operation to use when stencil passes
  28959. */
  28960. setStencilOperationPass(operation: number): void;
  28961. /**
  28962. * Sets a boolean indicating if the dithering state is enabled or disabled
  28963. * @param value defines the dithering state
  28964. */
  28965. setDitheringState(value: boolean): void;
  28966. /**
  28967. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28968. * @param value defines the rasterizer state
  28969. */
  28970. setRasterizerState(value: boolean): void;
  28971. /**
  28972. * stop executing a render loop function and remove it from the execution array
  28973. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28974. */
  28975. stopRenderLoop(renderFunction?: () => void): void;
  28976. /** @hidden */
  28977. _renderLoop(): void;
  28978. /**
  28979. * Register and execute a render loop. The engine can have more than one render function
  28980. * @param renderFunction defines the function to continuously execute
  28981. */
  28982. runRenderLoop(renderFunction: () => void): void;
  28983. /**
  28984. * Toggle full screen mode
  28985. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28986. */
  28987. switchFullscreen(requestPointerLock: boolean): void;
  28988. /**
  28989. * Enters full screen mode
  28990. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28991. */
  28992. enterFullscreen(requestPointerLock: boolean): void;
  28993. /**
  28994. * Exits full screen mode
  28995. */
  28996. exitFullscreen(): void;
  28997. /**
  28998. * Enters Pointerlock mode
  28999. */
  29000. enterPointerlock(): void;
  29001. /**
  29002. * Exits Pointerlock mode
  29003. */
  29004. exitPointerlock(): void;
  29005. /**
  29006. * Clear the current render buffer or the current render target (if any is set up)
  29007. * @param color defines the color to use
  29008. * @param backBuffer defines if the back buffer must be cleared
  29009. * @param depth defines if the depth buffer must be cleared
  29010. * @param stencil defines if the stencil buffer must be cleared
  29011. */
  29012. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29013. /**
  29014. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29015. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29016. * @param y defines the y-coordinate of the corner of the clear rectangle
  29017. * @param width defines the width of the clear rectangle
  29018. * @param height defines the height of the clear rectangle
  29019. * @param clearColor defines the clear color
  29020. */
  29021. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29022. /**
  29023. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29024. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29025. * @param y defines the y-coordinate of the corner of the clear rectangle
  29026. * @param width defines the width of the clear rectangle
  29027. * @param height defines the height of the clear rectangle
  29028. */
  29029. enableScissor(x: number, y: number, width: number, height: number): void;
  29030. /**
  29031. * Disable previously set scissor test rectangle
  29032. */
  29033. disableScissor(): void;
  29034. private _viewportCached;
  29035. /** @hidden */
  29036. _viewport(x: number, y: number, width: number, height: number): void;
  29037. /**
  29038. * Set the WebGL's viewport
  29039. * @param viewport defines the viewport element to be used
  29040. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29041. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29042. */
  29043. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29044. /**
  29045. * Directly set the WebGL Viewport
  29046. * @param x defines the x coordinate of the viewport (in screen space)
  29047. * @param y defines the y coordinate of the viewport (in screen space)
  29048. * @param width defines the width of the viewport (in screen space)
  29049. * @param height defines the height of the viewport (in screen space)
  29050. * @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
  29051. */
  29052. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29053. /**
  29054. * Begin a new frame
  29055. */
  29056. beginFrame(): void;
  29057. /**
  29058. * Enf the current frame
  29059. */
  29060. endFrame(): void;
  29061. /**
  29062. * Resize the view according to the canvas' size
  29063. */
  29064. resize(): void;
  29065. /**
  29066. * Force a specific size of the canvas
  29067. * @param width defines the new canvas' width
  29068. * @param height defines the new canvas' height
  29069. */
  29070. setSize(width: number, height: number): void;
  29071. /**
  29072. * Binds the frame buffer to the specified texture.
  29073. * @param texture The texture to render to or null for the default canvas
  29074. * @param faceIndex The face of the texture to render to in case of cube texture
  29075. * @param requiredWidth The width of the target to render to
  29076. * @param requiredHeight The height of the target to render to
  29077. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29078. * @param depthStencilTexture The depth stencil texture to use to render
  29079. * @param lodLevel defines le lod level to bind to the frame buffer
  29080. */
  29081. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29082. /** @hidden */
  29083. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29084. /**
  29085. * Unbind the current render target texture from the webGL context
  29086. * @param texture defines the render target texture to unbind
  29087. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29088. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29089. */
  29090. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29091. /**
  29092. * Force the mipmap generation for the given render target texture
  29093. * @param texture defines the render target texture to use
  29094. */
  29095. generateMipMapsForCubemap(texture: InternalTexture): void;
  29096. /**
  29097. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29098. */
  29099. flushFramebuffer(): void;
  29100. /**
  29101. * Unbind the current render target and bind the default framebuffer
  29102. */
  29103. restoreDefaultFramebuffer(): void;
  29104. /**
  29105. * Create an uniform buffer
  29106. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29107. * @param elements defines the content of the uniform buffer
  29108. * @returns the webGL uniform buffer
  29109. */
  29110. createUniformBuffer(elements: FloatArray): DataBuffer;
  29111. /**
  29112. * Create a dynamic uniform buffer
  29113. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29114. * @param elements defines the content of the uniform buffer
  29115. * @returns the webGL uniform buffer
  29116. */
  29117. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29118. /**
  29119. * Update an existing uniform buffer
  29120. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29121. * @param uniformBuffer defines the target uniform buffer
  29122. * @param elements defines the content to update
  29123. * @param offset defines the offset in the uniform buffer where update should start
  29124. * @param count defines the size of the data to update
  29125. */
  29126. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29127. private _resetVertexBufferBinding;
  29128. /**
  29129. * Creates a vertex buffer
  29130. * @param data the data for the vertex buffer
  29131. * @returns the new WebGL static buffer
  29132. */
  29133. createVertexBuffer(data: DataArray): DataBuffer;
  29134. /**
  29135. * Creates a dynamic vertex buffer
  29136. * @param data the data for the dynamic vertex buffer
  29137. * @returns the new WebGL dynamic buffer
  29138. */
  29139. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29140. /**
  29141. * Update a dynamic index buffer
  29142. * @param indexBuffer defines the target index buffer
  29143. * @param indices defines the data to update
  29144. * @param offset defines the offset in the target index buffer where update should start
  29145. */
  29146. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29147. /**
  29148. * Updates a dynamic vertex buffer.
  29149. * @param vertexBuffer the vertex buffer to update
  29150. * @param data the data used to update the vertex buffer
  29151. * @param byteOffset the byte offset of the data
  29152. * @param byteLength the byte length of the data
  29153. */
  29154. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29155. private _resetIndexBufferBinding;
  29156. /**
  29157. * Creates a new index buffer
  29158. * @param indices defines the content of the index buffer
  29159. * @param updatable defines if the index buffer must be updatable
  29160. * @returns a new webGL buffer
  29161. */
  29162. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29163. /**
  29164. * Bind a webGL buffer to the webGL context
  29165. * @param buffer defines the buffer to bind
  29166. */
  29167. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29168. /**
  29169. * Bind an uniform buffer to the current webGL context
  29170. * @param buffer defines the buffer to bind
  29171. */
  29172. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29173. /**
  29174. * Bind a buffer to the current webGL context at a given location
  29175. * @param buffer defines the buffer to bind
  29176. * @param location defines the index where to bind the buffer
  29177. */
  29178. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29179. /**
  29180. * Bind a specific block at a given index in a specific shader program
  29181. * @param pipelineContext defines the pipeline context to use
  29182. * @param blockName defines the block name
  29183. * @param index defines the index where to bind the block
  29184. */
  29185. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29186. private bindIndexBuffer;
  29187. private bindBuffer;
  29188. /**
  29189. * update the bound buffer with the given data
  29190. * @param data defines the data to update
  29191. */
  29192. updateArrayBuffer(data: Float32Array): void;
  29193. private _vertexAttribPointer;
  29194. private _bindIndexBufferWithCache;
  29195. private _bindVertexBuffersAttributes;
  29196. /**
  29197. * Records a vertex array object
  29198. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29199. * @param vertexBuffers defines the list of vertex buffers to store
  29200. * @param indexBuffer defines the index buffer to store
  29201. * @param effect defines the effect to store
  29202. * @returns the new vertex array object
  29203. */
  29204. recordVertexArrayObject(vertexBuffers: {
  29205. [key: string]: VertexBuffer;
  29206. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29207. /**
  29208. * Bind a specific vertex array object
  29209. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29210. * @param vertexArrayObject defines the vertex array object to bind
  29211. * @param indexBuffer defines the index buffer to bind
  29212. */
  29213. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29214. /**
  29215. * Bind webGl buffers directly to the webGL context
  29216. * @param vertexBuffer defines the vertex buffer to bind
  29217. * @param indexBuffer defines the index buffer to bind
  29218. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29219. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29220. * @param effect defines the effect associated with the vertex buffer
  29221. */
  29222. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29223. private _unbindVertexArrayObject;
  29224. /**
  29225. * Bind a list of vertex buffers to the webGL context
  29226. * @param vertexBuffers defines the list of vertex buffers to bind
  29227. * @param indexBuffer defines the index buffer to bind
  29228. * @param effect defines the effect associated with the vertex buffers
  29229. */
  29230. bindBuffers(vertexBuffers: {
  29231. [key: string]: Nullable<VertexBuffer>;
  29232. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29233. /**
  29234. * Unbind all instance attributes
  29235. */
  29236. unbindInstanceAttributes(): void;
  29237. /**
  29238. * Release and free the memory of a vertex array object
  29239. * @param vao defines the vertex array object to delete
  29240. */
  29241. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29242. /** @hidden */
  29243. _releaseBuffer(buffer: DataBuffer): boolean;
  29244. /**
  29245. * Creates a webGL buffer to use with instanciation
  29246. * @param capacity defines the size of the buffer
  29247. * @returns the webGL buffer
  29248. */
  29249. createInstancesBuffer(capacity: number): DataBuffer;
  29250. /**
  29251. * Delete a webGL buffer used with instanciation
  29252. * @param buffer defines the webGL buffer to delete
  29253. */
  29254. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29255. /**
  29256. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29257. * @param instancesBuffer defines the webGL buffer to update and bind
  29258. * @param data defines the data to store in the buffer
  29259. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29260. */
  29261. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29262. /**
  29263. * Apply all cached states (depth, culling, stencil and alpha)
  29264. */
  29265. applyStates(): void;
  29266. /**
  29267. * Send a draw order
  29268. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29269. * @param indexStart defines the starting index
  29270. * @param indexCount defines the number of index to draw
  29271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29272. */
  29273. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29274. /**
  29275. * Draw a list of points
  29276. * @param verticesStart defines the index of first vertex to draw
  29277. * @param verticesCount defines the count of vertices to draw
  29278. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29279. */
  29280. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29281. /**
  29282. * Draw a list of unindexed primitives
  29283. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29284. * @param verticesStart defines the index of first vertex to draw
  29285. * @param verticesCount defines the count of vertices to draw
  29286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29287. */
  29288. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29289. /**
  29290. * Draw a list of indexed primitives
  29291. * @param fillMode defines the primitive to use
  29292. * @param indexStart defines the starting index
  29293. * @param indexCount defines the number of index to draw
  29294. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29295. */
  29296. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29297. /**
  29298. * Draw a list of unindexed primitives
  29299. * @param fillMode defines the primitive to use
  29300. * @param verticesStart defines the index of first vertex to draw
  29301. * @param verticesCount defines the count of vertices to draw
  29302. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29303. */
  29304. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29305. private _drawMode;
  29306. /** @hidden */
  29307. _releaseEffect(effect: Effect): void;
  29308. /** @hidden */
  29309. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29310. /**
  29311. * Create a new effect (used to store vertex/fragment shaders)
  29312. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29313. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29314. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29315. * @param samplers defines an array of string used to represent textures
  29316. * @param defines defines the string containing the defines to use to compile the shaders
  29317. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29318. * @param onCompiled defines a function to call when the effect creation is successful
  29319. * @param onError defines a function to call when the effect creation has failed
  29320. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29321. * @returns the new Effect
  29322. */
  29323. 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;
  29324. private _compileShader;
  29325. private _compileRawShader;
  29326. /**
  29327. * Directly creates a webGL program
  29328. * @param pipelineContext defines the pipeline context to attach to
  29329. * @param vertexCode defines the vertex shader code to use
  29330. * @param fragmentCode defines the fragment shader code to use
  29331. * @param context defines the webGL context to use (if not set, the current one will be used)
  29332. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29333. * @returns the new webGL program
  29334. */
  29335. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29336. /**
  29337. * Creates a webGL program
  29338. * @param pipelineContext defines the pipeline context to attach to
  29339. * @param vertexCode defines the vertex shader code to use
  29340. * @param fragmentCode defines the fragment shader code to use
  29341. * @param defines defines the string containing the defines to use to compile the shaders
  29342. * @param context defines the webGL context to use (if not set, the current one will be used)
  29343. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29344. * @returns the new webGL program
  29345. */
  29346. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29347. /**
  29348. * Creates a new pipeline context
  29349. * @returns the new pipeline
  29350. */
  29351. createPipelineContext(): WebGLPipelineContext;
  29352. private _createShaderProgram;
  29353. private _finalizePipelineContext;
  29354. /** @hidden */
  29355. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29356. /** @hidden */
  29357. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29358. /** @hidden */
  29359. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29360. /**
  29361. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29362. * @param pipelineContext defines the pipeline context to use
  29363. * @param uniformsNames defines the list of uniform names
  29364. * @returns an array of webGL uniform locations
  29365. */
  29366. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29367. /**
  29368. * Gets the lsit of active attributes for a given webGL program
  29369. * @param pipelineContext defines the pipeline context to use
  29370. * @param attributesNames defines the list of attribute names to get
  29371. * @returns an array of indices indicating the offset of each attribute
  29372. */
  29373. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29374. /**
  29375. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29376. * @param effect defines the effect to activate
  29377. */
  29378. enableEffect(effect: Nullable<Effect>): void;
  29379. /**
  29380. * Set the value of an uniform to an array of int32
  29381. * @param uniform defines the webGL uniform location where to store the value
  29382. * @param array defines the array of int32 to store
  29383. */
  29384. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29385. /**
  29386. * Set the value of an uniform to an array of int32 (stored as vec2)
  29387. * @param uniform defines the webGL uniform location where to store the value
  29388. * @param array defines the array of int32 to store
  29389. */
  29390. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29391. /**
  29392. * Set the value of an uniform to an array of int32 (stored as vec3)
  29393. * @param uniform defines the webGL uniform location where to store the value
  29394. * @param array defines the array of int32 to store
  29395. */
  29396. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29397. /**
  29398. * Set the value of an uniform to an array of int32 (stored as vec4)
  29399. * @param uniform defines the webGL uniform location where to store the value
  29400. * @param array defines the array of int32 to store
  29401. */
  29402. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29403. /**
  29404. * Set the value of an uniform to an array of float32
  29405. * @param uniform defines the webGL uniform location where to store the value
  29406. * @param array defines the array of float32 to store
  29407. */
  29408. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29409. /**
  29410. * Set the value of an uniform to an array of float32 (stored as vec2)
  29411. * @param uniform defines the webGL uniform location where to store the value
  29412. * @param array defines the array of float32 to store
  29413. */
  29414. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29415. /**
  29416. * Set the value of an uniform to an array of float32 (stored as vec3)
  29417. * @param uniform defines the webGL uniform location where to store the value
  29418. * @param array defines the array of float32 to store
  29419. */
  29420. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29421. /**
  29422. * Set the value of an uniform to an array of float32 (stored as vec4)
  29423. * @param uniform defines the webGL uniform location where to store the value
  29424. * @param array defines the array of float32 to store
  29425. */
  29426. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29427. /**
  29428. * Set the value of an uniform to an array of number
  29429. * @param uniform defines the webGL uniform location where to store the value
  29430. * @param array defines the array of number to store
  29431. */
  29432. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29433. /**
  29434. * Set the value of an uniform to an array of number (stored as vec2)
  29435. * @param uniform defines the webGL uniform location where to store the value
  29436. * @param array defines the array of number to store
  29437. */
  29438. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29439. /**
  29440. * Set the value of an uniform to an array of number (stored as vec3)
  29441. * @param uniform defines the webGL uniform location where to store the value
  29442. * @param array defines the array of number to store
  29443. */
  29444. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29445. /**
  29446. * Set the value of an uniform to an array of number (stored as vec4)
  29447. * @param uniform defines the webGL uniform location where to store the value
  29448. * @param array defines the array of number to store
  29449. */
  29450. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29451. /**
  29452. * Set the value of an uniform to an array of float32 (stored as matrices)
  29453. * @param uniform defines the webGL uniform location where to store the value
  29454. * @param matrices defines the array of float32 to store
  29455. */
  29456. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29457. /**
  29458. * Set the value of an uniform to a matrix
  29459. * @param uniform defines the webGL uniform location where to store the value
  29460. * @param matrix defines the matrix to store
  29461. */
  29462. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29463. /**
  29464. * Set the value of an uniform to a matrix (3x3)
  29465. * @param uniform defines the webGL uniform location where to store the value
  29466. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29467. */
  29468. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29469. /**
  29470. * Set the value of an uniform to a matrix (2x2)
  29471. * @param uniform defines the webGL uniform location where to store the value
  29472. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29473. */
  29474. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29475. /**
  29476. * Set the value of an uniform to a number (int)
  29477. * @param uniform defines the webGL uniform location where to store the value
  29478. * @param value defines the int number to store
  29479. */
  29480. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29481. /**
  29482. * Set the value of an uniform to a number (float)
  29483. * @param uniform defines the webGL uniform location where to store the value
  29484. * @param value defines the float number to store
  29485. */
  29486. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29487. /**
  29488. * Set the value of an uniform to a vec2
  29489. * @param uniform defines the webGL uniform location where to store the value
  29490. * @param x defines the 1st component of the value
  29491. * @param y defines the 2nd component of the value
  29492. */
  29493. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29494. /**
  29495. * Set the value of an uniform to a vec3
  29496. * @param uniform defines the webGL uniform location where to store the value
  29497. * @param x defines the 1st component of the value
  29498. * @param y defines the 2nd component of the value
  29499. * @param z defines the 3rd component of the value
  29500. */
  29501. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29502. /**
  29503. * Set the value of an uniform to a boolean
  29504. * @param uniform defines the webGL uniform location where to store the value
  29505. * @param bool defines the boolean to store
  29506. */
  29507. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29508. /**
  29509. * Set the value of an uniform to a vec4
  29510. * @param uniform defines the webGL uniform location where to store the value
  29511. * @param x defines the 1st component of the value
  29512. * @param y defines the 2nd component of the value
  29513. * @param z defines the 3rd component of the value
  29514. * @param w defines the 4th component of the value
  29515. */
  29516. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29517. /**
  29518. * Set the value of an uniform to a Color3
  29519. * @param uniform defines the webGL uniform location where to store the value
  29520. * @param color3 defines the color to store
  29521. */
  29522. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29523. /**
  29524. * Set the value of an uniform to a Color3 and an alpha value
  29525. * @param uniform defines the webGL uniform location where to store the value
  29526. * @param color3 defines the color to store
  29527. * @param alpha defines the alpha component to store
  29528. */
  29529. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29530. /**
  29531. * Sets a Color4 on a uniform variable
  29532. * @param uniform defines the uniform location
  29533. * @param color4 defines the value to be set
  29534. */
  29535. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29536. /**
  29537. * Set various states to the webGL context
  29538. * @param culling defines backface culling state
  29539. * @param zOffset defines the value to apply to zOffset (0 by default)
  29540. * @param force defines if states must be applied even if cache is up to date
  29541. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29542. */
  29543. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29544. /**
  29545. * Set the z offset to apply to current rendering
  29546. * @param value defines the offset to apply
  29547. */
  29548. setZOffset(value: number): void;
  29549. /**
  29550. * Gets the current value of the zOffset
  29551. * @returns the current zOffset state
  29552. */
  29553. getZOffset(): number;
  29554. /**
  29555. * Enable or disable depth buffering
  29556. * @param enable defines the state to set
  29557. */
  29558. setDepthBuffer(enable: boolean): void;
  29559. /**
  29560. * Gets a boolean indicating if depth writing is enabled
  29561. * @returns the current depth writing state
  29562. */
  29563. getDepthWrite(): boolean;
  29564. /**
  29565. * Enable or disable depth writing
  29566. * @param enable defines the state to set
  29567. */
  29568. setDepthWrite(enable: boolean): void;
  29569. /**
  29570. * Enable or disable color writing
  29571. * @param enable defines the state to set
  29572. */
  29573. setColorWrite(enable: boolean): void;
  29574. /**
  29575. * Gets a boolean indicating if color writing is enabled
  29576. * @returns the current color writing state
  29577. */
  29578. getColorWrite(): boolean;
  29579. /**
  29580. * Sets alpha constants used by some alpha blending modes
  29581. * @param r defines the red component
  29582. * @param g defines the green component
  29583. * @param b defines the blue component
  29584. * @param a defines the alpha component
  29585. */
  29586. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29587. /**
  29588. * Sets the current alpha mode
  29589. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29590. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29591. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29592. */
  29593. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29594. /**
  29595. * Gets the current alpha mode
  29596. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29597. * @returns the current alpha mode
  29598. */
  29599. getAlphaMode(): number;
  29600. /**
  29601. * Clears the list of texture accessible through engine.
  29602. * This can help preventing texture load conflict due to name collision.
  29603. */
  29604. clearInternalTexturesCache(): void;
  29605. /**
  29606. * Force the entire cache to be cleared
  29607. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29608. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29609. */
  29610. wipeCaches(bruteForce?: boolean): void;
  29611. /**
  29612. * Set the compressed texture format to use, based on the formats you have, and the formats
  29613. * supported by the hardware / browser.
  29614. *
  29615. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29616. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29617. * to API arguments needed to compressed textures. This puts the burden on the container
  29618. * generator to house the arcane code for determining these for current & future formats.
  29619. *
  29620. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29621. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29622. *
  29623. * Note: The result of this call is not taken into account when a texture is base64.
  29624. *
  29625. * @param formatsAvailable defines the list of those format families you have created
  29626. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29627. *
  29628. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29629. * @returns The extension selected.
  29630. */
  29631. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29632. /** @hidden */
  29633. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29634. min: number;
  29635. mag: number;
  29636. };
  29637. /** @hidden */
  29638. _createTexture(): WebGLTexture;
  29639. /**
  29640. * Usually called from Texture.ts.
  29641. * Passed information to create a WebGLTexture
  29642. * @param urlArg defines a value which contains one of the following:
  29643. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29644. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29645. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29646. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29647. * @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)
  29648. * @param scene needed for loading to the correct scene
  29649. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29650. * @param onLoad optional callback to be called upon successful completion
  29651. * @param onError optional callback to be called upon failure
  29652. * @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
  29653. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29654. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29655. * @param forcedExtension defines the extension to use to pick the right loader
  29656. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29657. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29658. */
  29659. 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;
  29660. /**
  29661. * @hidden
  29662. * Rescales a texture
  29663. * @param source input texutre
  29664. * @param destination destination texture
  29665. * @param scene scene to use to render the resize
  29666. * @param internalFormat format to use when resizing
  29667. * @param onComplete callback to be called when resize has completed
  29668. */
  29669. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29670. private _unpackFlipYCached;
  29671. /**
  29672. * In case you are sharing the context with other applications, it might
  29673. * be interested to not cache the unpack flip y state to ensure a consistent
  29674. * value would be set.
  29675. */
  29676. enableUnpackFlipYCached: boolean;
  29677. /** @hidden */
  29678. _unpackFlipY(value: boolean): void;
  29679. /** @hidden */
  29680. _getUnpackAlignement(): number;
  29681. /**
  29682. * Creates a dynamic texture
  29683. * @param width defines the width of the texture
  29684. * @param height defines the height of the texture
  29685. * @param generateMipMaps defines if the engine should generate the mip levels
  29686. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29687. * @returns the dynamic texture inside an InternalTexture
  29688. */
  29689. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29690. /**
  29691. * Update the sampling mode of a given texture
  29692. * @param samplingMode defines the required sampling mode
  29693. * @param texture defines the texture to update
  29694. */
  29695. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29696. /**
  29697. * Update the content of a dynamic texture
  29698. * @param texture defines the texture to update
  29699. * @param canvas defines the canvas containing the source
  29700. * @param invertY defines if data must be stored with Y axis inverted
  29701. * @param premulAlpha defines if alpha is stored as premultiplied
  29702. * @param format defines the format of the data
  29703. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29704. */
  29705. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29706. /**
  29707. * Update a video texture
  29708. * @param texture defines the texture to update
  29709. * @param video defines the video element to use
  29710. * @param invertY defines if data must be stored with Y axis inverted
  29711. */
  29712. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29713. /**
  29714. * Updates a depth texture Comparison Mode and Function.
  29715. * If the comparison Function is equal to 0, the mode will be set to none.
  29716. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29717. * @param texture The texture to set the comparison function for
  29718. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29719. */
  29720. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29721. /** @hidden */
  29722. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29723. width: number;
  29724. height: number;
  29725. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29726. /**
  29727. * Creates a depth stencil texture.
  29728. * This is only available in WebGL 2 or with the depth texture extension available.
  29729. * @param size The size of face edge in the texture.
  29730. * @param options The options defining the texture.
  29731. * @returns The texture
  29732. */
  29733. createDepthStencilTexture(size: number | {
  29734. width: number;
  29735. height: number;
  29736. }, options: DepthTextureCreationOptions): InternalTexture;
  29737. /**
  29738. * Creates a depth stencil texture.
  29739. * This is only available in WebGL 2 or with the depth texture extension available.
  29740. * @param size The size of face edge in the texture.
  29741. * @param options The options defining the texture.
  29742. * @returns The texture
  29743. */
  29744. private _createDepthStencilTexture;
  29745. /**
  29746. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29747. * @param renderTarget The render target to set the frame buffer for
  29748. */
  29749. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29750. /**
  29751. * Creates a new render target texture
  29752. * @param size defines the size of the texture
  29753. * @param options defines the options used to create the texture
  29754. * @returns a new render target texture stored in an InternalTexture
  29755. */
  29756. createRenderTargetTexture(size: number | {
  29757. width: number;
  29758. height: number;
  29759. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29760. /** @hidden */
  29761. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29762. /**
  29763. * Updates the sample count of a render target texture
  29764. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29765. * @param texture defines the texture to update
  29766. * @param samples defines the sample count to set
  29767. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29768. */
  29769. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29770. /** @hidden */
  29771. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29772. /** @hidden */
  29773. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29774. /** @hidden */
  29775. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29776. /** @hidden */
  29777. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29778. /**
  29779. * @hidden
  29780. */
  29781. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29782. private _prepareWebGLTextureContinuation;
  29783. private _prepareWebGLTexture;
  29784. /** @hidden */
  29785. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29786. /** @hidden */
  29787. _releaseFramebufferObjects(texture: InternalTexture): void;
  29788. /** @hidden */
  29789. _releaseTexture(texture: InternalTexture): void;
  29790. private setProgram;
  29791. private _boundUniforms;
  29792. /**
  29793. * Binds an effect to the webGL context
  29794. * @param effect defines the effect to bind
  29795. */
  29796. bindSamplers(effect: Effect): void;
  29797. private _activateCurrentTexture;
  29798. /** @hidden */
  29799. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29800. /** @hidden */
  29801. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29802. /**
  29803. * Sets a texture to the webGL context from a postprocess
  29804. * @param channel defines the channel to use
  29805. * @param postProcess defines the source postprocess
  29806. */
  29807. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29808. /**
  29809. * Binds the output of the passed in post process to the texture channel specified
  29810. * @param channel The channel the texture should be bound to
  29811. * @param postProcess The post process which's output should be bound
  29812. */
  29813. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29814. /**
  29815. * Unbind all textures from the webGL context
  29816. */
  29817. unbindAllTextures(): void;
  29818. /**
  29819. * Sets a texture to the according uniform.
  29820. * @param channel The texture channel
  29821. * @param uniform The uniform to set
  29822. * @param texture The texture to apply
  29823. */
  29824. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29825. /**
  29826. * Sets a depth stencil texture from a render target to the according uniform.
  29827. * @param channel The texture channel
  29828. * @param uniform The uniform to set
  29829. * @param texture The render target texture containing the depth stencil texture to apply
  29830. */
  29831. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29832. private _bindSamplerUniformToChannel;
  29833. private _getTextureWrapMode;
  29834. private _setTexture;
  29835. /**
  29836. * Sets an array of texture to the webGL context
  29837. * @param channel defines the channel where the texture array must be set
  29838. * @param uniform defines the associated uniform location
  29839. * @param textures defines the array of textures to bind
  29840. */
  29841. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29842. /** @hidden */
  29843. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29844. private _setTextureParameterFloat;
  29845. private _setTextureParameterInteger;
  29846. /**
  29847. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29848. * @param x defines the x coordinate of the rectangle where pixels must be read
  29849. * @param y defines the y coordinate of the rectangle where pixels must be read
  29850. * @param width defines the width of the rectangle where pixels must be read
  29851. * @param height defines the height of the rectangle where pixels must be read
  29852. * @returns a Uint8Array containing RGBA colors
  29853. */
  29854. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29855. /**
  29856. * Add an externaly attached data from its key.
  29857. * This method call will fail and return false, if such key already exists.
  29858. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29859. * @param key the unique key that identifies the data
  29860. * @param data the data object to associate to the key for this Engine instance
  29861. * @return true if no such key were already present and the data was added successfully, false otherwise
  29862. */
  29863. addExternalData<T>(key: string, data: T): boolean;
  29864. /**
  29865. * Get an externaly attached data from its key
  29866. * @param key the unique key that identifies the data
  29867. * @return the associated data, if present (can be null), or undefined if not present
  29868. */
  29869. getExternalData<T>(key: string): T;
  29870. /**
  29871. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29872. * @param key the unique key that identifies the data
  29873. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29874. * @return the associated data, can be null if the factory returned null.
  29875. */
  29876. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29877. /**
  29878. * Remove an externaly attached data from the Engine instance
  29879. * @param key the unique key that identifies the data
  29880. * @return true if the data was successfully removed, false if it doesn't exist
  29881. */
  29882. removeExternalData(key: string): boolean;
  29883. /**
  29884. * Unbind all vertex attributes from the webGL context
  29885. */
  29886. unbindAllAttributes(): void;
  29887. /**
  29888. * 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
  29889. */
  29890. releaseEffects(): void;
  29891. /**
  29892. * Dispose and release all associated resources
  29893. */
  29894. dispose(): void;
  29895. /**
  29896. * Display the loading screen
  29897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29898. */
  29899. displayLoadingUI(): void;
  29900. /**
  29901. * Hide the loading screen
  29902. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29903. */
  29904. hideLoadingUI(): void;
  29905. /**
  29906. * Gets the current loading screen object
  29907. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29908. */
  29909. /**
  29910. * Sets the current loading screen object
  29911. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29912. */
  29913. loadingScreen: ILoadingScreen;
  29914. /**
  29915. * Sets the current loading screen text
  29916. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29917. */
  29918. loadingUIText: string;
  29919. /**
  29920. * Sets the current loading screen background color
  29921. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29922. */
  29923. loadingUIBackgroundColor: string;
  29924. /**
  29925. * Attach a new callback raised when context lost event is fired
  29926. * @param callback defines the callback to call
  29927. */
  29928. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29929. /**
  29930. * Attach a new callback raised when context restored event is fired
  29931. * @param callback defines the callback to call
  29932. */
  29933. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29934. /**
  29935. * Gets the source code of the vertex shader associated with a specific webGL program
  29936. * @param program defines the program to use
  29937. * @returns a string containing the source code of the vertex shader associated with the program
  29938. */
  29939. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29940. /**
  29941. * Gets the source code of the fragment shader associated with a specific webGL program
  29942. * @param program defines the program to use
  29943. * @returns a string containing the source code of the fragment shader associated with the program
  29944. */
  29945. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29946. /**
  29947. * Get the current error code of the webGL context
  29948. * @returns the error code
  29949. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29950. */
  29951. getError(): number;
  29952. /**
  29953. * Gets the current framerate
  29954. * @returns a number representing the framerate
  29955. */
  29956. getFps(): number;
  29957. /**
  29958. * Gets the time spent between current and previous frame
  29959. * @returns a number representing the delta time in ms
  29960. */
  29961. getDeltaTime(): number;
  29962. private _measureFps;
  29963. /** @hidden */
  29964. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29965. private _canRenderToFloatFramebuffer;
  29966. private _canRenderToHalfFloatFramebuffer;
  29967. private _canRenderToFramebuffer;
  29968. /** @hidden */
  29969. _getWebGLTextureType(type: number): number;
  29970. /** @hidden */
  29971. _getInternalFormat(format: number): number;
  29972. /** @hidden */
  29973. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29974. /** @hidden */
  29975. _getRGBAMultiSampleBufferFormat(type: number): number;
  29976. /** @hidden */
  29977. _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;
  29978. /** @hidden */
  29979. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29980. /**
  29981. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29982. * @returns true if the engine can be created
  29983. * @ignorenaming
  29984. */
  29985. static isSupported(): boolean;
  29986. }
  29987. }
  29988. declare module "babylonjs/Materials/effect" {
  29989. import { Observable } from "babylonjs/Misc/observable";
  29990. import { Nullable } from "babylonjs/types";
  29991. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29992. import { IDisposable } from "babylonjs/scene";
  29993. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29994. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29995. import { Engine } from "babylonjs/Engines/engine";
  29996. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29998. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29999. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30001. /**
  30002. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30003. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30004. */
  30005. export class EffectFallbacks {
  30006. private _defines;
  30007. private _currentRank;
  30008. private _maxRank;
  30009. private _mesh;
  30010. /**
  30011. * Removes the fallback from the bound mesh.
  30012. */
  30013. unBindMesh(): void;
  30014. /**
  30015. * Adds a fallback on the specified property.
  30016. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30017. * @param define The name of the define in the shader
  30018. */
  30019. addFallback(rank: number, define: string): void;
  30020. /**
  30021. * Sets the mesh to use CPU skinning when needing to fallback.
  30022. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30023. * @param mesh The mesh to use the fallbacks.
  30024. */
  30025. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30026. /**
  30027. * Checks to see if more fallbacks are still availible.
  30028. */
  30029. readonly isMoreFallbacks: boolean;
  30030. /**
  30031. * Removes the defines that should be removed when falling back.
  30032. * @param currentDefines defines the current define statements for the shader.
  30033. * @param effect defines the current effect we try to compile
  30034. * @returns The resulting defines with defines of the current rank removed.
  30035. */
  30036. reduce(currentDefines: string, effect: Effect): string;
  30037. }
  30038. /**
  30039. * Options to be used when creating an effect.
  30040. */
  30041. export class EffectCreationOptions {
  30042. /**
  30043. * Atrributes that will be used in the shader.
  30044. */
  30045. attributes: string[];
  30046. /**
  30047. * Uniform varible names that will be set in the shader.
  30048. */
  30049. uniformsNames: string[];
  30050. /**
  30051. * Uniform buffer varible names that will be set in the shader.
  30052. */
  30053. uniformBuffersNames: string[];
  30054. /**
  30055. * Sampler texture variable names that will be set in the shader.
  30056. */
  30057. samplers: string[];
  30058. /**
  30059. * Define statements that will be set in the shader.
  30060. */
  30061. defines: any;
  30062. /**
  30063. * Possible fallbacks for this effect to improve performance when needed.
  30064. */
  30065. fallbacks: Nullable<EffectFallbacks>;
  30066. /**
  30067. * Callback that will be called when the shader is compiled.
  30068. */
  30069. onCompiled: Nullable<(effect: Effect) => void>;
  30070. /**
  30071. * Callback that will be called if an error occurs during shader compilation.
  30072. */
  30073. onError: Nullable<(effect: Effect, errors: string) => void>;
  30074. /**
  30075. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30076. */
  30077. indexParameters: any;
  30078. /**
  30079. * Max number of lights that can be used in the shader.
  30080. */
  30081. maxSimultaneousLights: number;
  30082. /**
  30083. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30084. */
  30085. transformFeedbackVaryings: Nullable<string[]>;
  30086. }
  30087. /**
  30088. * Effect containing vertex and fragment shader that can be executed on an object.
  30089. */
  30090. export class Effect implements IDisposable {
  30091. /**
  30092. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30093. */
  30094. static ShadersRepository: string;
  30095. /**
  30096. * Name of the effect.
  30097. */
  30098. name: any;
  30099. /**
  30100. * String container all the define statements that should be set on the shader.
  30101. */
  30102. defines: string;
  30103. /**
  30104. * Callback that will be called when the shader is compiled.
  30105. */
  30106. onCompiled: Nullable<(effect: Effect) => void>;
  30107. /**
  30108. * Callback that will be called if an error occurs during shader compilation.
  30109. */
  30110. onError: Nullable<(effect: Effect, errors: string) => void>;
  30111. /**
  30112. * Callback that will be called when effect is bound.
  30113. */
  30114. onBind: Nullable<(effect: Effect) => void>;
  30115. /**
  30116. * Unique ID of the effect.
  30117. */
  30118. uniqueId: number;
  30119. /**
  30120. * Observable that will be called when the shader is compiled.
  30121. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30122. */
  30123. onCompileObservable: Observable<Effect>;
  30124. /**
  30125. * Observable that will be called if an error occurs during shader compilation.
  30126. */
  30127. onErrorObservable: Observable<Effect>;
  30128. /** @hidden */
  30129. _onBindObservable: Nullable<Observable<Effect>>;
  30130. /**
  30131. * Observable that will be called when effect is bound.
  30132. */
  30133. readonly onBindObservable: Observable<Effect>;
  30134. /** @hidden */
  30135. _bonesComputationForcedToCPU: boolean;
  30136. private static _uniqueIdSeed;
  30137. private _engine;
  30138. private _uniformBuffersNames;
  30139. private _uniformsNames;
  30140. private _samplerList;
  30141. private _samplers;
  30142. private _isReady;
  30143. private _compilationError;
  30144. private _attributesNames;
  30145. private _attributes;
  30146. private _uniforms;
  30147. /**
  30148. * Key for the effect.
  30149. * @hidden
  30150. */
  30151. _key: string;
  30152. private _indexParameters;
  30153. private _fallbacks;
  30154. private _vertexSourceCode;
  30155. private _fragmentSourceCode;
  30156. private _vertexSourceCodeOverride;
  30157. private _fragmentSourceCodeOverride;
  30158. private _transformFeedbackVaryings;
  30159. /**
  30160. * Compiled shader to webGL program.
  30161. * @hidden
  30162. */
  30163. _pipelineContext: Nullable<IPipelineContext>;
  30164. private _valueCache;
  30165. private static _baseCache;
  30166. /**
  30167. * Instantiates an effect.
  30168. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30169. * @param baseName Name of the effect.
  30170. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30171. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30172. * @param samplers List of sampler variables that will be passed to the shader.
  30173. * @param engine Engine to be used to render the effect
  30174. * @param defines Define statements to be added to the shader.
  30175. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30176. * @param onCompiled Callback that will be called when the shader is compiled.
  30177. * @param onError Callback that will be called if an error occurs during shader compilation.
  30178. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30179. */
  30180. 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);
  30181. private _useFinalCode;
  30182. /**
  30183. * Unique key for this effect
  30184. */
  30185. readonly key: string;
  30186. /**
  30187. * If the effect has been compiled and prepared.
  30188. * @returns if the effect is compiled and prepared.
  30189. */
  30190. isReady(): boolean;
  30191. /**
  30192. * The engine the effect was initialized with.
  30193. * @returns the engine.
  30194. */
  30195. getEngine(): Engine;
  30196. /**
  30197. * The pipeline context for this effect
  30198. * @returns the associated pipeline context
  30199. */
  30200. getPipelineContext(): Nullable<IPipelineContext>;
  30201. /**
  30202. * The set of names of attribute variables for the shader.
  30203. * @returns An array of attribute names.
  30204. */
  30205. getAttributesNames(): string[];
  30206. /**
  30207. * Returns the attribute at the given index.
  30208. * @param index The index of the attribute.
  30209. * @returns The location of the attribute.
  30210. */
  30211. getAttributeLocation(index: number): number;
  30212. /**
  30213. * Returns the attribute based on the name of the variable.
  30214. * @param name of the attribute to look up.
  30215. * @returns the attribute location.
  30216. */
  30217. getAttributeLocationByName(name: string): number;
  30218. /**
  30219. * The number of attributes.
  30220. * @returns the numnber of attributes.
  30221. */
  30222. getAttributesCount(): number;
  30223. /**
  30224. * Gets the index of a uniform variable.
  30225. * @param uniformName of the uniform to look up.
  30226. * @returns the index.
  30227. */
  30228. getUniformIndex(uniformName: string): number;
  30229. /**
  30230. * Returns the attribute based on the name of the variable.
  30231. * @param uniformName of the uniform to look up.
  30232. * @returns the location of the uniform.
  30233. */
  30234. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30235. /**
  30236. * Returns an array of sampler variable names
  30237. * @returns The array of sampler variable neames.
  30238. */
  30239. getSamplers(): string[];
  30240. /**
  30241. * The error from the last compilation.
  30242. * @returns the error string.
  30243. */
  30244. getCompilationError(): string;
  30245. /**
  30246. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30247. * @param func The callback to be used.
  30248. */
  30249. executeWhenCompiled(func: (effect: Effect) => void): void;
  30250. private _checkIsReady;
  30251. /** @hidden */
  30252. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30253. /** @hidden */
  30254. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30255. /** @hidden */
  30256. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30257. /**
  30258. * Recompiles the webGL program
  30259. * @param vertexSourceCode The source code for the vertex shader.
  30260. * @param fragmentSourceCode The source code for the fragment shader.
  30261. * @param onCompiled Callback called when completed.
  30262. * @param onError Callback called on error.
  30263. * @hidden
  30264. */
  30265. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30266. /**
  30267. * Prepares the effect
  30268. * @hidden
  30269. */
  30270. _prepareEffect(): void;
  30271. /**
  30272. * Checks if the effect is supported. (Must be called after compilation)
  30273. */
  30274. readonly isSupported: boolean;
  30275. /**
  30276. * Binds a texture to the engine to be used as output of the shader.
  30277. * @param channel Name of the output variable.
  30278. * @param texture Texture to bind.
  30279. * @hidden
  30280. */
  30281. _bindTexture(channel: string, texture: InternalTexture): void;
  30282. /**
  30283. * Sets a texture on the engine to be used in the shader.
  30284. * @param channel Name of the sampler variable.
  30285. * @param texture Texture to set.
  30286. */
  30287. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30288. /**
  30289. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30290. * @param channel Name of the sampler variable.
  30291. * @param texture Texture to set.
  30292. */
  30293. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30294. /**
  30295. * Sets an array of textures on the engine to be used in the shader.
  30296. * @param channel Name of the variable.
  30297. * @param textures Textures to set.
  30298. */
  30299. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30300. /**
  30301. * 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)
  30302. * @param channel Name of the sampler variable.
  30303. * @param postProcess Post process to get the input texture from.
  30304. */
  30305. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30306. /**
  30307. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30308. * 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)
  30309. * @param channel Name of the sampler variable.
  30310. * @param postProcess Post process to get the output texture from.
  30311. */
  30312. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30313. /** @hidden */
  30314. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30315. /** @hidden */
  30316. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30317. /** @hidden */
  30318. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30319. /** @hidden */
  30320. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30321. /**
  30322. * Binds a buffer to a uniform.
  30323. * @param buffer Buffer to bind.
  30324. * @param name Name of the uniform variable to bind to.
  30325. */
  30326. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30327. /**
  30328. * Binds block to a uniform.
  30329. * @param blockName Name of the block to bind.
  30330. * @param index Index to bind.
  30331. */
  30332. bindUniformBlock(blockName: string, index: number): void;
  30333. /**
  30334. * Sets an interger value on a uniform variable.
  30335. * @param uniformName Name of the variable.
  30336. * @param value Value to be set.
  30337. * @returns this effect.
  30338. */
  30339. setInt(uniformName: string, value: number): Effect;
  30340. /**
  30341. * Sets an int array on a uniform variable.
  30342. * @param uniformName Name of the variable.
  30343. * @param array array to be set.
  30344. * @returns this effect.
  30345. */
  30346. setIntArray(uniformName: string, array: Int32Array): Effect;
  30347. /**
  30348. * 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)
  30349. * @param uniformName Name of the variable.
  30350. * @param array array to be set.
  30351. * @returns this effect.
  30352. */
  30353. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30354. /**
  30355. * 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)
  30356. * @param uniformName Name of the variable.
  30357. * @param array array to be set.
  30358. * @returns this effect.
  30359. */
  30360. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30361. /**
  30362. * 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)
  30363. * @param uniformName Name of the variable.
  30364. * @param array array to be set.
  30365. * @returns this effect.
  30366. */
  30367. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30368. /**
  30369. * Sets an float array on a uniform variable.
  30370. * @param uniformName Name of the variable.
  30371. * @param array array to be set.
  30372. * @returns this effect.
  30373. */
  30374. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30375. /**
  30376. * 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)
  30377. * @param uniformName Name of the variable.
  30378. * @param array array to be set.
  30379. * @returns this effect.
  30380. */
  30381. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30382. /**
  30383. * 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)
  30384. * @param uniformName Name of the variable.
  30385. * @param array array to be set.
  30386. * @returns this effect.
  30387. */
  30388. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30389. /**
  30390. * 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)
  30391. * @param uniformName Name of the variable.
  30392. * @param array array to be set.
  30393. * @returns this effect.
  30394. */
  30395. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30396. /**
  30397. * Sets an array on a uniform variable.
  30398. * @param uniformName Name of the variable.
  30399. * @param array array to be set.
  30400. * @returns this effect.
  30401. */
  30402. setArray(uniformName: string, array: number[]): Effect;
  30403. /**
  30404. * 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)
  30405. * @param uniformName Name of the variable.
  30406. * @param array array to be set.
  30407. * @returns this effect.
  30408. */
  30409. setArray2(uniformName: string, array: number[]): Effect;
  30410. /**
  30411. * 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)
  30412. * @param uniformName Name of the variable.
  30413. * @param array array to be set.
  30414. * @returns this effect.
  30415. */
  30416. setArray3(uniformName: string, array: number[]): Effect;
  30417. /**
  30418. * 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)
  30419. * @param uniformName Name of the variable.
  30420. * @param array array to be set.
  30421. * @returns this effect.
  30422. */
  30423. setArray4(uniformName: string, array: number[]): Effect;
  30424. /**
  30425. * Sets matrices on a uniform variable.
  30426. * @param uniformName Name of the variable.
  30427. * @param matrices matrices to be set.
  30428. * @returns this effect.
  30429. */
  30430. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30431. /**
  30432. * Sets matrix on a uniform variable.
  30433. * @param uniformName Name of the variable.
  30434. * @param matrix matrix to be set.
  30435. * @returns this effect.
  30436. */
  30437. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30438. /**
  30439. * 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)
  30440. * @param uniformName Name of the variable.
  30441. * @param matrix matrix to be set.
  30442. * @returns this effect.
  30443. */
  30444. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30445. /**
  30446. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30447. * @param uniformName Name of the variable.
  30448. * @param matrix matrix to be set.
  30449. * @returns this effect.
  30450. */
  30451. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30452. /**
  30453. * Sets a float on a uniform variable.
  30454. * @param uniformName Name of the variable.
  30455. * @param value value to be set.
  30456. * @returns this effect.
  30457. */
  30458. setFloat(uniformName: string, value: number): Effect;
  30459. /**
  30460. * Sets a boolean on a uniform variable.
  30461. * @param uniformName Name of the variable.
  30462. * @param bool value to be set.
  30463. * @returns this effect.
  30464. */
  30465. setBool(uniformName: string, bool: boolean): Effect;
  30466. /**
  30467. * Sets a Vector2 on a uniform variable.
  30468. * @param uniformName Name of the variable.
  30469. * @param vector2 vector2 to be set.
  30470. * @returns this effect.
  30471. */
  30472. setVector2(uniformName: string, vector2: Vector2): Effect;
  30473. /**
  30474. * Sets a float2 on a uniform variable.
  30475. * @param uniformName Name of the variable.
  30476. * @param x First float in float2.
  30477. * @param y Second float in float2.
  30478. * @returns this effect.
  30479. */
  30480. setFloat2(uniformName: string, x: number, y: number): Effect;
  30481. /**
  30482. * Sets a Vector3 on a uniform variable.
  30483. * @param uniformName Name of the variable.
  30484. * @param vector3 Value to be set.
  30485. * @returns this effect.
  30486. */
  30487. setVector3(uniformName: string, vector3: Vector3): Effect;
  30488. /**
  30489. * Sets a float3 on a uniform variable.
  30490. * @param uniformName Name of the variable.
  30491. * @param x First float in float3.
  30492. * @param y Second float in float3.
  30493. * @param z Third float in float3.
  30494. * @returns this effect.
  30495. */
  30496. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30497. /**
  30498. * Sets a Vector4 on a uniform variable.
  30499. * @param uniformName Name of the variable.
  30500. * @param vector4 Value to be set.
  30501. * @returns this effect.
  30502. */
  30503. setVector4(uniformName: string, vector4: Vector4): Effect;
  30504. /**
  30505. * Sets a float4 on a uniform variable.
  30506. * @param uniformName Name of the variable.
  30507. * @param x First float in float4.
  30508. * @param y Second float in float4.
  30509. * @param z Third float in float4.
  30510. * @param w Fourth float in float4.
  30511. * @returns this effect.
  30512. */
  30513. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30514. /**
  30515. * Sets a Color3 on a uniform variable.
  30516. * @param uniformName Name of the variable.
  30517. * @param color3 Value to be set.
  30518. * @returns this effect.
  30519. */
  30520. setColor3(uniformName: string, color3: Color3): Effect;
  30521. /**
  30522. * Sets a Color4 on a uniform variable.
  30523. * @param uniformName Name of the variable.
  30524. * @param color3 Value to be set.
  30525. * @param alpha Alpha value to be set.
  30526. * @returns this effect.
  30527. */
  30528. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30529. /**
  30530. * Sets a Color4 on a uniform variable
  30531. * @param uniformName defines the name of the variable
  30532. * @param color4 defines the value to be set
  30533. * @returns this effect.
  30534. */
  30535. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30536. /** Release all associated resources */
  30537. dispose(): void;
  30538. /**
  30539. * This function will add a new shader to the shader store
  30540. * @param name the name of the shader
  30541. * @param pixelShader optional pixel shader content
  30542. * @param vertexShader optional vertex shader content
  30543. */
  30544. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30545. /**
  30546. * Store of each shader (The can be looked up using effect.key)
  30547. */
  30548. static ShadersStore: {
  30549. [key: string]: string;
  30550. };
  30551. /**
  30552. * Store of each included file for a shader (The can be looked up using effect.key)
  30553. */
  30554. static IncludesShadersStore: {
  30555. [key: string]: string;
  30556. };
  30557. /**
  30558. * Resets the cache of effects.
  30559. */
  30560. static ResetCache(): void;
  30561. }
  30562. }
  30563. declare module "babylonjs/Materials/colorCurves" {
  30564. import { Effect } from "babylonjs/Materials/effect";
  30565. /**
  30566. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30567. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30568. * 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;
  30569. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30570. */
  30571. export class ColorCurves {
  30572. private _dirty;
  30573. private _tempColor;
  30574. private _globalCurve;
  30575. private _highlightsCurve;
  30576. private _midtonesCurve;
  30577. private _shadowsCurve;
  30578. private _positiveCurve;
  30579. private _negativeCurve;
  30580. private _globalHue;
  30581. private _globalDensity;
  30582. private _globalSaturation;
  30583. private _globalExposure;
  30584. /**
  30585. * Gets the global Hue value.
  30586. * 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).
  30587. */
  30588. /**
  30589. * Sets the global Hue value.
  30590. * 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).
  30591. */
  30592. globalHue: number;
  30593. /**
  30594. * Gets the global Density value.
  30595. * 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.
  30596. * Values less than zero provide a filter of opposite hue.
  30597. */
  30598. /**
  30599. * Sets the global Density value.
  30600. * 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.
  30601. * Values less than zero provide a filter of opposite hue.
  30602. */
  30603. globalDensity: number;
  30604. /**
  30605. * Gets the global Saturation value.
  30606. * 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.
  30607. */
  30608. /**
  30609. * Sets the global Saturation value.
  30610. * 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.
  30611. */
  30612. globalSaturation: number;
  30613. /**
  30614. * Gets the global Exposure value.
  30615. * 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.
  30616. */
  30617. /**
  30618. * Sets the global Exposure value.
  30619. * 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.
  30620. */
  30621. globalExposure: number;
  30622. private _highlightsHue;
  30623. private _highlightsDensity;
  30624. private _highlightsSaturation;
  30625. private _highlightsExposure;
  30626. /**
  30627. * Gets the highlights Hue value.
  30628. * 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).
  30629. */
  30630. /**
  30631. * Sets the highlights Hue value.
  30632. * 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).
  30633. */
  30634. highlightsHue: number;
  30635. /**
  30636. * Gets the highlights Density value.
  30637. * 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.
  30638. * Values less than zero provide a filter of opposite hue.
  30639. */
  30640. /**
  30641. * Sets the highlights Density value.
  30642. * 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.
  30643. * Values less than zero provide a filter of opposite hue.
  30644. */
  30645. highlightsDensity: number;
  30646. /**
  30647. * Gets the highlights Saturation value.
  30648. * 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.
  30649. */
  30650. /**
  30651. * Sets the highlights Saturation value.
  30652. * 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.
  30653. */
  30654. highlightsSaturation: number;
  30655. /**
  30656. * Gets the highlights Exposure value.
  30657. * 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.
  30658. */
  30659. /**
  30660. * Sets the highlights Exposure value.
  30661. * 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.
  30662. */
  30663. highlightsExposure: number;
  30664. private _midtonesHue;
  30665. private _midtonesDensity;
  30666. private _midtonesSaturation;
  30667. private _midtonesExposure;
  30668. /**
  30669. * Gets the midtones Hue value.
  30670. * 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).
  30671. */
  30672. /**
  30673. * Sets the midtones Hue value.
  30674. * 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).
  30675. */
  30676. midtonesHue: number;
  30677. /**
  30678. * Gets the midtones Density value.
  30679. * 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.
  30680. * Values less than zero provide a filter of opposite hue.
  30681. */
  30682. /**
  30683. * Sets the midtones Density value.
  30684. * 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.
  30685. * Values less than zero provide a filter of opposite hue.
  30686. */
  30687. midtonesDensity: number;
  30688. /**
  30689. * Gets the midtones Saturation value.
  30690. * 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.
  30691. */
  30692. /**
  30693. * Sets the midtones Saturation value.
  30694. * 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.
  30695. */
  30696. midtonesSaturation: number;
  30697. /**
  30698. * Gets the midtones Exposure value.
  30699. * 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.
  30700. */
  30701. /**
  30702. * Sets the midtones Exposure value.
  30703. * 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.
  30704. */
  30705. midtonesExposure: number;
  30706. private _shadowsHue;
  30707. private _shadowsDensity;
  30708. private _shadowsSaturation;
  30709. private _shadowsExposure;
  30710. /**
  30711. * Gets the shadows Hue value.
  30712. * 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).
  30713. */
  30714. /**
  30715. * Sets the shadows Hue value.
  30716. * 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).
  30717. */
  30718. shadowsHue: number;
  30719. /**
  30720. * Gets the shadows Density value.
  30721. * 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.
  30722. * Values less than zero provide a filter of opposite hue.
  30723. */
  30724. /**
  30725. * Sets the shadows Density value.
  30726. * 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.
  30727. * Values less than zero provide a filter of opposite hue.
  30728. */
  30729. shadowsDensity: number;
  30730. /**
  30731. * Gets the shadows Saturation value.
  30732. * 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.
  30733. */
  30734. /**
  30735. * Sets the shadows Saturation value.
  30736. * 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.
  30737. */
  30738. shadowsSaturation: number;
  30739. /**
  30740. * Gets the shadows Exposure value.
  30741. * 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.
  30742. */
  30743. /**
  30744. * Sets the shadows Exposure value.
  30745. * 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.
  30746. */
  30747. shadowsExposure: number;
  30748. /**
  30749. * Returns the class name
  30750. * @returns The class name
  30751. */
  30752. getClassName(): string;
  30753. /**
  30754. * Binds the color curves to the shader.
  30755. * @param colorCurves The color curve to bind
  30756. * @param effect The effect to bind to
  30757. * @param positiveUniform The positive uniform shader parameter
  30758. * @param neutralUniform The neutral uniform shader parameter
  30759. * @param negativeUniform The negative uniform shader parameter
  30760. */
  30761. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30762. /**
  30763. * Prepare the list of uniforms associated with the ColorCurves effects.
  30764. * @param uniformsList The list of uniforms used in the effect
  30765. */
  30766. static PrepareUniforms(uniformsList: string[]): void;
  30767. /**
  30768. * Returns color grading data based on a hue, density, saturation and exposure value.
  30769. * @param filterHue The hue of the color filter.
  30770. * @param filterDensity The density of the color filter.
  30771. * @param saturation The saturation.
  30772. * @param exposure The exposure.
  30773. * @param result The result data container.
  30774. */
  30775. private getColorGradingDataToRef;
  30776. /**
  30777. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30778. * @param value The input slider value in range [-100,100].
  30779. * @returns Adjusted value.
  30780. */
  30781. private static applyColorGradingSliderNonlinear;
  30782. /**
  30783. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30784. * @param hue The hue (H) input.
  30785. * @param saturation The saturation (S) input.
  30786. * @param brightness The brightness (B) input.
  30787. * @result An RGBA color represented as Vector4.
  30788. */
  30789. private static fromHSBToRef;
  30790. /**
  30791. * Returns a value clamped between min and max
  30792. * @param value The value to clamp
  30793. * @param min The minimum of value
  30794. * @param max The maximum of value
  30795. * @returns The clamped value.
  30796. */
  30797. private static clamp;
  30798. /**
  30799. * Clones the current color curve instance.
  30800. * @return The cloned curves
  30801. */
  30802. clone(): ColorCurves;
  30803. /**
  30804. * Serializes the current color curve instance to a json representation.
  30805. * @return a JSON representation
  30806. */
  30807. serialize(): any;
  30808. /**
  30809. * Parses the color curve from a json representation.
  30810. * @param source the JSON source to parse
  30811. * @return The parsed curves
  30812. */
  30813. static Parse(source: any): ColorCurves;
  30814. }
  30815. }
  30816. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30817. import { Observable } from "babylonjs/Misc/observable";
  30818. import { Nullable } from "babylonjs/types";
  30819. import { Color4 } from "babylonjs/Maths/math";
  30820. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30821. import { Effect } from "babylonjs/Materials/effect";
  30822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30823. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30824. /**
  30825. * Interface to follow in your material defines to integrate easily the
  30826. * Image proccessing functions.
  30827. * @hidden
  30828. */
  30829. export interface IImageProcessingConfigurationDefines {
  30830. IMAGEPROCESSING: boolean;
  30831. VIGNETTE: boolean;
  30832. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30833. VIGNETTEBLENDMODEOPAQUE: boolean;
  30834. TONEMAPPING: boolean;
  30835. TONEMAPPING_ACES: boolean;
  30836. CONTRAST: boolean;
  30837. EXPOSURE: boolean;
  30838. COLORCURVES: boolean;
  30839. COLORGRADING: boolean;
  30840. COLORGRADING3D: boolean;
  30841. SAMPLER3DGREENDEPTH: boolean;
  30842. SAMPLER3DBGRMAP: boolean;
  30843. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30844. }
  30845. /**
  30846. * @hidden
  30847. */
  30848. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30849. IMAGEPROCESSING: boolean;
  30850. VIGNETTE: boolean;
  30851. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30852. VIGNETTEBLENDMODEOPAQUE: boolean;
  30853. TONEMAPPING: boolean;
  30854. TONEMAPPING_ACES: boolean;
  30855. CONTRAST: boolean;
  30856. COLORCURVES: boolean;
  30857. COLORGRADING: boolean;
  30858. COLORGRADING3D: boolean;
  30859. SAMPLER3DGREENDEPTH: boolean;
  30860. SAMPLER3DBGRMAP: boolean;
  30861. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30862. EXPOSURE: boolean;
  30863. constructor();
  30864. }
  30865. /**
  30866. * This groups together the common properties used for image processing either in direct forward pass
  30867. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30868. * or not.
  30869. */
  30870. export class ImageProcessingConfiguration {
  30871. /**
  30872. * Default tone mapping applied in BabylonJS.
  30873. */
  30874. static readonly TONEMAPPING_STANDARD: number;
  30875. /**
  30876. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30877. * to other engines rendering to increase portability.
  30878. */
  30879. static readonly TONEMAPPING_ACES: number;
  30880. /**
  30881. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30882. */
  30883. colorCurves: Nullable<ColorCurves>;
  30884. private _colorCurvesEnabled;
  30885. /**
  30886. * Gets wether the color curves effect is enabled.
  30887. */
  30888. /**
  30889. * Sets wether the color curves effect is enabled.
  30890. */
  30891. colorCurvesEnabled: boolean;
  30892. private _colorGradingTexture;
  30893. /**
  30894. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30895. */
  30896. /**
  30897. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30898. */
  30899. colorGradingTexture: Nullable<BaseTexture>;
  30900. private _colorGradingEnabled;
  30901. /**
  30902. * Gets wether the color grading effect is enabled.
  30903. */
  30904. /**
  30905. * Sets wether the color grading effect is enabled.
  30906. */
  30907. colorGradingEnabled: boolean;
  30908. private _colorGradingWithGreenDepth;
  30909. /**
  30910. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30911. */
  30912. /**
  30913. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30914. */
  30915. colorGradingWithGreenDepth: boolean;
  30916. private _colorGradingBGR;
  30917. /**
  30918. * Gets wether the color grading texture contains BGR values.
  30919. */
  30920. /**
  30921. * Sets wether the color grading texture contains BGR values.
  30922. */
  30923. colorGradingBGR: boolean;
  30924. /** @hidden */
  30925. _exposure: number;
  30926. /**
  30927. * Gets the Exposure used in the effect.
  30928. */
  30929. /**
  30930. * Sets the Exposure used in the effect.
  30931. */
  30932. exposure: number;
  30933. private _toneMappingEnabled;
  30934. /**
  30935. * Gets wether the tone mapping effect is enabled.
  30936. */
  30937. /**
  30938. * Sets wether the tone mapping effect is enabled.
  30939. */
  30940. toneMappingEnabled: boolean;
  30941. private _toneMappingType;
  30942. /**
  30943. * Gets the type of tone mapping effect.
  30944. */
  30945. /**
  30946. * Sets the type of tone mapping effect used in BabylonJS.
  30947. */
  30948. toneMappingType: number;
  30949. protected _contrast: number;
  30950. /**
  30951. * Gets the contrast used in the effect.
  30952. */
  30953. /**
  30954. * Sets the contrast used in the effect.
  30955. */
  30956. contrast: number;
  30957. /**
  30958. * Vignette stretch size.
  30959. */
  30960. vignetteStretch: number;
  30961. /**
  30962. * Vignette centre X Offset.
  30963. */
  30964. vignetteCentreX: number;
  30965. /**
  30966. * Vignette centre Y Offset.
  30967. */
  30968. vignetteCentreY: number;
  30969. /**
  30970. * Vignette weight or intensity of the vignette effect.
  30971. */
  30972. vignetteWeight: number;
  30973. /**
  30974. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30975. * if vignetteEnabled is set to true.
  30976. */
  30977. vignetteColor: Color4;
  30978. /**
  30979. * Camera field of view used by the Vignette effect.
  30980. */
  30981. vignetteCameraFov: number;
  30982. private _vignetteBlendMode;
  30983. /**
  30984. * Gets the vignette blend mode allowing different kind of effect.
  30985. */
  30986. /**
  30987. * Sets the vignette blend mode allowing different kind of effect.
  30988. */
  30989. vignetteBlendMode: number;
  30990. private _vignetteEnabled;
  30991. /**
  30992. * Gets wether the vignette effect is enabled.
  30993. */
  30994. /**
  30995. * Sets wether the vignette effect is enabled.
  30996. */
  30997. vignetteEnabled: boolean;
  30998. private _applyByPostProcess;
  30999. /**
  31000. * Gets wether the image processing is applied through a post process or not.
  31001. */
  31002. /**
  31003. * Sets wether the image processing is applied through a post process or not.
  31004. */
  31005. applyByPostProcess: boolean;
  31006. private _isEnabled;
  31007. /**
  31008. * Gets wether the image processing is enabled or not.
  31009. */
  31010. /**
  31011. * Sets wether the image processing is enabled or not.
  31012. */
  31013. isEnabled: boolean;
  31014. /**
  31015. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31016. */
  31017. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31018. /**
  31019. * Method called each time the image processing information changes requires to recompile the effect.
  31020. */
  31021. protected _updateParameters(): void;
  31022. /**
  31023. * Gets the current class name.
  31024. * @return "ImageProcessingConfiguration"
  31025. */
  31026. getClassName(): string;
  31027. /**
  31028. * Prepare the list of uniforms associated with the Image Processing effects.
  31029. * @param uniforms The list of uniforms used in the effect
  31030. * @param defines the list of defines currently in use
  31031. */
  31032. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31033. /**
  31034. * Prepare the list of samplers associated with the Image Processing effects.
  31035. * @param samplersList The list of uniforms used in the effect
  31036. * @param defines the list of defines currently in use
  31037. */
  31038. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31039. /**
  31040. * Prepare the list of defines associated to the shader.
  31041. * @param defines the list of defines to complete
  31042. * @param forPostProcess Define if we are currently in post process mode or not
  31043. */
  31044. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31045. /**
  31046. * Returns true if all the image processing information are ready.
  31047. * @returns True if ready, otherwise, false
  31048. */
  31049. isReady(): boolean;
  31050. /**
  31051. * Binds the image processing to the shader.
  31052. * @param effect The effect to bind to
  31053. * @param aspectRatio Define the current aspect ratio of the effect
  31054. */
  31055. bind(effect: Effect, aspectRatio?: number): void;
  31056. /**
  31057. * Clones the current image processing instance.
  31058. * @return The cloned image processing
  31059. */
  31060. clone(): ImageProcessingConfiguration;
  31061. /**
  31062. * Serializes the current image processing instance to a json representation.
  31063. * @return a JSON representation
  31064. */
  31065. serialize(): any;
  31066. /**
  31067. * Parses the image processing from a json representation.
  31068. * @param source the JSON source to parse
  31069. * @return The parsed image processing
  31070. */
  31071. static Parse(source: any): ImageProcessingConfiguration;
  31072. private static _VIGNETTEMODE_MULTIPLY;
  31073. private static _VIGNETTEMODE_OPAQUE;
  31074. /**
  31075. * Used to apply the vignette as a mix with the pixel color.
  31076. */
  31077. static readonly VIGNETTEMODE_MULTIPLY: number;
  31078. /**
  31079. * Used to apply the vignette as a replacement of the pixel color.
  31080. */
  31081. static readonly VIGNETTEMODE_OPAQUE: number;
  31082. }
  31083. }
  31084. declare module "babylonjs/Materials/fresnelParameters" {
  31085. import { Color3 } from "babylonjs/Maths/math";
  31086. /**
  31087. * This represents all the required information to add a fresnel effect on a material:
  31088. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31089. */
  31090. export class FresnelParameters {
  31091. private _isEnabled;
  31092. /**
  31093. * Define if the fresnel effect is enable or not.
  31094. */
  31095. isEnabled: boolean;
  31096. /**
  31097. * Define the color used on edges (grazing angle)
  31098. */
  31099. leftColor: Color3;
  31100. /**
  31101. * Define the color used on center
  31102. */
  31103. rightColor: Color3;
  31104. /**
  31105. * Define bias applied to computed fresnel term
  31106. */
  31107. bias: number;
  31108. /**
  31109. * Defined the power exponent applied to fresnel term
  31110. */
  31111. power: number;
  31112. /**
  31113. * Clones the current fresnel and its valuues
  31114. * @returns a clone fresnel configuration
  31115. */
  31116. clone(): FresnelParameters;
  31117. /**
  31118. * Serializes the current fresnel parameters to a JSON representation.
  31119. * @return the JSON serialization
  31120. */
  31121. serialize(): any;
  31122. /**
  31123. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31124. * @param parsedFresnelParameters Define the JSON representation
  31125. * @returns the parsed parameters
  31126. */
  31127. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31128. }
  31129. }
  31130. declare module "babylonjs/Misc/decorators" {
  31131. import { Nullable } from "babylonjs/types";
  31132. import { Scene } from "babylonjs/scene";
  31133. import { IAnimatable } from "babylonjs/Misc/tools";
  31134. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31135. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31136. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31137. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31138. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31139. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31140. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31141. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31142. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31143. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31144. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31145. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31146. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31147. /**
  31148. * Decorator used to define property that can be serialized as reference to a camera
  31149. * @param sourceName defines the name of the property to decorate
  31150. */
  31151. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31152. /**
  31153. * Class used to help serialization objects
  31154. */
  31155. export class SerializationHelper {
  31156. /** @hidden */
  31157. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31158. /** @hidden */
  31159. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31160. /** @hidden */
  31161. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31162. /** @hidden */
  31163. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31164. /**
  31165. * Appends the serialized animations from the source animations
  31166. * @param source Source containing the animations
  31167. * @param destination Target to store the animations
  31168. */
  31169. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31170. /**
  31171. * Static function used to serialized a specific entity
  31172. * @param entity defines the entity to serialize
  31173. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31174. * @returns a JSON compatible object representing the serialization of the entity
  31175. */
  31176. static Serialize<T>(entity: T, serializationObject?: any): any;
  31177. /**
  31178. * Creates a new entity from a serialization data object
  31179. * @param creationFunction defines a function used to instanciated the new entity
  31180. * @param source defines the source serialization data
  31181. * @param scene defines the hosting scene
  31182. * @param rootUrl defines the root url for resources
  31183. * @returns a new entity
  31184. */
  31185. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31186. /**
  31187. * Clones an object
  31188. * @param creationFunction defines the function used to instanciate the new object
  31189. * @param source defines the source object
  31190. * @returns the cloned object
  31191. */
  31192. static Clone<T>(creationFunction: () => T, source: T): T;
  31193. /**
  31194. * Instanciates a new object based on a source one (some data will be shared between both object)
  31195. * @param creationFunction defines the function used to instanciate the new object
  31196. * @param source defines the source object
  31197. * @returns the new object
  31198. */
  31199. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31200. }
  31201. }
  31202. declare module "babylonjs/Cameras/camera" {
  31203. import { SmartArray } from "babylonjs/Misc/smartArray";
  31204. import { Observable } from "babylonjs/Misc/observable";
  31205. import { Nullable } from "babylonjs/types";
  31206. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31207. import { Scene } from "babylonjs/scene";
  31208. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31209. import { Node } from "babylonjs/node";
  31210. import { Mesh } from "babylonjs/Meshes/mesh";
  31211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31212. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31213. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31214. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31215. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31216. import { Ray } from "babylonjs/Culling/ray";
  31217. /**
  31218. * This is the base class of all the camera used in the application.
  31219. * @see http://doc.babylonjs.com/features/cameras
  31220. */
  31221. export class Camera extends Node {
  31222. /** @hidden */
  31223. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31224. /**
  31225. * This is the default projection mode used by the cameras.
  31226. * It helps recreating a feeling of perspective and better appreciate depth.
  31227. * This is the best way to simulate real life cameras.
  31228. */
  31229. static readonly PERSPECTIVE_CAMERA: number;
  31230. /**
  31231. * This helps creating camera with an orthographic mode.
  31232. * 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.
  31233. */
  31234. static readonly ORTHOGRAPHIC_CAMERA: number;
  31235. /**
  31236. * This is the default FOV mode for perspective cameras.
  31237. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31238. */
  31239. static readonly FOVMODE_VERTICAL_FIXED: number;
  31240. /**
  31241. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31242. */
  31243. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31244. /**
  31245. * This specifies ther is no need for a camera rig.
  31246. * Basically only one eye is rendered corresponding to the camera.
  31247. */
  31248. static readonly RIG_MODE_NONE: number;
  31249. /**
  31250. * Simulates a camera Rig with one blue eye and one red eye.
  31251. * This can be use with 3d blue and red glasses.
  31252. */
  31253. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31254. /**
  31255. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31256. */
  31257. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31258. /**
  31259. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31260. */
  31261. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31262. /**
  31263. * Defines that both eyes of the camera will be rendered over under each other.
  31264. */
  31265. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31266. /**
  31267. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31268. */
  31269. static readonly RIG_MODE_VR: number;
  31270. /**
  31271. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31272. */
  31273. static readonly RIG_MODE_WEBVR: number;
  31274. /**
  31275. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31276. */
  31277. static readonly RIG_MODE_CUSTOM: number;
  31278. /**
  31279. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31280. */
  31281. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31282. /**
  31283. * Define the input manager associated with the camera.
  31284. */
  31285. inputs: CameraInputsManager<Camera>;
  31286. /** @hidden */
  31287. _position: Vector3;
  31288. /**
  31289. * Define the current local position of the camera in the scene
  31290. */
  31291. position: Vector3;
  31292. /**
  31293. * The vector the camera should consider as up.
  31294. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31295. */
  31296. upVector: Vector3;
  31297. /**
  31298. * Define the current limit on the left side for an orthographic camera
  31299. * In scene unit
  31300. */
  31301. orthoLeft: Nullable<number>;
  31302. /**
  31303. * Define the current limit on the right side for an orthographic camera
  31304. * In scene unit
  31305. */
  31306. orthoRight: Nullable<number>;
  31307. /**
  31308. * Define the current limit on the bottom side for an orthographic camera
  31309. * In scene unit
  31310. */
  31311. orthoBottom: Nullable<number>;
  31312. /**
  31313. * Define the current limit on the top side for an orthographic camera
  31314. * In scene unit
  31315. */
  31316. orthoTop: Nullable<number>;
  31317. /**
  31318. * Field Of View is set in Radians. (default is 0.8)
  31319. */
  31320. fov: number;
  31321. /**
  31322. * Define the minimum distance the camera can see from.
  31323. * This is important to note that the depth buffer are not infinite and the closer it starts
  31324. * the more your scene might encounter depth fighting issue.
  31325. */
  31326. minZ: number;
  31327. /**
  31328. * Define the maximum distance the camera can see to.
  31329. * This is important to note that the depth buffer are not infinite and the further it end
  31330. * the more your scene might encounter depth fighting issue.
  31331. */
  31332. maxZ: number;
  31333. /**
  31334. * Define the default inertia of the camera.
  31335. * This helps giving a smooth feeling to the camera movement.
  31336. */
  31337. inertia: number;
  31338. /**
  31339. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31340. */
  31341. mode: number;
  31342. /**
  31343. * Define wether the camera is intermediate.
  31344. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31345. */
  31346. isIntermediate: boolean;
  31347. /**
  31348. * Define the viewport of the camera.
  31349. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31350. */
  31351. viewport: Viewport;
  31352. /**
  31353. * Restricts the camera to viewing objects with the same layerMask.
  31354. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31355. */
  31356. layerMask: number;
  31357. /**
  31358. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31359. */
  31360. fovMode: number;
  31361. /**
  31362. * Rig mode of the camera.
  31363. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31364. * This is normally controlled byt the camera themselves as internal use.
  31365. */
  31366. cameraRigMode: number;
  31367. /**
  31368. * Defines the distance between both "eyes" in case of a RIG
  31369. */
  31370. interaxialDistance: number;
  31371. /**
  31372. * Defines if stereoscopic rendering is done side by side or over under.
  31373. */
  31374. isStereoscopicSideBySide: boolean;
  31375. /**
  31376. * 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
  31377. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31378. * else in the scene.
  31379. */
  31380. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31381. /**
  31382. * When set, the camera will render to this render target instead of the default canvas
  31383. */
  31384. outputRenderTarget: Nullable<RenderTargetTexture>;
  31385. /**
  31386. * Observable triggered when the camera view matrix has changed.
  31387. */
  31388. onViewMatrixChangedObservable: Observable<Camera>;
  31389. /**
  31390. * Observable triggered when the camera Projection matrix has changed.
  31391. */
  31392. onProjectionMatrixChangedObservable: Observable<Camera>;
  31393. /**
  31394. * Observable triggered when the inputs have been processed.
  31395. */
  31396. onAfterCheckInputsObservable: Observable<Camera>;
  31397. /**
  31398. * Observable triggered when reset has been called and applied to the camera.
  31399. */
  31400. onRestoreStateObservable: Observable<Camera>;
  31401. /** @hidden */
  31402. _cameraRigParams: any;
  31403. /** @hidden */
  31404. _rigCameras: Camera[];
  31405. /** @hidden */
  31406. _rigPostProcess: Nullable<PostProcess>;
  31407. protected _webvrViewMatrix: Matrix;
  31408. /** @hidden */
  31409. _skipRendering: boolean;
  31410. /** @hidden */
  31411. _projectionMatrix: Matrix;
  31412. /** @hidden */
  31413. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31414. /** @hidden */
  31415. _activeMeshes: SmartArray<AbstractMesh>;
  31416. protected _globalPosition: Vector3;
  31417. /** @hidden */
  31418. _computedViewMatrix: Matrix;
  31419. private _doNotComputeProjectionMatrix;
  31420. private _transformMatrix;
  31421. private _frustumPlanes;
  31422. private _refreshFrustumPlanes;
  31423. private _storedFov;
  31424. private _stateStored;
  31425. /**
  31426. * Instantiates a new camera object.
  31427. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31428. * @see http://doc.babylonjs.com/features/cameras
  31429. * @param name Defines the name of the camera in the scene
  31430. * @param position Defines the position of the camera
  31431. * @param scene Defines the scene the camera belongs too
  31432. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31433. */
  31434. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31435. /**
  31436. * Store current camera state (fov, position, etc..)
  31437. * @returns the camera
  31438. */
  31439. storeState(): Camera;
  31440. /**
  31441. * Restores the camera state values if it has been stored. You must call storeState() first
  31442. */
  31443. protected _restoreStateValues(): boolean;
  31444. /**
  31445. * Restored camera state. You must call storeState() first.
  31446. * @returns true if restored and false otherwise
  31447. */
  31448. restoreState(): boolean;
  31449. /**
  31450. * Gets the class name of the camera.
  31451. * @returns the class name
  31452. */
  31453. getClassName(): string;
  31454. /** @hidden */
  31455. readonly _isCamera: boolean;
  31456. /**
  31457. * Gets a string representation of the camera useful for debug purpose.
  31458. * @param fullDetails Defines that a more verboe level of logging is required
  31459. * @returns the string representation
  31460. */
  31461. toString(fullDetails?: boolean): string;
  31462. /**
  31463. * Gets the current world space position of the camera.
  31464. */
  31465. readonly globalPosition: Vector3;
  31466. /**
  31467. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31468. * @returns the active meshe list
  31469. */
  31470. getActiveMeshes(): SmartArray<AbstractMesh>;
  31471. /**
  31472. * Check wether a mesh is part of the current active mesh list of the camera
  31473. * @param mesh Defines the mesh to check
  31474. * @returns true if active, false otherwise
  31475. */
  31476. isActiveMesh(mesh: Mesh): boolean;
  31477. /**
  31478. * Is this camera ready to be used/rendered
  31479. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31480. * @return true if the camera is ready
  31481. */
  31482. isReady(completeCheck?: boolean): boolean;
  31483. /** @hidden */
  31484. _initCache(): void;
  31485. /** @hidden */
  31486. _updateCache(ignoreParentClass?: boolean): void;
  31487. /** @hidden */
  31488. _isSynchronized(): boolean;
  31489. /** @hidden */
  31490. _isSynchronizedViewMatrix(): boolean;
  31491. /** @hidden */
  31492. _isSynchronizedProjectionMatrix(): boolean;
  31493. /**
  31494. * Attach the input controls to a specific dom element to get the input from.
  31495. * @param element Defines the element the controls should be listened from
  31496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31497. */
  31498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31499. /**
  31500. * Detach the current controls from the specified dom element.
  31501. * @param element Defines the element to stop listening the inputs from
  31502. */
  31503. detachControl(element: HTMLElement): void;
  31504. /**
  31505. * Update the camera state according to the different inputs gathered during the frame.
  31506. */
  31507. update(): void;
  31508. /** @hidden */
  31509. _checkInputs(): void;
  31510. /** @hidden */
  31511. readonly rigCameras: Camera[];
  31512. /**
  31513. * Gets the post process used by the rig cameras
  31514. */
  31515. readonly rigPostProcess: Nullable<PostProcess>;
  31516. /**
  31517. * Internal, gets the first post proces.
  31518. * @returns the first post process to be run on this camera.
  31519. */
  31520. _getFirstPostProcess(): Nullable<PostProcess>;
  31521. private _cascadePostProcessesToRigCams;
  31522. /**
  31523. * Attach a post process to the camera.
  31524. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31525. * @param postProcess The post process to attach to the camera
  31526. * @param insertAt The position of the post process in case several of them are in use in the scene
  31527. * @returns the position the post process has been inserted at
  31528. */
  31529. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31530. /**
  31531. * Detach a post process to the camera.
  31532. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31533. * @param postProcess The post process to detach from the camera
  31534. */
  31535. detachPostProcess(postProcess: PostProcess): void;
  31536. /**
  31537. * Gets the current world matrix of the camera
  31538. */
  31539. getWorldMatrix(): Matrix;
  31540. /** @hidden */
  31541. _getViewMatrix(): Matrix;
  31542. /**
  31543. * Gets the current view matrix of the camera.
  31544. * @param force forces the camera to recompute the matrix without looking at the cached state
  31545. * @returns the view matrix
  31546. */
  31547. getViewMatrix(force?: boolean): Matrix;
  31548. /**
  31549. * Freeze the projection matrix.
  31550. * It will prevent the cache check of the camera projection compute and can speed up perf
  31551. * if no parameter of the camera are meant to change
  31552. * @param projection Defines manually a projection if necessary
  31553. */
  31554. freezeProjectionMatrix(projection?: Matrix): void;
  31555. /**
  31556. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31557. */
  31558. unfreezeProjectionMatrix(): void;
  31559. /**
  31560. * Gets the current projection matrix of the camera.
  31561. * @param force forces the camera to recompute the matrix without looking at the cached state
  31562. * @returns the projection matrix
  31563. */
  31564. getProjectionMatrix(force?: boolean): Matrix;
  31565. /**
  31566. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31567. * @returns a Matrix
  31568. */
  31569. getTransformationMatrix(): Matrix;
  31570. private _updateFrustumPlanes;
  31571. /**
  31572. * Checks if a cullable object (mesh...) is in the camera frustum
  31573. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31574. * @param target The object to check
  31575. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31576. * @returns true if the object is in frustum otherwise false
  31577. */
  31578. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31579. /**
  31580. * Checks if a cullable object (mesh...) is in the camera frustum
  31581. * Unlike isInFrustum this cheks the full bounding box
  31582. * @param target The object to check
  31583. * @returns true if the object is in frustum otherwise false
  31584. */
  31585. isCompletelyInFrustum(target: ICullable): boolean;
  31586. /**
  31587. * Gets a ray in the forward direction from the camera.
  31588. * @param length Defines the length of the ray to create
  31589. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31590. * @param origin Defines the start point of the ray which defaults to the camera position
  31591. * @returns the forward ray
  31592. */
  31593. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31594. /**
  31595. * Releases resources associated with this node.
  31596. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31597. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31598. */
  31599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31600. /** @hidden */
  31601. _isLeftCamera: boolean;
  31602. /**
  31603. * Gets the left camera of a rig setup in case of Rigged Camera
  31604. */
  31605. readonly isLeftCamera: boolean;
  31606. /** @hidden */
  31607. _isRightCamera: boolean;
  31608. /**
  31609. * Gets the right camera of a rig setup in case of Rigged Camera
  31610. */
  31611. readonly isRightCamera: boolean;
  31612. /**
  31613. * Gets the left camera of a rig setup in case of Rigged Camera
  31614. */
  31615. readonly leftCamera: Nullable<FreeCamera>;
  31616. /**
  31617. * Gets the right camera of a rig setup in case of Rigged Camera
  31618. */
  31619. readonly rightCamera: Nullable<FreeCamera>;
  31620. /**
  31621. * Gets the left camera target of a rig setup in case of Rigged Camera
  31622. * @returns the target position
  31623. */
  31624. getLeftTarget(): Nullable<Vector3>;
  31625. /**
  31626. * Gets the right camera target of a rig setup in case of Rigged Camera
  31627. * @returns the target position
  31628. */
  31629. getRightTarget(): Nullable<Vector3>;
  31630. /**
  31631. * @hidden
  31632. */
  31633. setCameraRigMode(mode: number, rigParams: any): void;
  31634. /** @hidden */
  31635. static _setStereoscopicRigMode(camera: Camera): void;
  31636. /** @hidden */
  31637. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31638. /** @hidden */
  31639. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31640. /** @hidden */
  31641. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31642. /** @hidden */
  31643. _getVRProjectionMatrix(): Matrix;
  31644. protected _updateCameraRotationMatrix(): void;
  31645. protected _updateWebVRCameraRotationMatrix(): void;
  31646. /**
  31647. * This function MUST be overwritten by the different WebVR cameras available.
  31648. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31649. * @hidden
  31650. */
  31651. _getWebVRProjectionMatrix(): Matrix;
  31652. /**
  31653. * This function MUST be overwritten by the different WebVR cameras available.
  31654. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31655. * @hidden
  31656. */
  31657. _getWebVRViewMatrix(): Matrix;
  31658. /** @hidden */
  31659. setCameraRigParameter(name: string, value: any): void;
  31660. /**
  31661. * needs to be overridden by children so sub has required properties to be copied
  31662. * @hidden
  31663. */
  31664. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31665. /**
  31666. * May need to be overridden by children
  31667. * @hidden
  31668. */
  31669. _updateRigCameras(): void;
  31670. /** @hidden */
  31671. _setupInputs(): void;
  31672. /**
  31673. * Serialiaze the camera setup to a json represention
  31674. * @returns the JSON representation
  31675. */
  31676. serialize(): any;
  31677. /**
  31678. * Clones the current camera.
  31679. * @param name The cloned camera name
  31680. * @returns the cloned camera
  31681. */
  31682. clone(name: string): Camera;
  31683. /**
  31684. * Gets the direction of the camera relative to a given local axis.
  31685. * @param localAxis Defines the reference axis to provide a relative direction.
  31686. * @return the direction
  31687. */
  31688. getDirection(localAxis: Vector3): Vector3;
  31689. /**
  31690. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31691. * @param localAxis Defines the reference axis to provide a relative direction.
  31692. * @param result Defines the vector to store the result in
  31693. */
  31694. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31695. /**
  31696. * Gets a camera constructor for a given camera type
  31697. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31698. * @param name The name of the camera the result will be able to instantiate
  31699. * @param scene The scene the result will construct the camera in
  31700. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31701. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31702. * @returns a factory method to construc the camera
  31703. */
  31704. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31705. /**
  31706. * Compute the world matrix of the camera.
  31707. * @returns the camera workd matrix
  31708. */
  31709. computeWorldMatrix(): Matrix;
  31710. /**
  31711. * Parse a JSON and creates the camera from the parsed information
  31712. * @param parsedCamera The JSON to parse
  31713. * @param scene The scene to instantiate the camera in
  31714. * @returns the newly constructed camera
  31715. */
  31716. static Parse(parsedCamera: any, scene: Scene): Camera;
  31717. }
  31718. }
  31719. declare module "babylonjs/Misc/tools" {
  31720. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31721. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31723. import { Observable } from "babylonjs/Misc/observable";
  31724. import { DomManagement } from "babylonjs/Misc/domManagement";
  31725. import { WebRequest } from "babylonjs/Misc/webRequest";
  31726. import { Camera } from "babylonjs/Cameras/camera";
  31727. import { Engine } from "babylonjs/Engines/engine";
  31728. import { Animation } from "babylonjs/Animations/animation";
  31729. /**
  31730. * Interface for any object that can request an animation frame
  31731. */
  31732. export interface ICustomAnimationFrameRequester {
  31733. /**
  31734. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31735. */
  31736. renderFunction?: Function;
  31737. /**
  31738. * Called to request the next frame to render to
  31739. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31740. */
  31741. requestAnimationFrame: Function;
  31742. /**
  31743. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31744. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31745. */
  31746. requestID?: number;
  31747. }
  31748. /**
  31749. * Interface containing an array of animations
  31750. */
  31751. export interface IAnimatable {
  31752. /**
  31753. * Array of animations
  31754. */
  31755. animations: Nullable<Array<Animation>>;
  31756. }
  31757. /** Interface used by value gradients (color, factor, ...) */
  31758. export interface IValueGradient {
  31759. /**
  31760. * Gets or sets the gradient value (between 0 and 1)
  31761. */
  31762. gradient: number;
  31763. }
  31764. /** Class used to store color4 gradient */
  31765. export class ColorGradient implements IValueGradient {
  31766. /**
  31767. * Gets or sets the gradient value (between 0 and 1)
  31768. */
  31769. gradient: number;
  31770. /**
  31771. * Gets or sets first associated color
  31772. */
  31773. color1: Color4;
  31774. /**
  31775. * Gets or sets second associated color
  31776. */
  31777. color2?: Color4;
  31778. /**
  31779. * Will get a color picked randomly between color1 and color2.
  31780. * If color2 is undefined then color1 will be used
  31781. * @param result defines the target Color4 to store the result in
  31782. */
  31783. getColorToRef(result: Color4): void;
  31784. }
  31785. /** Class used to store color 3 gradient */
  31786. export class Color3Gradient implements IValueGradient {
  31787. /**
  31788. * Gets or sets the gradient value (between 0 and 1)
  31789. */
  31790. gradient: number;
  31791. /**
  31792. * Gets or sets the associated color
  31793. */
  31794. color: Color3;
  31795. }
  31796. /** Class used to store factor gradient */
  31797. export class FactorGradient implements IValueGradient {
  31798. /**
  31799. * Gets or sets the gradient value (between 0 and 1)
  31800. */
  31801. gradient: number;
  31802. /**
  31803. * Gets or sets first associated factor
  31804. */
  31805. factor1: number;
  31806. /**
  31807. * Gets or sets second associated factor
  31808. */
  31809. factor2?: number;
  31810. /**
  31811. * Will get a number picked randomly between factor1 and factor2.
  31812. * If factor2 is undefined then factor1 will be used
  31813. * @returns the picked number
  31814. */
  31815. getFactor(): number;
  31816. }
  31817. /**
  31818. * @ignore
  31819. * Application error to support additional information when loading a file
  31820. */
  31821. export class LoadFileError extends Error {
  31822. /** defines the optional web request */
  31823. request?: WebRequest | undefined;
  31824. private static _setPrototypeOf;
  31825. /**
  31826. * Creates a new LoadFileError
  31827. * @param message defines the message of the error
  31828. * @param request defines the optional web request
  31829. */
  31830. constructor(message: string,
  31831. /** defines the optional web request */
  31832. request?: WebRequest | undefined);
  31833. }
  31834. /**
  31835. * Class used to define a retry strategy when error happens while loading assets
  31836. */
  31837. export class RetryStrategy {
  31838. /**
  31839. * Function used to defines an exponential back off strategy
  31840. * @param maxRetries defines the maximum number of retries (3 by default)
  31841. * @param baseInterval defines the interval between retries
  31842. * @returns the strategy function to use
  31843. */
  31844. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31845. }
  31846. /**
  31847. * File request interface
  31848. */
  31849. export interface IFileRequest {
  31850. /**
  31851. * Raised when the request is complete (success or error).
  31852. */
  31853. onCompleteObservable: Observable<IFileRequest>;
  31854. /**
  31855. * Aborts the request for a file.
  31856. */
  31857. abort: () => void;
  31858. }
  31859. /**
  31860. * Class containing a set of static utilities functions
  31861. */
  31862. export class Tools {
  31863. /**
  31864. * Gets or sets the base URL to use to load assets
  31865. */
  31866. static BaseUrl: string;
  31867. /**
  31868. * Enable/Disable Custom HTTP Request Headers globally.
  31869. * default = false
  31870. * @see CustomRequestHeaders
  31871. */
  31872. static UseCustomRequestHeaders: boolean;
  31873. /**
  31874. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31875. * i.e. when loading files, where the server/service expects an Authorization header
  31876. */
  31877. static CustomRequestHeaders: {
  31878. [key: string]: string;
  31879. };
  31880. /**
  31881. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31882. */
  31883. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31884. /**
  31885. * Default behaviour for cors in the application.
  31886. * It can be a string if the expected behavior is identical in the entire app.
  31887. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31888. */
  31889. static CorsBehavior: string | ((url: string | string[]) => string);
  31890. /**
  31891. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31892. * @ignorenaming
  31893. */
  31894. static UseFallbackTexture: boolean;
  31895. /**
  31896. * Use this object to register external classes like custom textures or material
  31897. * to allow the laoders to instantiate them
  31898. */
  31899. static RegisteredExternalClasses: {
  31900. [key: string]: Object;
  31901. };
  31902. /**
  31903. * Texture content used if a texture cannot loaded
  31904. * @ignorenaming
  31905. */
  31906. static fallbackTexture: string;
  31907. /**
  31908. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31909. * @param u defines the coordinate on X axis
  31910. * @param v defines the coordinate on Y axis
  31911. * @param width defines the width of the source data
  31912. * @param height defines the height of the source data
  31913. * @param pixels defines the source byte array
  31914. * @param color defines the output color
  31915. */
  31916. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31917. /**
  31918. * Interpolates between a and b via alpha
  31919. * @param a The lower value (returned when alpha = 0)
  31920. * @param b The upper value (returned when alpha = 1)
  31921. * @param alpha The interpolation-factor
  31922. * @return The mixed value
  31923. */
  31924. static Mix(a: number, b: number, alpha: number): number;
  31925. /**
  31926. * Tries to instantiate a new object from a given class name
  31927. * @param className defines the class name to instantiate
  31928. * @returns the new object or null if the system was not able to do the instantiation
  31929. */
  31930. static Instantiate(className: string): any;
  31931. /**
  31932. * Provides a slice function that will work even on IE
  31933. * @param data defines the array to slice
  31934. * @param start defines the start of the data (optional)
  31935. * @param end defines the end of the data (optional)
  31936. * @returns the new sliced array
  31937. */
  31938. static Slice<T>(data: T, start?: number, end?: number): T;
  31939. /**
  31940. * Polyfill for setImmediate
  31941. * @param action defines the action to execute after the current execution block
  31942. */
  31943. static SetImmediate(action: () => void): void;
  31944. /**
  31945. * Function indicating if a number is an exponent of 2
  31946. * @param value defines the value to test
  31947. * @returns true if the value is an exponent of 2
  31948. */
  31949. static IsExponentOfTwo(value: number): boolean;
  31950. private static _tmpFloatArray;
  31951. /**
  31952. * Returns the nearest 32-bit single precision float representation of a Number
  31953. * @param value A Number. If the parameter is of a different type, it will get converted
  31954. * to a number or to NaN if it cannot be converted
  31955. * @returns number
  31956. */
  31957. static FloatRound(value: number): number;
  31958. /**
  31959. * Find the next highest power of two.
  31960. * @param x Number to start search from.
  31961. * @return Next highest power of two.
  31962. */
  31963. static CeilingPOT(x: number): number;
  31964. /**
  31965. * Find the next lowest power of two.
  31966. * @param x Number to start search from.
  31967. * @return Next lowest power of two.
  31968. */
  31969. static FloorPOT(x: number): number;
  31970. /**
  31971. * Find the nearest power of two.
  31972. * @param x Number to start search from.
  31973. * @return Next nearest power of two.
  31974. */
  31975. static NearestPOT(x: number): number;
  31976. /**
  31977. * Get the closest exponent of two
  31978. * @param value defines the value to approximate
  31979. * @param max defines the maximum value to return
  31980. * @param mode defines how to define the closest value
  31981. * @returns closest exponent of two of the given value
  31982. */
  31983. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31984. /**
  31985. * Extracts the filename from a path
  31986. * @param path defines the path to use
  31987. * @returns the filename
  31988. */
  31989. static GetFilename(path: string): string;
  31990. /**
  31991. * Extracts the "folder" part of a path (everything before the filename).
  31992. * @param uri The URI to extract the info from
  31993. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31994. * @returns The "folder" part of the path
  31995. */
  31996. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31997. /**
  31998. * Extracts text content from a DOM element hierarchy
  31999. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32000. */
  32001. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32002. /**
  32003. * Convert an angle in radians to degrees
  32004. * @param angle defines the angle to convert
  32005. * @returns the angle in degrees
  32006. */
  32007. static ToDegrees(angle: number): number;
  32008. /**
  32009. * Convert an angle in degrees to radians
  32010. * @param angle defines the angle to convert
  32011. * @returns the angle in radians
  32012. */
  32013. static ToRadians(angle: number): number;
  32014. /**
  32015. * Encode a buffer to a base64 string
  32016. * @param buffer defines the buffer to encode
  32017. * @returns the encoded string
  32018. */
  32019. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32020. /**
  32021. * Extracts minimum and maximum values from a list of indexed positions
  32022. * @param positions defines the positions to use
  32023. * @param indices defines the indices to the positions
  32024. * @param indexStart defines the start index
  32025. * @param indexCount defines the end index
  32026. * @param bias defines bias value to add to the result
  32027. * @return minimum and maximum values
  32028. */
  32029. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32030. minimum: Vector3;
  32031. maximum: Vector3;
  32032. };
  32033. /**
  32034. * Extracts minimum and maximum values from a list of positions
  32035. * @param positions defines the positions to use
  32036. * @param start defines the start index in the positions array
  32037. * @param count defines the number of positions to handle
  32038. * @param bias defines bias value to add to the result
  32039. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32040. * @return minimum and maximum values
  32041. */
  32042. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32043. minimum: Vector3;
  32044. maximum: Vector3;
  32045. };
  32046. /**
  32047. * Returns an array if obj is not an array
  32048. * @param obj defines the object to evaluate as an array
  32049. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32050. * @returns either obj directly if obj is an array or a new array containing obj
  32051. */
  32052. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32053. /**
  32054. * Gets the pointer prefix to use
  32055. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32056. */
  32057. static GetPointerPrefix(): string;
  32058. /**
  32059. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32060. * @param func - the function to be called
  32061. * @param requester - the object that will request the next frame. Falls back to window.
  32062. * @returns frame number
  32063. */
  32064. static QueueNewFrame(func: () => void, requester?: any): number;
  32065. /**
  32066. * Ask the browser to promote the current element to fullscreen rendering mode
  32067. * @param element defines the DOM element to promote
  32068. */
  32069. static RequestFullscreen(element: HTMLElement): void;
  32070. /**
  32071. * Asks the browser to exit fullscreen mode
  32072. */
  32073. static ExitFullscreen(): void;
  32074. /**
  32075. * Ask the browser to promote the current element to pointerlock mode
  32076. * @param element defines the DOM element to promote
  32077. */
  32078. static RequestPointerlock(element: HTMLElement): void;
  32079. /**
  32080. * Asks the browser to exit pointerlock mode
  32081. */
  32082. static ExitPointerlock(): void;
  32083. /**
  32084. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32085. * @param url define the url we are trying
  32086. * @param element define the dom element where to configure the cors policy
  32087. */
  32088. static SetCorsBehavior(url: string | string[], element: {
  32089. crossOrigin: string | null;
  32090. }): void;
  32091. /**
  32092. * Removes unwanted characters from an url
  32093. * @param url defines the url to clean
  32094. * @returns the cleaned url
  32095. */
  32096. static CleanUrl(url: string): string;
  32097. /**
  32098. * Gets or sets a function used to pre-process url before using them to load assets
  32099. */
  32100. static PreprocessUrl: (url: string) => string;
  32101. /**
  32102. * Loads an image as an HTMLImageElement.
  32103. * @param input url string, ArrayBuffer, or Blob to load
  32104. * @param onLoad callback called when the image successfully loads
  32105. * @param onError callback called when the image fails to load
  32106. * @param offlineProvider offline provider for caching
  32107. * @returns the HTMLImageElement of the loaded image
  32108. */
  32109. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32110. /**
  32111. * Loads a file
  32112. * @param url url string, ArrayBuffer, or Blob to load
  32113. * @param onSuccess callback called when the file successfully loads
  32114. * @param onProgress callback called while file is loading (if the server supports this mode)
  32115. * @param offlineProvider defines the offline provider for caching
  32116. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32117. * @param onError callback called when the file fails to load
  32118. * @returns a file request object
  32119. */
  32120. 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;
  32121. /**
  32122. * Load a script (identified by an url). When the url returns, the
  32123. * content of this file is added into a new script element, attached to the DOM (body element)
  32124. * @param scriptUrl defines the url of the script to laod
  32125. * @param onSuccess defines the callback called when the script is loaded
  32126. * @param onError defines the callback to call if an error occurs
  32127. * @param scriptId defines the id of the script element
  32128. */
  32129. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32130. /**
  32131. * Load an asynchronous script (identified by an url). When the url returns, the
  32132. * content of this file is added into a new script element, attached to the DOM (body element)
  32133. * @param scriptUrl defines the url of the script to laod
  32134. * @param scriptId defines the id of the script element
  32135. * @returns a promise request object
  32136. */
  32137. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32138. /**
  32139. * Loads a file from a blob
  32140. * @param fileToLoad defines the blob to use
  32141. * @param callback defines the callback to call when data is loaded
  32142. * @param progressCallback defines the callback to call during loading process
  32143. * @returns a file request object
  32144. */
  32145. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32146. /**
  32147. * Loads a file
  32148. * @param fileToLoad defines the file to load
  32149. * @param callback defines the callback to call when data is loaded
  32150. * @param progressCallBack defines the callback to call during loading process
  32151. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32152. * @returns a file request object
  32153. */
  32154. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32155. /**
  32156. * Creates a data url from a given string content
  32157. * @param content defines the content to convert
  32158. * @returns the new data url link
  32159. */
  32160. static FileAsURL(content: string): string;
  32161. /**
  32162. * Format the given number to a specific decimal format
  32163. * @param value defines the number to format
  32164. * @param decimals defines the number of decimals to use
  32165. * @returns the formatted string
  32166. */
  32167. static Format(value: number, decimals?: number): string;
  32168. /**
  32169. * Checks if a given vector is inside a specific range
  32170. * @param v defines the vector to test
  32171. * @param min defines the minimum range
  32172. * @param max defines the maximum range
  32173. */
  32174. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32175. /**
  32176. * Tries to copy an object by duplicating every property
  32177. * @param source defines the source object
  32178. * @param destination defines the target object
  32179. * @param doNotCopyList defines a list of properties to avoid
  32180. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32181. */
  32182. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32183. /**
  32184. * Gets a boolean indicating if the given object has no own property
  32185. * @param obj defines the object to test
  32186. * @returns true if object has no own property
  32187. */
  32188. static IsEmpty(obj: any): boolean;
  32189. /**
  32190. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32191. * @param str Source string
  32192. * @param suffix Suffix to search for in the source string
  32193. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32194. */
  32195. static EndsWith(str: string, suffix: string): boolean;
  32196. /**
  32197. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32198. * @param str Source string
  32199. * @param suffix Suffix to search for in the source string
  32200. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32201. */
  32202. static StartsWith(str: string, suffix: string): boolean;
  32203. /**
  32204. * Function used to register events at window level
  32205. * @param events defines the events to register
  32206. */
  32207. static RegisterTopRootEvents(events: {
  32208. name: string;
  32209. handler: Nullable<(e: FocusEvent) => any>;
  32210. }[]): void;
  32211. /**
  32212. * Function used to unregister events from window level
  32213. * @param events defines the events to unregister
  32214. */
  32215. static UnregisterTopRootEvents(events: {
  32216. name: string;
  32217. handler: Nullable<(e: FocusEvent) => any>;
  32218. }[]): void;
  32219. /**
  32220. * @ignore
  32221. */
  32222. static _ScreenshotCanvas: HTMLCanvasElement;
  32223. /**
  32224. * Dumps the current bound framebuffer
  32225. * @param width defines the rendering width
  32226. * @param height defines the rendering height
  32227. * @param engine defines the hosting engine
  32228. * @param successCallback defines the callback triggered once the data are available
  32229. * @param mimeType defines the mime type of the result
  32230. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32231. */
  32232. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32233. /**
  32234. * Converts the canvas data to blob.
  32235. * This acts as a polyfill for browsers not supporting the to blob function.
  32236. * @param canvas Defines the canvas to extract the data from
  32237. * @param successCallback Defines the callback triggered once the data are available
  32238. * @param mimeType Defines the mime type of the result
  32239. */
  32240. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32241. /**
  32242. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32243. * @param successCallback defines the callback triggered once the data are available
  32244. * @param mimeType defines the mime type of the result
  32245. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32246. */
  32247. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32248. /**
  32249. * Downloads a blob in the browser
  32250. * @param blob defines the blob to download
  32251. * @param fileName defines the name of the downloaded file
  32252. */
  32253. static Download(blob: Blob, fileName: string): void;
  32254. /**
  32255. * Captures a screenshot of the current rendering
  32256. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32257. * @param engine defines the rendering engine
  32258. * @param camera defines the source camera
  32259. * @param size This parameter can be set to a single number or to an object with the
  32260. * following (optional) properties: precision, width, height. If a single number is passed,
  32261. * it will be used for both width and height. If an object is passed, the screenshot size
  32262. * will be derived from the parameters. The precision property is a multiplier allowing
  32263. * rendering at a higher or lower resolution
  32264. * @param successCallback defines the callback receives a single parameter which contains the
  32265. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32266. * src parameter of an <img> to display it
  32267. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32268. * Check your browser for supported MIME types
  32269. */
  32270. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32271. /**
  32272. * Generates an image screenshot from the specified camera.
  32273. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32274. * @param engine The engine to use for rendering
  32275. * @param camera The camera to use for rendering
  32276. * @param size This parameter can be set to a single number or to an object with the
  32277. * following (optional) properties: precision, width, height. If a single number is passed,
  32278. * it will be used for both width and height. If an object is passed, the screenshot size
  32279. * will be derived from the parameters. The precision property is a multiplier allowing
  32280. * rendering at a higher or lower resolution
  32281. * @param successCallback The callback receives a single parameter which contains the
  32282. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32283. * src parameter of an <img> to display it
  32284. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32285. * Check your browser for supported MIME types
  32286. * @param samples Texture samples (default: 1)
  32287. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32288. * @param fileName A name for for the downloaded file.
  32289. */
  32290. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32291. /**
  32292. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32293. * Be aware Math.random() could cause collisions, but:
  32294. * "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"
  32295. * @returns a pseudo random id
  32296. */
  32297. static RandomId(): string;
  32298. /**
  32299. * Test if the given uri is a base64 string
  32300. * @param uri The uri to test
  32301. * @return True if the uri is a base64 string or false otherwise
  32302. */
  32303. static IsBase64(uri: string): boolean;
  32304. /**
  32305. * Decode the given base64 uri.
  32306. * @param uri The uri to decode
  32307. * @return The decoded base64 data.
  32308. */
  32309. static DecodeBase64(uri: string): ArrayBuffer;
  32310. /**
  32311. * Gets the absolute url.
  32312. * @param url the input url
  32313. * @return the absolute url
  32314. */
  32315. static GetAbsoluteUrl(url: string): string;
  32316. /**
  32317. * No log
  32318. */
  32319. static readonly NoneLogLevel: number;
  32320. /**
  32321. * Only message logs
  32322. */
  32323. static readonly MessageLogLevel: number;
  32324. /**
  32325. * Only warning logs
  32326. */
  32327. static readonly WarningLogLevel: number;
  32328. /**
  32329. * Only error logs
  32330. */
  32331. static readonly ErrorLogLevel: number;
  32332. /**
  32333. * All logs
  32334. */
  32335. static readonly AllLogLevel: number;
  32336. /**
  32337. * Gets a value indicating the number of loading errors
  32338. * @ignorenaming
  32339. */
  32340. static readonly errorsCount: number;
  32341. /**
  32342. * Callback called when a new log is added
  32343. */
  32344. static OnNewCacheEntry: (entry: string) => void;
  32345. /**
  32346. * Log a message to the console
  32347. * @param message defines the message to log
  32348. */
  32349. static Log(message: string): void;
  32350. /**
  32351. * Write a warning message to the console
  32352. * @param message defines the message to log
  32353. */
  32354. static Warn(message: string): void;
  32355. /**
  32356. * Write an error message to the console
  32357. * @param message defines the message to log
  32358. */
  32359. static Error(message: string): void;
  32360. /**
  32361. * Gets current log cache (list of logs)
  32362. */
  32363. static readonly LogCache: string;
  32364. /**
  32365. * Clears the log cache
  32366. */
  32367. static ClearLogCache(): void;
  32368. /**
  32369. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32370. */
  32371. static LogLevels: number;
  32372. /**
  32373. * Checks if the loaded document was accessed via `file:`-Protocol.
  32374. * @returns boolean
  32375. */
  32376. static IsFileURL(): boolean;
  32377. /**
  32378. * Checks if the window object exists
  32379. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32380. */
  32381. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32382. /**
  32383. * No performance log
  32384. */
  32385. static readonly PerformanceNoneLogLevel: number;
  32386. /**
  32387. * Use user marks to log performance
  32388. */
  32389. static readonly PerformanceUserMarkLogLevel: number;
  32390. /**
  32391. * Log performance to the console
  32392. */
  32393. static readonly PerformanceConsoleLogLevel: number;
  32394. private static _performance;
  32395. /**
  32396. * Sets the current performance log level
  32397. */
  32398. static PerformanceLogLevel: number;
  32399. private static _StartPerformanceCounterDisabled;
  32400. private static _EndPerformanceCounterDisabled;
  32401. private static _StartUserMark;
  32402. private static _EndUserMark;
  32403. private static _StartPerformanceConsole;
  32404. private static _EndPerformanceConsole;
  32405. /**
  32406. * Starts a performance counter
  32407. */
  32408. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32409. /**
  32410. * Ends a specific performance coutner
  32411. */
  32412. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32413. /**
  32414. * Gets either window.performance.now() if supported or Date.now() else
  32415. */
  32416. static readonly Now: number;
  32417. /**
  32418. * This method will return the name of the class used to create the instance of the given object.
  32419. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32420. * @param object the object to get the class name from
  32421. * @param isType defines if the object is actually a type
  32422. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32423. */
  32424. static GetClassName(object: any, isType?: boolean): string;
  32425. /**
  32426. * Gets the first element of an array satisfying a given predicate
  32427. * @param array defines the array to browse
  32428. * @param predicate defines the predicate to use
  32429. * @returns null if not found or the element
  32430. */
  32431. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32432. /**
  32433. * This method will return the name of the full name of the class, including its owning module (if any).
  32434. * 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).
  32435. * @param object the object to get the class name from
  32436. * @param isType defines if the object is actually a type
  32437. * @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.
  32438. * @ignorenaming
  32439. */
  32440. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32441. /**
  32442. * Returns a promise that resolves after the given amount of time.
  32443. * @param delay Number of milliseconds to delay
  32444. * @returns Promise that resolves after the given amount of time
  32445. */
  32446. static DelayAsync(delay: number): Promise<void>;
  32447. /**
  32448. * Gets the current gradient from an array of IValueGradient
  32449. * @param ratio defines the current ratio to get
  32450. * @param gradients defines the array of IValueGradient
  32451. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32452. */
  32453. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32454. }
  32455. /**
  32456. * This class is used to track a performance counter which is number based.
  32457. * The user has access to many properties which give statistics of different nature.
  32458. *
  32459. * The implementer can track two kinds of Performance Counter: time and count.
  32460. * 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.
  32461. * 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.
  32462. */
  32463. export class PerfCounter {
  32464. /**
  32465. * Gets or sets a global boolean to turn on and off all the counters
  32466. */
  32467. static Enabled: boolean;
  32468. /**
  32469. * Returns the smallest value ever
  32470. */
  32471. readonly min: number;
  32472. /**
  32473. * Returns the biggest value ever
  32474. */
  32475. readonly max: number;
  32476. /**
  32477. * Returns the average value since the performance counter is running
  32478. */
  32479. readonly average: number;
  32480. /**
  32481. * Returns the average value of the last second the counter was monitored
  32482. */
  32483. readonly lastSecAverage: number;
  32484. /**
  32485. * Returns the current value
  32486. */
  32487. readonly current: number;
  32488. /**
  32489. * Gets the accumulated total
  32490. */
  32491. readonly total: number;
  32492. /**
  32493. * Gets the total value count
  32494. */
  32495. readonly count: number;
  32496. /**
  32497. * Creates a new counter
  32498. */
  32499. constructor();
  32500. /**
  32501. * Call this method to start monitoring a new frame.
  32502. * 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.
  32503. */
  32504. fetchNewFrame(): void;
  32505. /**
  32506. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32507. * @param newCount the count value to add to the monitored count
  32508. * @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.
  32509. */
  32510. addCount(newCount: number, fetchResult: boolean): void;
  32511. /**
  32512. * Start monitoring this performance counter
  32513. */
  32514. beginMonitoring(): void;
  32515. /**
  32516. * Compute the time lapsed since the previous beginMonitoring() call.
  32517. * @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
  32518. */
  32519. endMonitoring(newFrame?: boolean): void;
  32520. private _fetchResult;
  32521. private _startMonitoringTime;
  32522. private _min;
  32523. private _max;
  32524. private _average;
  32525. private _current;
  32526. private _totalValueCount;
  32527. private _totalAccumulated;
  32528. private _lastSecAverage;
  32529. private _lastSecAccumulated;
  32530. private _lastSecTime;
  32531. private _lastSecValueCount;
  32532. }
  32533. /**
  32534. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32535. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32536. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32537. * @param name The name of the class, case should be preserved
  32538. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32539. */
  32540. export function className(name: string, module?: string): (target: Object) => void;
  32541. /**
  32542. * An implementation of a loop for asynchronous functions.
  32543. */
  32544. export class AsyncLoop {
  32545. /**
  32546. * Defines the number of iterations for the loop
  32547. */
  32548. iterations: number;
  32549. /**
  32550. * Defines the current index of the loop.
  32551. */
  32552. index: number;
  32553. private _done;
  32554. private _fn;
  32555. private _successCallback;
  32556. /**
  32557. * Constructor.
  32558. * @param iterations the number of iterations.
  32559. * @param func the function to run each iteration
  32560. * @param successCallback the callback that will be called upon succesful execution
  32561. * @param offset starting offset.
  32562. */
  32563. constructor(
  32564. /**
  32565. * Defines the number of iterations for the loop
  32566. */
  32567. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32568. /**
  32569. * Execute the next iteration. Must be called after the last iteration was finished.
  32570. */
  32571. executeNext(): void;
  32572. /**
  32573. * Break the loop and run the success callback.
  32574. */
  32575. breakLoop(): void;
  32576. /**
  32577. * Create and run an async loop.
  32578. * @param iterations the number of iterations.
  32579. * @param fn the function to run each iteration
  32580. * @param successCallback the callback that will be called upon succesful execution
  32581. * @param offset starting offset.
  32582. * @returns the created async loop object
  32583. */
  32584. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32585. /**
  32586. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32587. * @param iterations total number of iterations
  32588. * @param syncedIterations number of synchronous iterations in each async iteration.
  32589. * @param fn the function to call each iteration.
  32590. * @param callback a success call back that will be called when iterating stops.
  32591. * @param breakFunction a break condition (optional)
  32592. * @param timeout timeout settings for the setTimeout function. default - 0.
  32593. * @returns the created async loop object
  32594. */
  32595. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32596. }
  32597. }
  32598. declare module "babylonjs/Collisions/collisionCoordinator" {
  32599. import { Nullable } from "babylonjs/types";
  32600. import { Scene } from "babylonjs/scene";
  32601. import { Vector3 } from "babylonjs/Maths/math";
  32602. import { Collider } from "babylonjs/Collisions/collider";
  32603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32604. /** @hidden */
  32605. export interface ICollisionCoordinator {
  32606. createCollider(): Collider;
  32607. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32608. init(scene: Scene): void;
  32609. }
  32610. /** @hidden */
  32611. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32612. private _scene;
  32613. private _scaledPosition;
  32614. private _scaledVelocity;
  32615. private _finalPosition;
  32616. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32617. createCollider(): Collider;
  32618. init(scene: Scene): void;
  32619. private _collideWithWorld;
  32620. }
  32621. }
  32622. declare module "babylonjs/Inputs/scene.inputManager" {
  32623. import { Nullable } from "babylonjs/types";
  32624. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32625. import { Vector2 } from "babylonjs/Maths/math";
  32626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32627. import { Scene } from "babylonjs/scene";
  32628. /**
  32629. * Class used to manage all inputs for the scene.
  32630. */
  32631. export class InputManager {
  32632. /** The distance in pixel that you have to move to prevent some events */
  32633. static DragMovementThreshold: number;
  32634. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32635. static LongPressDelay: number;
  32636. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32637. static DoubleClickDelay: number;
  32638. /** If you need to check double click without raising a single click at first click, enable this flag */
  32639. static ExclusiveDoubleClickMode: boolean;
  32640. private _wheelEventName;
  32641. private _onPointerMove;
  32642. private _onPointerDown;
  32643. private _onPointerUp;
  32644. private _initClickEvent;
  32645. private _initActionManager;
  32646. private _delayedSimpleClick;
  32647. private _delayedSimpleClickTimeout;
  32648. private _previousDelayedSimpleClickTimeout;
  32649. private _meshPickProceed;
  32650. private _previousButtonPressed;
  32651. private _currentPickResult;
  32652. private _previousPickResult;
  32653. private _totalPointersPressed;
  32654. private _doubleClickOccured;
  32655. private _pointerOverMesh;
  32656. private _pickedDownMesh;
  32657. private _pickedUpMesh;
  32658. private _pointerX;
  32659. private _pointerY;
  32660. private _unTranslatedPointerX;
  32661. private _unTranslatedPointerY;
  32662. private _startingPointerPosition;
  32663. private _previousStartingPointerPosition;
  32664. private _startingPointerTime;
  32665. private _previousStartingPointerTime;
  32666. private _pointerCaptures;
  32667. private _onKeyDown;
  32668. private _onKeyUp;
  32669. private _onCanvasFocusObserver;
  32670. private _onCanvasBlurObserver;
  32671. private _scene;
  32672. /**
  32673. * Creates a new InputManager
  32674. * @param scene defines the hosting scene
  32675. */
  32676. constructor(scene: Scene);
  32677. /**
  32678. * Gets the mesh that is currently under the pointer
  32679. */
  32680. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32681. /**
  32682. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32683. */
  32684. readonly unTranslatedPointer: Vector2;
  32685. /**
  32686. * Gets or sets the current on-screen X position of the pointer
  32687. */
  32688. pointerX: number;
  32689. /**
  32690. * Gets or sets the current on-screen Y position of the pointer
  32691. */
  32692. pointerY: number;
  32693. private _updatePointerPosition;
  32694. private _processPointerMove;
  32695. private _setRayOnPointerInfo;
  32696. private _checkPrePointerObservable;
  32697. /**
  32698. * Use this method to simulate a pointer move on a mesh
  32699. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32700. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32701. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32702. */
  32703. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32704. /**
  32705. * Use this method to simulate a pointer down on a mesh
  32706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32709. */
  32710. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32711. private _processPointerDown;
  32712. /** @hidden */
  32713. _isPointerSwiping(): boolean;
  32714. /**
  32715. * Use this method to simulate a pointer up on a mesh
  32716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32719. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32720. */
  32721. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32722. private _processPointerUp;
  32723. /**
  32724. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32725. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32726. * @returns true if the pointer was captured
  32727. */
  32728. isPointerCaptured(pointerId?: number): boolean;
  32729. /**
  32730. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32731. * @param attachUp defines if you want to attach events to pointerup
  32732. * @param attachDown defines if you want to attach events to pointerdown
  32733. * @param attachMove defines if you want to attach events to pointermove
  32734. */
  32735. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32736. /**
  32737. * Detaches all event handlers
  32738. */
  32739. detachControl(): void;
  32740. /**
  32741. * Force the value of meshUnderPointer
  32742. * @param mesh defines the mesh to use
  32743. */
  32744. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32745. /**
  32746. * Gets the mesh under the pointer
  32747. * @returns a Mesh or null if no mesh is under the pointer
  32748. */
  32749. getPointerOverMesh(): Nullable<AbstractMesh>;
  32750. }
  32751. }
  32752. declare module "babylonjs/Animations/animationGroup" {
  32753. import { Animatable } from "babylonjs/Animations/animatable";
  32754. import { Animation } from "babylonjs/Animations/animation";
  32755. import { Scene, IDisposable } from "babylonjs/scene";
  32756. import { Observable } from "babylonjs/Misc/observable";
  32757. import { Nullable } from "babylonjs/types";
  32758. import "babylonjs/Animations/animatable";
  32759. /**
  32760. * This class defines the direct association between an animation and a target
  32761. */
  32762. export class TargetedAnimation {
  32763. /**
  32764. * Animation to perform
  32765. */
  32766. animation: Animation;
  32767. /**
  32768. * Target to animate
  32769. */
  32770. target: any;
  32771. /**
  32772. * Serialize the object
  32773. * @returns the JSON object representing the current entity
  32774. */
  32775. serialize(): any;
  32776. }
  32777. /**
  32778. * Use this class to create coordinated animations on multiple targets
  32779. */
  32780. export class AnimationGroup implements IDisposable {
  32781. /** The name of the animation group */
  32782. name: string;
  32783. private _scene;
  32784. private _targetedAnimations;
  32785. private _animatables;
  32786. private _from;
  32787. private _to;
  32788. private _isStarted;
  32789. private _isPaused;
  32790. private _speedRatio;
  32791. private _loopAnimation;
  32792. /**
  32793. * Gets or sets the unique id of the node
  32794. */
  32795. uniqueId: number;
  32796. /**
  32797. * This observable will notify when one animation have ended
  32798. */
  32799. onAnimationEndObservable: Observable<TargetedAnimation>;
  32800. /**
  32801. * Observer raised when one animation loops
  32802. */
  32803. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32804. /**
  32805. * This observable will notify when all animations have ended.
  32806. */
  32807. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32808. /**
  32809. * This observable will notify when all animations have paused.
  32810. */
  32811. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32812. /**
  32813. * This observable will notify when all animations are playing.
  32814. */
  32815. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32816. /**
  32817. * Gets the first frame
  32818. */
  32819. readonly from: number;
  32820. /**
  32821. * Gets the last frame
  32822. */
  32823. readonly to: number;
  32824. /**
  32825. * Define if the animations are started
  32826. */
  32827. readonly isStarted: boolean;
  32828. /**
  32829. * Gets a value indicating that the current group is playing
  32830. */
  32831. readonly isPlaying: boolean;
  32832. /**
  32833. * Gets or sets the speed ratio to use for all animations
  32834. */
  32835. /**
  32836. * Gets or sets the speed ratio to use for all animations
  32837. */
  32838. speedRatio: number;
  32839. /**
  32840. * Gets or sets if all animations should loop or not
  32841. */
  32842. loopAnimation: boolean;
  32843. /**
  32844. * Gets the targeted animations for this animation group
  32845. */
  32846. readonly targetedAnimations: Array<TargetedAnimation>;
  32847. /**
  32848. * returning the list of animatables controlled by this animation group.
  32849. */
  32850. readonly animatables: Array<Animatable>;
  32851. /**
  32852. * Instantiates a new Animation Group.
  32853. * This helps managing several animations at once.
  32854. * @see http://doc.babylonjs.com/how_to/group
  32855. * @param name Defines the name of the group
  32856. * @param scene Defines the scene the group belongs to
  32857. */
  32858. constructor(
  32859. /** The name of the animation group */
  32860. name: string, scene?: Nullable<Scene>);
  32861. /**
  32862. * Add an animation (with its target) in the group
  32863. * @param animation defines the animation we want to add
  32864. * @param target defines the target of the animation
  32865. * @returns the TargetedAnimation object
  32866. */
  32867. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32868. /**
  32869. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32870. * It can add constant keys at begin or end
  32871. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32872. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32873. * @returns the animation group
  32874. */
  32875. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32876. /**
  32877. * Start all animations on given targets
  32878. * @param loop defines if animations must loop
  32879. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32880. * @param from defines the from key (optional)
  32881. * @param to defines the to key (optional)
  32882. * @returns the current animation group
  32883. */
  32884. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32885. /**
  32886. * Pause all animations
  32887. * @returns the animation group
  32888. */
  32889. pause(): AnimationGroup;
  32890. /**
  32891. * Play all animations to initial state
  32892. * This function will start() the animations if they were not started or will restart() them if they were paused
  32893. * @param loop defines if animations must loop
  32894. * @returns the animation group
  32895. */
  32896. play(loop?: boolean): AnimationGroup;
  32897. /**
  32898. * Reset all animations to initial state
  32899. * @returns the animation group
  32900. */
  32901. reset(): AnimationGroup;
  32902. /**
  32903. * Restart animations from key 0
  32904. * @returns the animation group
  32905. */
  32906. restart(): AnimationGroup;
  32907. /**
  32908. * Stop all animations
  32909. * @returns the animation group
  32910. */
  32911. stop(): AnimationGroup;
  32912. /**
  32913. * Set animation weight for all animatables
  32914. * @param weight defines the weight to use
  32915. * @return the animationGroup
  32916. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32917. */
  32918. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32919. /**
  32920. * Synchronize and normalize all animatables with a source animatable
  32921. * @param root defines the root animatable to synchronize with
  32922. * @return the animationGroup
  32923. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32924. */
  32925. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32926. /**
  32927. * Goes to a specific frame in this animation group
  32928. * @param frame the frame number to go to
  32929. * @return the animationGroup
  32930. */
  32931. goToFrame(frame: number): AnimationGroup;
  32932. /**
  32933. * Dispose all associated resources
  32934. */
  32935. dispose(): void;
  32936. private _checkAnimationGroupEnded;
  32937. /**
  32938. * Clone the current animation group and returns a copy
  32939. * @param newName defines the name of the new group
  32940. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32941. * @returns the new aniamtion group
  32942. */
  32943. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32944. /**
  32945. * Serializes the animationGroup to an object
  32946. * @returns Serialized object
  32947. */
  32948. serialize(): any;
  32949. /**
  32950. * Returns a new AnimationGroup object parsed from the source provided.
  32951. * @param parsedAnimationGroup defines the source
  32952. * @param scene defines the scene that will receive the animationGroup
  32953. * @returns a new AnimationGroup
  32954. */
  32955. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32956. /**
  32957. * Returns the string "AnimationGroup"
  32958. * @returns "AnimationGroup"
  32959. */
  32960. getClassName(): string;
  32961. /**
  32962. * Creates a detailled string about the object
  32963. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32964. * @returns a string representing the object
  32965. */
  32966. toString(fullDetails?: boolean): string;
  32967. }
  32968. }
  32969. declare module "babylonjs/scene" {
  32970. import { Nullable } from "babylonjs/types";
  32971. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32972. import { Observable } from "babylonjs/Misc/observable";
  32973. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32974. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32975. import { Geometry } from "babylonjs/Meshes/geometry";
  32976. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32979. import { Mesh } from "babylonjs/Meshes/mesh";
  32980. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32981. import { Bone } from "babylonjs/Bones/bone";
  32982. import { Skeleton } from "babylonjs/Bones/skeleton";
  32983. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32984. import { Camera } from "babylonjs/Cameras/camera";
  32985. import { AbstractScene } from "babylonjs/abstractScene";
  32986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32987. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32988. import { Material } from "babylonjs/Materials/material";
  32989. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32990. import { Effect } from "babylonjs/Materials/effect";
  32991. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32992. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32993. import { Light } from "babylonjs/Lights/light";
  32994. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32995. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32996. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32997. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32998. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32999. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33000. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33001. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33002. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33003. import { Engine } from "babylonjs/Engines/engine";
  33004. import { Node } from "babylonjs/node";
  33005. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33006. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33007. import { WebRequest } from "babylonjs/Misc/webRequest";
  33008. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33009. import { Ray } from "babylonjs/Culling/ray";
  33010. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33011. import { Animation } from "babylonjs/Animations/animation";
  33012. import { Animatable } from "babylonjs/Animations/animatable";
  33013. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33014. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33015. import { Collider } from "babylonjs/Collisions/collider";
  33016. /**
  33017. * Define an interface for all classes that will hold resources
  33018. */
  33019. export interface IDisposable {
  33020. /**
  33021. * Releases all held resources
  33022. */
  33023. dispose(): void;
  33024. }
  33025. /** Interface defining initialization parameters for Scene class */
  33026. export interface SceneOptions {
  33027. /**
  33028. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33029. * It will improve performance when the number of geometries becomes important.
  33030. */
  33031. useGeometryUniqueIdsMap?: boolean;
  33032. /**
  33033. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33034. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33035. */
  33036. useMaterialMeshMap?: boolean;
  33037. /**
  33038. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33039. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33040. */
  33041. useClonedMeshhMap?: boolean;
  33042. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33043. virtual?: boolean;
  33044. }
  33045. /**
  33046. * Represents a scene to be rendered by the engine.
  33047. * @see http://doc.babylonjs.com/features/scene
  33048. */
  33049. export class Scene extends AbstractScene implements IAnimatable {
  33050. private static _uniqueIdCounter;
  33051. /** The fog is deactivated */
  33052. static readonly FOGMODE_NONE: number;
  33053. /** The fog density is following an exponential function */
  33054. static readonly FOGMODE_EXP: number;
  33055. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33056. static readonly FOGMODE_EXP2: number;
  33057. /** The fog density is following a linear function. */
  33058. static readonly FOGMODE_LINEAR: number;
  33059. /**
  33060. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33061. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33062. */
  33063. static MinDeltaTime: number;
  33064. /**
  33065. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33066. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33067. */
  33068. static MaxDeltaTime: number;
  33069. /**
  33070. * Factory used to create the default material.
  33071. * @param name The name of the material to create
  33072. * @param scene The scene to create the material for
  33073. * @returns The default material
  33074. */
  33075. static DefaultMaterialFactory(scene: Scene): Material;
  33076. /**
  33077. * Factory used to create the a collision coordinator.
  33078. * @returns The collision coordinator
  33079. */
  33080. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33081. /** @hidden */
  33082. _inputManager: InputManager;
  33083. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33084. cameraToUseForPointers: Nullable<Camera>;
  33085. /** @hidden */
  33086. readonly _isScene: boolean;
  33087. /**
  33088. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33089. */
  33090. autoClear: boolean;
  33091. /**
  33092. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33093. */
  33094. autoClearDepthAndStencil: boolean;
  33095. /**
  33096. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33097. */
  33098. clearColor: Color4;
  33099. /**
  33100. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33101. */
  33102. ambientColor: Color3;
  33103. /**
  33104. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33105. * It should only be one of the following (if not the default embedded one):
  33106. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33107. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33108. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33109. * The material properties need to be setup according to the type of texture in use.
  33110. */
  33111. environmentBRDFTexture: BaseTexture;
  33112. /** @hidden */
  33113. protected _environmentTexture: Nullable<BaseTexture>;
  33114. /**
  33115. * Texture used in all pbr material as the reflection texture.
  33116. * As in the majority of the scene they are the same (exception for multi room and so on),
  33117. * this is easier to reference from here than from all the materials.
  33118. */
  33119. /**
  33120. * Texture used in all pbr material as the reflection texture.
  33121. * As in the majority of the scene they are the same (exception for multi room and so on),
  33122. * this is easier to set here than in all the materials.
  33123. */
  33124. environmentTexture: Nullable<BaseTexture>;
  33125. /** @hidden */
  33126. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33127. /**
  33128. * Default image processing configuration used either in the rendering
  33129. * Forward main pass or through the imageProcessingPostProcess if present.
  33130. * As in the majority of the scene they are the same (exception for multi camera),
  33131. * this is easier to reference from here than from all the materials and post process.
  33132. *
  33133. * No setter as we it is a shared configuration, you can set the values instead.
  33134. */
  33135. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33136. private _forceWireframe;
  33137. /**
  33138. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33139. */
  33140. forceWireframe: boolean;
  33141. private _forcePointsCloud;
  33142. /**
  33143. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33144. */
  33145. forcePointsCloud: boolean;
  33146. /**
  33147. * Gets or sets the active clipplane 1
  33148. */
  33149. clipPlane: Nullable<Plane>;
  33150. /**
  33151. * Gets or sets the active clipplane 2
  33152. */
  33153. clipPlane2: Nullable<Plane>;
  33154. /**
  33155. * Gets or sets the active clipplane 3
  33156. */
  33157. clipPlane3: Nullable<Plane>;
  33158. /**
  33159. * Gets or sets the active clipplane 4
  33160. */
  33161. clipPlane4: Nullable<Plane>;
  33162. /**
  33163. * Gets or sets a boolean indicating if animations are enabled
  33164. */
  33165. animationsEnabled: boolean;
  33166. private _animationPropertiesOverride;
  33167. /**
  33168. * Gets or sets the animation properties override
  33169. */
  33170. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33171. /**
  33172. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33173. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33174. */
  33175. useConstantAnimationDeltaTime: boolean;
  33176. /**
  33177. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33178. * Please note that it requires to run a ray cast through the scene on every frame
  33179. */
  33180. constantlyUpdateMeshUnderPointer: boolean;
  33181. /**
  33182. * Defines the HTML cursor to use when hovering over interactive elements
  33183. */
  33184. hoverCursor: string;
  33185. /**
  33186. * Defines the HTML default cursor to use (empty by default)
  33187. */
  33188. defaultCursor: string;
  33189. /**
  33190. * This is used to call preventDefault() on pointer down
  33191. * in order to block unwanted artifacts like system double clicks
  33192. */
  33193. preventDefaultOnPointerDown: boolean;
  33194. /**
  33195. * This is used to call preventDefault() on pointer up
  33196. * in order to block unwanted artifacts like system double clicks
  33197. */
  33198. preventDefaultOnPointerUp: boolean;
  33199. /**
  33200. * Gets or sets user defined metadata
  33201. */
  33202. metadata: any;
  33203. /**
  33204. * For internal use only. Please do not use.
  33205. */
  33206. reservedDataStore: any;
  33207. /**
  33208. * Gets the name of the plugin used to load this scene (null by default)
  33209. */
  33210. loadingPluginName: string;
  33211. /**
  33212. * Use this array to add regular expressions used to disable offline support for specific urls
  33213. */
  33214. disableOfflineSupportExceptionRules: RegExp[];
  33215. /**
  33216. * An event triggered when the scene is disposed.
  33217. */
  33218. onDisposeObservable: Observable<Scene>;
  33219. private _onDisposeObserver;
  33220. /** Sets a function to be executed when this scene is disposed. */
  33221. onDispose: () => void;
  33222. /**
  33223. * An event triggered before rendering the scene (right after animations and physics)
  33224. */
  33225. onBeforeRenderObservable: Observable<Scene>;
  33226. private _onBeforeRenderObserver;
  33227. /** Sets a function to be executed before rendering this scene */
  33228. beforeRender: Nullable<() => void>;
  33229. /**
  33230. * An event triggered after rendering the scene
  33231. */
  33232. onAfterRenderObservable: Observable<Scene>;
  33233. /**
  33234. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33235. */
  33236. onAfterRenderCameraObservable: Observable<Camera>;
  33237. private _onAfterRenderObserver;
  33238. /** Sets a function to be executed after rendering this scene */
  33239. afterRender: Nullable<() => void>;
  33240. /**
  33241. * An event triggered before animating the scene
  33242. */
  33243. onBeforeAnimationsObservable: Observable<Scene>;
  33244. /**
  33245. * An event triggered after animations processing
  33246. */
  33247. onAfterAnimationsObservable: Observable<Scene>;
  33248. /**
  33249. * An event triggered before draw calls are ready to be sent
  33250. */
  33251. onBeforeDrawPhaseObservable: Observable<Scene>;
  33252. /**
  33253. * An event triggered after draw calls have been sent
  33254. */
  33255. onAfterDrawPhaseObservable: Observable<Scene>;
  33256. /**
  33257. * An event triggered when the scene is ready
  33258. */
  33259. onReadyObservable: Observable<Scene>;
  33260. /**
  33261. * An event triggered before rendering a camera
  33262. */
  33263. onBeforeCameraRenderObservable: Observable<Camera>;
  33264. private _onBeforeCameraRenderObserver;
  33265. /** Sets a function to be executed before rendering a camera*/
  33266. beforeCameraRender: () => void;
  33267. /**
  33268. * An event triggered after rendering a camera
  33269. */
  33270. onAfterCameraRenderObservable: Observable<Camera>;
  33271. private _onAfterCameraRenderObserver;
  33272. /** Sets a function to be executed after rendering a camera*/
  33273. afterCameraRender: () => void;
  33274. /**
  33275. * An event triggered when active meshes evaluation is about to start
  33276. */
  33277. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33278. /**
  33279. * An event triggered when active meshes evaluation is done
  33280. */
  33281. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33282. /**
  33283. * An event triggered when particles rendering is about to start
  33284. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33285. */
  33286. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33287. /**
  33288. * An event triggered when particles rendering is done
  33289. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33290. */
  33291. onAfterParticlesRenderingObservable: Observable<Scene>;
  33292. /**
  33293. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33294. */
  33295. onDataLoadedObservable: Observable<Scene>;
  33296. /**
  33297. * An event triggered when a camera is created
  33298. */
  33299. onNewCameraAddedObservable: Observable<Camera>;
  33300. /**
  33301. * An event triggered when a camera is removed
  33302. */
  33303. onCameraRemovedObservable: Observable<Camera>;
  33304. /**
  33305. * An event triggered when a light is created
  33306. */
  33307. onNewLightAddedObservable: Observable<Light>;
  33308. /**
  33309. * An event triggered when a light is removed
  33310. */
  33311. onLightRemovedObservable: Observable<Light>;
  33312. /**
  33313. * An event triggered when a geometry is created
  33314. */
  33315. onNewGeometryAddedObservable: Observable<Geometry>;
  33316. /**
  33317. * An event triggered when a geometry is removed
  33318. */
  33319. onGeometryRemovedObservable: Observable<Geometry>;
  33320. /**
  33321. * An event triggered when a transform node is created
  33322. */
  33323. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33324. /**
  33325. * An event triggered when a transform node is removed
  33326. */
  33327. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33328. /**
  33329. * An event triggered when a mesh is created
  33330. */
  33331. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33332. /**
  33333. * An event triggered when a mesh is removed
  33334. */
  33335. onMeshRemovedObservable: Observable<AbstractMesh>;
  33336. /**
  33337. * An event triggered when a skeleton is created
  33338. */
  33339. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33340. /**
  33341. * An event triggered when a skeleton is removed
  33342. */
  33343. onSkeletonRemovedObservable: Observable<Skeleton>;
  33344. /**
  33345. * An event triggered when a material is created
  33346. */
  33347. onNewMaterialAddedObservable: Observable<Material>;
  33348. /**
  33349. * An event triggered when a material is removed
  33350. */
  33351. onMaterialRemovedObservable: Observable<Material>;
  33352. /**
  33353. * An event triggered when a texture is created
  33354. */
  33355. onNewTextureAddedObservable: Observable<BaseTexture>;
  33356. /**
  33357. * An event triggered when a texture is removed
  33358. */
  33359. onTextureRemovedObservable: Observable<BaseTexture>;
  33360. /**
  33361. * An event triggered when render targets are about to be rendered
  33362. * Can happen multiple times per frame.
  33363. */
  33364. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33365. /**
  33366. * An event triggered when render targets were rendered.
  33367. * Can happen multiple times per frame.
  33368. */
  33369. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33370. /**
  33371. * An event triggered before calculating deterministic simulation step
  33372. */
  33373. onBeforeStepObservable: Observable<Scene>;
  33374. /**
  33375. * An event triggered after calculating deterministic simulation step
  33376. */
  33377. onAfterStepObservable: Observable<Scene>;
  33378. /**
  33379. * An event triggered when the activeCamera property is updated
  33380. */
  33381. onActiveCameraChanged: Observable<Scene>;
  33382. /**
  33383. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33384. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33385. * 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)
  33386. */
  33387. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33388. /**
  33389. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33390. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33391. * 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)
  33392. */
  33393. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33394. /**
  33395. * This Observable will when a mesh has been imported into the scene.
  33396. */
  33397. onMeshImportedObservable: Observable<AbstractMesh>;
  33398. /**
  33399. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33400. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33401. */
  33402. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33403. /** @hidden */
  33404. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33405. /**
  33406. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33407. */
  33408. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33409. /**
  33410. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33411. */
  33412. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33413. /**
  33414. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33415. */
  33416. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33417. /** Callback called when a pointer move is detected */
  33418. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33419. /** Callback called when a pointer down is detected */
  33420. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33421. /** Callback called when a pointer up is detected */
  33422. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33423. /** Callback called when a pointer pick is detected */
  33424. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33425. /**
  33426. * 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).
  33427. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33428. */
  33429. onPrePointerObservable: Observable<PointerInfoPre>;
  33430. /**
  33431. * Observable event triggered each time an input event is received from the rendering canvas
  33432. */
  33433. onPointerObservable: Observable<PointerInfo>;
  33434. /**
  33435. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33436. */
  33437. readonly unTranslatedPointer: Vector2;
  33438. /**
  33439. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33440. */
  33441. static DragMovementThreshold: number;
  33442. /**
  33443. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33444. */
  33445. static LongPressDelay: number;
  33446. /**
  33447. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33448. */
  33449. static DoubleClickDelay: number;
  33450. /** If you need to check double click without raising a single click at first click, enable this flag */
  33451. static ExclusiveDoubleClickMode: boolean;
  33452. /** @hidden */
  33453. _mirroredCameraPosition: Nullable<Vector3>;
  33454. /**
  33455. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33456. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33457. */
  33458. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33459. /**
  33460. * Observable event triggered each time an keyboard event is received from the hosting window
  33461. */
  33462. onKeyboardObservable: Observable<KeyboardInfo>;
  33463. private _useRightHandedSystem;
  33464. /**
  33465. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33466. */
  33467. useRightHandedSystem: boolean;
  33468. private _timeAccumulator;
  33469. private _currentStepId;
  33470. private _currentInternalStep;
  33471. /**
  33472. * Sets the step Id used by deterministic lock step
  33473. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33474. * @param newStepId defines the step Id
  33475. */
  33476. setStepId(newStepId: number): void;
  33477. /**
  33478. * Gets the step Id used by deterministic lock step
  33479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33480. * @returns the step Id
  33481. */
  33482. getStepId(): number;
  33483. /**
  33484. * Gets the internal step used by deterministic lock step
  33485. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33486. * @returns the internal step
  33487. */
  33488. getInternalStep(): number;
  33489. private _fogEnabled;
  33490. /**
  33491. * Gets or sets a boolean indicating if fog is enabled on this scene
  33492. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33493. * (Default is true)
  33494. */
  33495. fogEnabled: boolean;
  33496. private _fogMode;
  33497. /**
  33498. * Gets or sets the fog mode to use
  33499. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33500. * | mode | value |
  33501. * | --- | --- |
  33502. * | FOGMODE_NONE | 0 |
  33503. * | FOGMODE_EXP | 1 |
  33504. * | FOGMODE_EXP2 | 2 |
  33505. * | FOGMODE_LINEAR | 3 |
  33506. */
  33507. fogMode: number;
  33508. /**
  33509. * Gets or sets the fog color to use
  33510. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33511. * (Default is Color3(0.2, 0.2, 0.3))
  33512. */
  33513. fogColor: Color3;
  33514. /**
  33515. * Gets or sets the fog density to use
  33516. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33517. * (Default is 0.1)
  33518. */
  33519. fogDensity: number;
  33520. /**
  33521. * Gets or sets the fog start distance to use
  33522. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33523. * (Default is 0)
  33524. */
  33525. fogStart: number;
  33526. /**
  33527. * Gets or sets the fog end distance to use
  33528. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33529. * (Default is 1000)
  33530. */
  33531. fogEnd: number;
  33532. private _shadowsEnabled;
  33533. /**
  33534. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33535. */
  33536. shadowsEnabled: boolean;
  33537. private _lightsEnabled;
  33538. /**
  33539. * Gets or sets a boolean indicating if lights are enabled on this scene
  33540. */
  33541. lightsEnabled: boolean;
  33542. /** All of the active cameras added to this scene. */
  33543. activeCameras: Camera[];
  33544. /** @hidden */
  33545. _activeCamera: Nullable<Camera>;
  33546. /** Gets or sets the current active camera */
  33547. activeCamera: Nullable<Camera>;
  33548. private _defaultMaterial;
  33549. /** The default material used on meshes when no material is affected */
  33550. /** The default material used on meshes when no material is affected */
  33551. defaultMaterial: Material;
  33552. private _texturesEnabled;
  33553. /**
  33554. * Gets or sets a boolean indicating if textures are enabled on this scene
  33555. */
  33556. texturesEnabled: boolean;
  33557. /**
  33558. * Gets or sets a boolean indicating if particles are enabled on this scene
  33559. */
  33560. particlesEnabled: boolean;
  33561. /**
  33562. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33563. */
  33564. spritesEnabled: boolean;
  33565. private _skeletonsEnabled;
  33566. /**
  33567. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33568. */
  33569. skeletonsEnabled: boolean;
  33570. /**
  33571. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33572. */
  33573. lensFlaresEnabled: boolean;
  33574. /**
  33575. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33576. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33577. */
  33578. collisionsEnabled: boolean;
  33579. private _collisionCoordinator;
  33580. /** @hidden */
  33581. readonly collisionCoordinator: ICollisionCoordinator;
  33582. /**
  33583. * Defines the gravity applied to this scene (used only for collisions)
  33584. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33585. */
  33586. gravity: Vector3;
  33587. /**
  33588. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33589. */
  33590. postProcessesEnabled: boolean;
  33591. /**
  33592. * The list of postprocesses added to the scene
  33593. */
  33594. postProcesses: PostProcess[];
  33595. /**
  33596. * Gets the current postprocess manager
  33597. */
  33598. postProcessManager: PostProcessManager;
  33599. /**
  33600. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33601. */
  33602. renderTargetsEnabled: boolean;
  33603. /**
  33604. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33605. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33606. */
  33607. dumpNextRenderTargets: boolean;
  33608. /**
  33609. * The list of user defined render targets added to the scene
  33610. */
  33611. customRenderTargets: RenderTargetTexture[];
  33612. /**
  33613. * Defines if texture loading must be delayed
  33614. * If true, textures will only be loaded when they need to be rendered
  33615. */
  33616. useDelayedTextureLoading: boolean;
  33617. /**
  33618. * Gets the list of meshes imported to the scene through SceneLoader
  33619. */
  33620. importedMeshesFiles: String[];
  33621. /**
  33622. * Gets or sets a boolean indicating if probes are enabled on this scene
  33623. */
  33624. probesEnabled: boolean;
  33625. /**
  33626. * Gets or sets the current offline provider to use to store scene data
  33627. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33628. */
  33629. offlineProvider: IOfflineProvider;
  33630. /**
  33631. * Gets or sets the action manager associated with the scene
  33632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33633. */
  33634. actionManager: AbstractActionManager;
  33635. private _meshesForIntersections;
  33636. /**
  33637. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33638. */
  33639. proceduralTexturesEnabled: boolean;
  33640. private _engine;
  33641. private _totalVertices;
  33642. /** @hidden */
  33643. _activeIndices: PerfCounter;
  33644. /** @hidden */
  33645. _activeParticles: PerfCounter;
  33646. /** @hidden */
  33647. _activeBones: PerfCounter;
  33648. private _animationRatio;
  33649. /** @hidden */
  33650. _animationTimeLast: number;
  33651. /** @hidden */
  33652. _animationTime: number;
  33653. /**
  33654. * Gets or sets a general scale for animation speed
  33655. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33656. */
  33657. animationTimeScale: number;
  33658. /** @hidden */
  33659. _cachedMaterial: Nullable<Material>;
  33660. /** @hidden */
  33661. _cachedEffect: Nullable<Effect>;
  33662. /** @hidden */
  33663. _cachedVisibility: Nullable<number>;
  33664. private _renderId;
  33665. private _frameId;
  33666. private _executeWhenReadyTimeoutId;
  33667. private _intermediateRendering;
  33668. private _viewUpdateFlag;
  33669. private _projectionUpdateFlag;
  33670. /** @hidden */
  33671. _toBeDisposed: Nullable<IDisposable>[];
  33672. private _activeRequests;
  33673. /** @hidden */
  33674. _pendingData: any[];
  33675. private _isDisposed;
  33676. /**
  33677. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33678. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33679. */
  33680. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33681. private _activeMeshes;
  33682. private _processedMaterials;
  33683. private _renderTargets;
  33684. /** @hidden */
  33685. _activeParticleSystems: SmartArray<IParticleSystem>;
  33686. private _activeSkeletons;
  33687. private _softwareSkinnedMeshes;
  33688. private _renderingManager;
  33689. /** @hidden */
  33690. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33691. private _transformMatrix;
  33692. private _sceneUbo;
  33693. /** @hidden */
  33694. _viewMatrix: Matrix;
  33695. private _projectionMatrix;
  33696. /** @hidden */
  33697. _forcedViewPosition: Nullable<Vector3>;
  33698. /** @hidden */
  33699. _frustumPlanes: Plane[];
  33700. /**
  33701. * Gets the list of frustum planes (built from the active camera)
  33702. */
  33703. readonly frustumPlanes: Plane[];
  33704. /**
  33705. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33706. * This is useful if there are more lights that the maximum simulteanous authorized
  33707. */
  33708. requireLightSorting: boolean;
  33709. /** @hidden */
  33710. readonly useMaterialMeshMap: boolean;
  33711. /** @hidden */
  33712. readonly useClonedMeshhMap: boolean;
  33713. private _externalData;
  33714. private _uid;
  33715. /**
  33716. * @hidden
  33717. * Backing store of defined scene components.
  33718. */
  33719. _components: ISceneComponent[];
  33720. /**
  33721. * @hidden
  33722. * Backing store of defined scene components.
  33723. */
  33724. _serializableComponents: ISceneSerializableComponent[];
  33725. /**
  33726. * List of components to register on the next registration step.
  33727. */
  33728. private _transientComponents;
  33729. /**
  33730. * Registers the transient components if needed.
  33731. */
  33732. private _registerTransientComponents;
  33733. /**
  33734. * @hidden
  33735. * Add a component to the scene.
  33736. * Note that the ccomponent could be registered on th next frame if this is called after
  33737. * the register component stage.
  33738. * @param component Defines the component to add to the scene
  33739. */
  33740. _addComponent(component: ISceneComponent): void;
  33741. /**
  33742. * @hidden
  33743. * Gets a component from the scene.
  33744. * @param name defines the name of the component to retrieve
  33745. * @returns the component or null if not present
  33746. */
  33747. _getComponent(name: string): Nullable<ISceneComponent>;
  33748. /**
  33749. * @hidden
  33750. * Defines the actions happening before camera updates.
  33751. */
  33752. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33753. /**
  33754. * @hidden
  33755. * Defines the actions happening before clear the canvas.
  33756. */
  33757. _beforeClearStage: Stage<SimpleStageAction>;
  33758. /**
  33759. * @hidden
  33760. * Defines the actions when collecting render targets for the frame.
  33761. */
  33762. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33763. /**
  33764. * @hidden
  33765. * Defines the actions happening for one camera in the frame.
  33766. */
  33767. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33768. /**
  33769. * @hidden
  33770. * Defines the actions happening during the per mesh ready checks.
  33771. */
  33772. _isReadyForMeshStage: Stage<MeshStageAction>;
  33773. /**
  33774. * @hidden
  33775. * Defines the actions happening before evaluate active mesh checks.
  33776. */
  33777. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33778. /**
  33779. * @hidden
  33780. * Defines the actions happening during the evaluate sub mesh checks.
  33781. */
  33782. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33783. /**
  33784. * @hidden
  33785. * Defines the actions happening during the active mesh stage.
  33786. */
  33787. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33788. /**
  33789. * @hidden
  33790. * Defines the actions happening during the per camera render target step.
  33791. */
  33792. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33793. /**
  33794. * @hidden
  33795. * Defines the actions happening just before the active camera is drawing.
  33796. */
  33797. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33798. /**
  33799. * @hidden
  33800. * Defines the actions happening just before a render target is drawing.
  33801. */
  33802. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33803. /**
  33804. * @hidden
  33805. * Defines the actions happening just before a rendering group is drawing.
  33806. */
  33807. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33808. /**
  33809. * @hidden
  33810. * Defines the actions happening just before a mesh is drawing.
  33811. */
  33812. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33813. /**
  33814. * @hidden
  33815. * Defines the actions happening just after a mesh has been drawn.
  33816. */
  33817. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33818. /**
  33819. * @hidden
  33820. * Defines the actions happening just after a rendering group has been drawn.
  33821. */
  33822. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33823. /**
  33824. * @hidden
  33825. * Defines the actions happening just after the active camera has been drawn.
  33826. */
  33827. _afterCameraDrawStage: Stage<CameraStageAction>;
  33828. /**
  33829. * @hidden
  33830. * Defines the actions happening just after a render target has been drawn.
  33831. */
  33832. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33833. /**
  33834. * @hidden
  33835. * Defines the actions happening just after rendering all cameras and computing intersections.
  33836. */
  33837. _afterRenderStage: Stage<SimpleStageAction>;
  33838. /**
  33839. * @hidden
  33840. * Defines the actions happening when a pointer move event happens.
  33841. */
  33842. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33843. /**
  33844. * @hidden
  33845. * Defines the actions happening when a pointer down event happens.
  33846. */
  33847. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33848. /**
  33849. * @hidden
  33850. * Defines the actions happening when a pointer up event happens.
  33851. */
  33852. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33853. /**
  33854. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33855. */
  33856. private geometriesByUniqueId;
  33857. /**
  33858. * Creates a new Scene
  33859. * @param engine defines the engine to use to render this scene
  33860. * @param options defines the scene options
  33861. */
  33862. constructor(engine: Engine, options?: SceneOptions);
  33863. /**
  33864. * Gets a string idenfifying the name of the class
  33865. * @returns "Scene" string
  33866. */
  33867. getClassName(): string;
  33868. private _defaultMeshCandidates;
  33869. /**
  33870. * @hidden
  33871. */
  33872. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33873. private _defaultSubMeshCandidates;
  33874. /**
  33875. * @hidden
  33876. */
  33877. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33878. /**
  33879. * Sets the default candidate providers for the scene.
  33880. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33881. * and getCollidingSubMeshCandidates to their default function
  33882. */
  33883. setDefaultCandidateProviders(): void;
  33884. /**
  33885. * Gets the mesh that is currently under the pointer
  33886. */
  33887. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33888. /**
  33889. * Gets or sets the current on-screen X position of the pointer
  33890. */
  33891. pointerX: number;
  33892. /**
  33893. * Gets or sets the current on-screen Y position of the pointer
  33894. */
  33895. pointerY: number;
  33896. /**
  33897. * Gets the cached material (ie. the latest rendered one)
  33898. * @returns the cached material
  33899. */
  33900. getCachedMaterial(): Nullable<Material>;
  33901. /**
  33902. * Gets the cached effect (ie. the latest rendered one)
  33903. * @returns the cached effect
  33904. */
  33905. getCachedEffect(): Nullable<Effect>;
  33906. /**
  33907. * Gets the cached visibility state (ie. the latest rendered one)
  33908. * @returns the cached visibility state
  33909. */
  33910. getCachedVisibility(): Nullable<number>;
  33911. /**
  33912. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33913. * @param material defines the current material
  33914. * @param effect defines the current effect
  33915. * @param visibility defines the current visibility state
  33916. * @returns true if one parameter is not cached
  33917. */
  33918. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33919. /**
  33920. * Gets the engine associated with the scene
  33921. * @returns an Engine
  33922. */
  33923. getEngine(): Engine;
  33924. /**
  33925. * Gets the total number of vertices rendered per frame
  33926. * @returns the total number of vertices rendered per frame
  33927. */
  33928. getTotalVertices(): number;
  33929. /**
  33930. * Gets the performance counter for total vertices
  33931. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33932. */
  33933. readonly totalVerticesPerfCounter: PerfCounter;
  33934. /**
  33935. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33936. * @returns the total number of active indices rendered per frame
  33937. */
  33938. getActiveIndices(): number;
  33939. /**
  33940. * Gets the performance counter for active indices
  33941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33942. */
  33943. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33944. /**
  33945. * Gets the total number of active particles rendered per frame
  33946. * @returns the total number of active particles rendered per frame
  33947. */
  33948. getActiveParticles(): number;
  33949. /**
  33950. * Gets the performance counter for active particles
  33951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33952. */
  33953. readonly activeParticlesPerfCounter: PerfCounter;
  33954. /**
  33955. * Gets the total number of active bones rendered per frame
  33956. * @returns the total number of active bones rendered per frame
  33957. */
  33958. getActiveBones(): number;
  33959. /**
  33960. * Gets the performance counter for active bones
  33961. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33962. */
  33963. readonly activeBonesPerfCounter: PerfCounter;
  33964. /**
  33965. * Gets the array of active meshes
  33966. * @returns an array of AbstractMesh
  33967. */
  33968. getActiveMeshes(): SmartArray<AbstractMesh>;
  33969. /**
  33970. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33971. * @returns a number
  33972. */
  33973. getAnimationRatio(): number;
  33974. /**
  33975. * Gets an unique Id for the current render phase
  33976. * @returns a number
  33977. */
  33978. getRenderId(): number;
  33979. /**
  33980. * Gets an unique Id for the current frame
  33981. * @returns a number
  33982. */
  33983. getFrameId(): number;
  33984. /** Call this function if you want to manually increment the render Id*/
  33985. incrementRenderId(): void;
  33986. private _createUbo;
  33987. /**
  33988. * Use this method to simulate a pointer move on a mesh
  33989. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33990. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33991. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33992. * @returns the current scene
  33993. */
  33994. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33995. /**
  33996. * Use this method to simulate a pointer down on a mesh
  33997. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33998. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33999. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34000. * @returns the current scene
  34001. */
  34002. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34003. /**
  34004. * Use this method to simulate a pointer up on a mesh
  34005. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34006. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34007. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34008. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34009. * @returns the current scene
  34010. */
  34011. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34012. /**
  34013. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34014. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34015. * @returns true if the pointer was captured
  34016. */
  34017. isPointerCaptured(pointerId?: number): boolean;
  34018. /**
  34019. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34020. * @param attachUp defines if you want to attach events to pointerup
  34021. * @param attachDown defines if you want to attach events to pointerdown
  34022. * @param attachMove defines if you want to attach events to pointermove
  34023. */
  34024. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34025. /** Detaches all event handlers*/
  34026. detachControl(): void;
  34027. /**
  34028. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34029. * Delay loaded resources are not taking in account
  34030. * @return true if all required resources are ready
  34031. */
  34032. isReady(): boolean;
  34033. /** Resets all cached information relative to material (including effect and visibility) */
  34034. resetCachedMaterial(): void;
  34035. /**
  34036. * Registers a function to be called before every frame render
  34037. * @param func defines the function to register
  34038. */
  34039. registerBeforeRender(func: () => void): void;
  34040. /**
  34041. * Unregisters a function called before every frame render
  34042. * @param func defines the function to unregister
  34043. */
  34044. unregisterBeforeRender(func: () => void): void;
  34045. /**
  34046. * Registers a function to be called after every frame render
  34047. * @param func defines the function to register
  34048. */
  34049. registerAfterRender(func: () => void): void;
  34050. /**
  34051. * Unregisters a function called after every frame render
  34052. * @param func defines the function to unregister
  34053. */
  34054. unregisterAfterRender(func: () => void): void;
  34055. private _executeOnceBeforeRender;
  34056. /**
  34057. * The provided function will run before render once and will be disposed afterwards.
  34058. * A timeout delay can be provided so that the function will be executed in N ms.
  34059. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34060. * @param func The function to be executed.
  34061. * @param timeout optional delay in ms
  34062. */
  34063. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34064. /** @hidden */
  34065. _addPendingData(data: any): void;
  34066. /** @hidden */
  34067. _removePendingData(data: any): void;
  34068. /**
  34069. * Returns the number of items waiting to be loaded
  34070. * @returns the number of items waiting to be loaded
  34071. */
  34072. getWaitingItemsCount(): number;
  34073. /**
  34074. * Returns a boolean indicating if the scene is still loading data
  34075. */
  34076. readonly isLoading: boolean;
  34077. /**
  34078. * Registers a function to be executed when the scene is ready
  34079. * @param {Function} func - the function to be executed
  34080. */
  34081. executeWhenReady(func: () => void): void;
  34082. /**
  34083. * Returns a promise that resolves when the scene is ready
  34084. * @returns A promise that resolves when the scene is ready
  34085. */
  34086. whenReadyAsync(): Promise<void>;
  34087. /** @hidden */
  34088. _checkIsReady(): void;
  34089. /**
  34090. * Gets all animatable attached to the scene
  34091. */
  34092. readonly animatables: Animatable[];
  34093. /**
  34094. * Resets the last animation time frame.
  34095. * Useful to override when animations start running when loading a scene for the first time.
  34096. */
  34097. resetLastAnimationTimeFrame(): void;
  34098. /**
  34099. * Gets the current view matrix
  34100. * @returns a Matrix
  34101. */
  34102. getViewMatrix(): Matrix;
  34103. /**
  34104. * Gets the current projection matrix
  34105. * @returns a Matrix
  34106. */
  34107. getProjectionMatrix(): Matrix;
  34108. /**
  34109. * Gets the current transform matrix
  34110. * @returns a Matrix made of View * Projection
  34111. */
  34112. getTransformMatrix(): Matrix;
  34113. /**
  34114. * Sets the current transform matrix
  34115. * @param viewL defines the View matrix to use
  34116. * @param projectionL defines the Projection matrix to use
  34117. * @param viewR defines the right View matrix to use (if provided)
  34118. * @param projectionR defines the right Projection matrix to use (if provided)
  34119. */
  34120. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34121. /**
  34122. * Gets the uniform buffer used to store scene data
  34123. * @returns a UniformBuffer
  34124. */
  34125. getSceneUniformBuffer(): UniformBuffer;
  34126. /**
  34127. * Gets an unique (relatively to the current scene) Id
  34128. * @returns an unique number for the scene
  34129. */
  34130. getUniqueId(): number;
  34131. /**
  34132. * Add a mesh to the list of scene's meshes
  34133. * @param newMesh defines the mesh to add
  34134. * @param recursive if all child meshes should also be added to the scene
  34135. */
  34136. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34137. /**
  34138. * Remove a mesh for the list of scene's meshes
  34139. * @param toRemove defines the mesh to remove
  34140. * @param recursive if all child meshes should also be removed from the scene
  34141. * @returns the index where the mesh was in the mesh list
  34142. */
  34143. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34144. /**
  34145. * Add a transform node to the list of scene's transform nodes
  34146. * @param newTransformNode defines the transform node to add
  34147. */
  34148. addTransformNode(newTransformNode: TransformNode): void;
  34149. /**
  34150. * Remove a transform node for the list of scene's transform nodes
  34151. * @param toRemove defines the transform node to remove
  34152. * @returns the index where the transform node was in the transform node list
  34153. */
  34154. removeTransformNode(toRemove: TransformNode): number;
  34155. /**
  34156. * Remove a skeleton for the list of scene's skeletons
  34157. * @param toRemove defines the skeleton to remove
  34158. * @returns the index where the skeleton was in the skeleton list
  34159. */
  34160. removeSkeleton(toRemove: Skeleton): number;
  34161. /**
  34162. * Remove a morph target for the list of scene's morph targets
  34163. * @param toRemove defines the morph target to remove
  34164. * @returns the index where the morph target was in the morph target list
  34165. */
  34166. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34167. /**
  34168. * Remove a light for the list of scene's lights
  34169. * @param toRemove defines the light to remove
  34170. * @returns the index where the light was in the light list
  34171. */
  34172. removeLight(toRemove: Light): number;
  34173. /**
  34174. * Remove a camera for the list of scene's cameras
  34175. * @param toRemove defines the camera to remove
  34176. * @returns the index where the camera was in the camera list
  34177. */
  34178. removeCamera(toRemove: Camera): number;
  34179. /**
  34180. * Remove a particle system for the list of scene's particle systems
  34181. * @param toRemove defines the particle system to remove
  34182. * @returns the index where the particle system was in the particle system list
  34183. */
  34184. removeParticleSystem(toRemove: IParticleSystem): number;
  34185. /**
  34186. * Remove a animation for the list of scene's animations
  34187. * @param toRemove defines the animation to remove
  34188. * @returns the index where the animation was in the animation list
  34189. */
  34190. removeAnimation(toRemove: Animation): number;
  34191. /**
  34192. * Will stop the animation of the given target
  34193. * @param target - the target
  34194. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34195. * @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)
  34196. */
  34197. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34198. /**
  34199. * Removes the given animation group from this scene.
  34200. * @param toRemove The animation group to remove
  34201. * @returns The index of the removed animation group
  34202. */
  34203. removeAnimationGroup(toRemove: AnimationGroup): number;
  34204. /**
  34205. * Removes the given multi-material from this scene.
  34206. * @param toRemove The multi-material to remove
  34207. * @returns The index of the removed multi-material
  34208. */
  34209. removeMultiMaterial(toRemove: MultiMaterial): number;
  34210. /**
  34211. * Removes the given material from this scene.
  34212. * @param toRemove The material to remove
  34213. * @returns The index of the removed material
  34214. */
  34215. removeMaterial(toRemove: Material): number;
  34216. /**
  34217. * Removes the given action manager from this scene.
  34218. * @param toRemove The action manager to remove
  34219. * @returns The index of the removed action manager
  34220. */
  34221. removeActionManager(toRemove: AbstractActionManager): number;
  34222. /**
  34223. * Removes the given texture from this scene.
  34224. * @param toRemove The texture to remove
  34225. * @returns The index of the removed texture
  34226. */
  34227. removeTexture(toRemove: BaseTexture): number;
  34228. /**
  34229. * Adds the given light to this scene
  34230. * @param newLight The light to add
  34231. */
  34232. addLight(newLight: Light): void;
  34233. /**
  34234. * Sorts the list list based on light priorities
  34235. */
  34236. sortLightsByPriority(): void;
  34237. /**
  34238. * Adds the given camera to this scene
  34239. * @param newCamera The camera to add
  34240. */
  34241. addCamera(newCamera: Camera): void;
  34242. /**
  34243. * Adds the given skeleton to this scene
  34244. * @param newSkeleton The skeleton to add
  34245. */
  34246. addSkeleton(newSkeleton: Skeleton): void;
  34247. /**
  34248. * Adds the given particle system to this scene
  34249. * @param newParticleSystem The particle system to add
  34250. */
  34251. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34252. /**
  34253. * Adds the given animation to this scene
  34254. * @param newAnimation The animation to add
  34255. */
  34256. addAnimation(newAnimation: Animation): void;
  34257. /**
  34258. * Adds the given animation group to this scene.
  34259. * @param newAnimationGroup The animation group to add
  34260. */
  34261. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34262. /**
  34263. * Adds the given multi-material to this scene
  34264. * @param newMultiMaterial The multi-material to add
  34265. */
  34266. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34267. /**
  34268. * Adds the given material to this scene
  34269. * @param newMaterial The material to add
  34270. */
  34271. addMaterial(newMaterial: Material): void;
  34272. /**
  34273. * Adds the given morph target to this scene
  34274. * @param newMorphTargetManager The morph target to add
  34275. */
  34276. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34277. /**
  34278. * Adds the given geometry to this scene
  34279. * @param newGeometry The geometry to add
  34280. */
  34281. addGeometry(newGeometry: Geometry): void;
  34282. /**
  34283. * Adds the given action manager to this scene
  34284. * @param newActionManager The action manager to add
  34285. */
  34286. addActionManager(newActionManager: AbstractActionManager): void;
  34287. /**
  34288. * Adds the given texture to this scene.
  34289. * @param newTexture The texture to add
  34290. */
  34291. addTexture(newTexture: BaseTexture): void;
  34292. /**
  34293. * Switch active camera
  34294. * @param newCamera defines the new active camera
  34295. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34296. */
  34297. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34298. /**
  34299. * sets the active camera of the scene using its ID
  34300. * @param id defines the camera's ID
  34301. * @return the new active camera or null if none found.
  34302. */
  34303. setActiveCameraByID(id: string): Nullable<Camera>;
  34304. /**
  34305. * sets the active camera of the scene using its name
  34306. * @param name defines the camera's name
  34307. * @returns the new active camera or null if none found.
  34308. */
  34309. setActiveCameraByName(name: string): Nullable<Camera>;
  34310. /**
  34311. * get an animation group using its name
  34312. * @param name defines the material's name
  34313. * @return the animation group or null if none found.
  34314. */
  34315. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34316. /**
  34317. * Get a material using its unique id
  34318. * @param uniqueId defines the material's unique id
  34319. * @return the material or null if none found.
  34320. */
  34321. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34322. /**
  34323. * get a material using its id
  34324. * @param id defines the material's ID
  34325. * @return the material or null if none found.
  34326. */
  34327. getMaterialByID(id: string): Nullable<Material>;
  34328. /**
  34329. * Gets a material using its name
  34330. * @param name defines the material's name
  34331. * @return the material or null if none found.
  34332. */
  34333. getMaterialByName(name: string): Nullable<Material>;
  34334. /**
  34335. * Gets a camera using its id
  34336. * @param id defines the id to look for
  34337. * @returns the camera or null if not found
  34338. */
  34339. getCameraByID(id: string): Nullable<Camera>;
  34340. /**
  34341. * Gets a camera using its unique id
  34342. * @param uniqueId defines the unique id to look for
  34343. * @returns the camera or null if not found
  34344. */
  34345. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34346. /**
  34347. * Gets a camera using its name
  34348. * @param name defines the camera's name
  34349. * @return the camera or null if none found.
  34350. */
  34351. getCameraByName(name: string): Nullable<Camera>;
  34352. /**
  34353. * Gets a bone using its id
  34354. * @param id defines the bone's id
  34355. * @return the bone or null if not found
  34356. */
  34357. getBoneByID(id: string): Nullable<Bone>;
  34358. /**
  34359. * Gets a bone using its id
  34360. * @param name defines the bone's name
  34361. * @return the bone or null if not found
  34362. */
  34363. getBoneByName(name: string): Nullable<Bone>;
  34364. /**
  34365. * Gets a light node using its name
  34366. * @param name defines the the light's name
  34367. * @return the light or null if none found.
  34368. */
  34369. getLightByName(name: string): Nullable<Light>;
  34370. /**
  34371. * Gets a light node using its id
  34372. * @param id defines the light's id
  34373. * @return the light or null if none found.
  34374. */
  34375. getLightByID(id: string): Nullable<Light>;
  34376. /**
  34377. * Gets a light node using its scene-generated unique ID
  34378. * @param uniqueId defines the light's unique id
  34379. * @return the light or null if none found.
  34380. */
  34381. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34382. /**
  34383. * Gets a particle system by id
  34384. * @param id defines the particle system id
  34385. * @return the corresponding system or null if none found
  34386. */
  34387. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34388. /**
  34389. * Gets a geometry using its ID
  34390. * @param id defines the geometry's id
  34391. * @return the geometry or null if none found.
  34392. */
  34393. getGeometryByID(id: string): Nullable<Geometry>;
  34394. private _getGeometryByUniqueID;
  34395. /**
  34396. * Add a new geometry to this scene
  34397. * @param geometry defines the geometry to be added to the scene.
  34398. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34399. * @return a boolean defining if the geometry was added or not
  34400. */
  34401. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34402. /**
  34403. * Removes an existing geometry
  34404. * @param geometry defines the geometry to be removed from the scene
  34405. * @return a boolean defining if the geometry was removed or not
  34406. */
  34407. removeGeometry(geometry: Geometry): boolean;
  34408. /**
  34409. * Gets the list of geometries attached to the scene
  34410. * @returns an array of Geometry
  34411. */
  34412. getGeometries(): Geometry[];
  34413. /**
  34414. * Gets the first added mesh found of a given ID
  34415. * @param id defines the id to search for
  34416. * @return the mesh found or null if not found at all
  34417. */
  34418. getMeshByID(id: string): Nullable<AbstractMesh>;
  34419. /**
  34420. * Gets a list of meshes using their id
  34421. * @param id defines the id to search for
  34422. * @returns a list of meshes
  34423. */
  34424. getMeshesByID(id: string): Array<AbstractMesh>;
  34425. /**
  34426. * Gets the first added transform node found of a given ID
  34427. * @param id defines the id to search for
  34428. * @return the found transform node or null if not found at all.
  34429. */
  34430. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34431. /**
  34432. * Gets a transform node with its auto-generated unique id
  34433. * @param uniqueId efines the unique id to search for
  34434. * @return the found transform node or null if not found at all.
  34435. */
  34436. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34437. /**
  34438. * Gets a list of transform nodes using their id
  34439. * @param id defines the id to search for
  34440. * @returns a list of transform nodes
  34441. */
  34442. getTransformNodesByID(id: string): Array<TransformNode>;
  34443. /**
  34444. * Gets a mesh with its auto-generated unique id
  34445. * @param uniqueId defines the unique id to search for
  34446. * @return the found mesh or null if not found at all.
  34447. */
  34448. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34449. /**
  34450. * Gets a the last added mesh using a given id
  34451. * @param id defines the id to search for
  34452. * @return the found mesh or null if not found at all.
  34453. */
  34454. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34455. /**
  34456. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34457. * @param id defines the id to search for
  34458. * @return the found node or null if not found at all
  34459. */
  34460. getLastEntryByID(id: string): Nullable<Node>;
  34461. /**
  34462. * Gets a node (Mesh, Camera, Light) using a given id
  34463. * @param id defines the id to search for
  34464. * @return the found node or null if not found at all
  34465. */
  34466. getNodeByID(id: string): Nullable<Node>;
  34467. /**
  34468. * Gets a node (Mesh, Camera, Light) using a given name
  34469. * @param name defines the name to search for
  34470. * @return the found node or null if not found at all.
  34471. */
  34472. getNodeByName(name: string): Nullable<Node>;
  34473. /**
  34474. * Gets a mesh using a given name
  34475. * @param name defines the name to search for
  34476. * @return the found mesh or null if not found at all.
  34477. */
  34478. getMeshByName(name: string): Nullable<AbstractMesh>;
  34479. /**
  34480. * Gets a transform node using a given name
  34481. * @param name defines the name to search for
  34482. * @return the found transform node or null if not found at all.
  34483. */
  34484. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34485. /**
  34486. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34487. * @param id defines the id to search for
  34488. * @return the found skeleton or null if not found at all.
  34489. */
  34490. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34491. /**
  34492. * Gets a skeleton using a given auto generated unique id
  34493. * @param uniqueId defines the unique id to search for
  34494. * @return the found skeleton or null if not found at all.
  34495. */
  34496. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34497. /**
  34498. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34499. * @param id defines the id to search for
  34500. * @return the found skeleton or null if not found at all.
  34501. */
  34502. getSkeletonById(id: string): Nullable<Skeleton>;
  34503. /**
  34504. * Gets a skeleton using a given name
  34505. * @param name defines the name to search for
  34506. * @return the found skeleton or null if not found at all.
  34507. */
  34508. getSkeletonByName(name: string): Nullable<Skeleton>;
  34509. /**
  34510. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34511. * @param id defines the id to search for
  34512. * @return the found morph target manager or null if not found at all.
  34513. */
  34514. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34515. /**
  34516. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34517. * @param id defines the id to search for
  34518. * @return the found morph target or null if not found at all.
  34519. */
  34520. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34521. /**
  34522. * Gets a boolean indicating if the given mesh is active
  34523. * @param mesh defines the mesh to look for
  34524. * @returns true if the mesh is in the active list
  34525. */
  34526. isActiveMesh(mesh: AbstractMesh): boolean;
  34527. /**
  34528. * Return a unique id as a string which can serve as an identifier for the scene
  34529. */
  34530. readonly uid: string;
  34531. /**
  34532. * Add an externaly attached data from its key.
  34533. * This method call will fail and return false, if such key already exists.
  34534. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34535. * @param key the unique key that identifies the data
  34536. * @param data the data object to associate to the key for this Engine instance
  34537. * @return true if no such key were already present and the data was added successfully, false otherwise
  34538. */
  34539. addExternalData<T>(key: string, data: T): boolean;
  34540. /**
  34541. * Get an externaly attached data from its key
  34542. * @param key the unique key that identifies the data
  34543. * @return the associated data, if present (can be null), or undefined if not present
  34544. */
  34545. getExternalData<T>(key: string): Nullable<T>;
  34546. /**
  34547. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34548. * @param key the unique key that identifies the data
  34549. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34550. * @return the associated data, can be null if the factory returned null.
  34551. */
  34552. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34553. /**
  34554. * Remove an externaly attached data from the Engine instance
  34555. * @param key the unique key that identifies the data
  34556. * @return true if the data was successfully removed, false if it doesn't exist
  34557. */
  34558. removeExternalData(key: string): boolean;
  34559. private _evaluateSubMesh;
  34560. /**
  34561. * Clear the processed materials smart array preventing retention point in material dispose.
  34562. */
  34563. freeProcessedMaterials(): void;
  34564. private _preventFreeActiveMeshesAndRenderingGroups;
  34565. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34566. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34567. * when disposing several meshes in a row or a hierarchy of meshes.
  34568. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34569. */
  34570. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34571. /**
  34572. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34573. */
  34574. freeActiveMeshes(): void;
  34575. /**
  34576. * Clear the info related to rendering groups preventing retention points during dispose.
  34577. */
  34578. freeRenderingGroups(): void;
  34579. /** @hidden */
  34580. _isInIntermediateRendering(): boolean;
  34581. /**
  34582. * Lambda returning the list of potentially active meshes.
  34583. */
  34584. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34585. /**
  34586. * Lambda returning the list of potentially active sub meshes.
  34587. */
  34588. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34589. /**
  34590. * Lambda returning the list of potentially intersecting sub meshes.
  34591. */
  34592. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34593. /**
  34594. * Lambda returning the list of potentially colliding sub meshes.
  34595. */
  34596. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34597. private _activeMeshesFrozen;
  34598. /**
  34599. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34600. * @returns the current scene
  34601. */
  34602. freezeActiveMeshes(): Scene;
  34603. /**
  34604. * Use this function to restart evaluating active meshes on every frame
  34605. * @returns the current scene
  34606. */
  34607. unfreezeActiveMeshes(): Scene;
  34608. private _evaluateActiveMeshes;
  34609. private _activeMesh;
  34610. /**
  34611. * Update the transform matrix to update from the current active camera
  34612. * @param force defines a boolean used to force the update even if cache is up to date
  34613. */
  34614. updateTransformMatrix(force?: boolean): void;
  34615. private _bindFrameBuffer;
  34616. /** @hidden */
  34617. _allowPostProcessClearColor: boolean;
  34618. /** @hidden */
  34619. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34620. private _processSubCameras;
  34621. private _checkIntersections;
  34622. /** @hidden */
  34623. _advancePhysicsEngineStep(step: number): void;
  34624. /**
  34625. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34626. */
  34627. getDeterministicFrameTime: () => number;
  34628. /** @hidden */
  34629. _animate(): void;
  34630. /** Execute all animations (for a frame) */
  34631. animate(): void;
  34632. /**
  34633. * Render the scene
  34634. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34635. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34636. */
  34637. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34638. /**
  34639. * Freeze all materials
  34640. * A frozen material will not be updatable but should be faster to render
  34641. */
  34642. freezeMaterials(): void;
  34643. /**
  34644. * Unfreeze all materials
  34645. * A frozen material will not be updatable but should be faster to render
  34646. */
  34647. unfreezeMaterials(): void;
  34648. /**
  34649. * Releases all held ressources
  34650. */
  34651. dispose(): void;
  34652. /**
  34653. * Gets if the scene is already disposed
  34654. */
  34655. readonly isDisposed: boolean;
  34656. /**
  34657. * Call this function to reduce memory footprint of the scene.
  34658. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34659. */
  34660. clearCachedVertexData(): void;
  34661. /**
  34662. * This function will remove the local cached buffer data from texture.
  34663. * It will save memory but will prevent the texture from being rebuilt
  34664. */
  34665. cleanCachedTextureBuffer(): void;
  34666. /**
  34667. * Get the world extend vectors with an optional filter
  34668. *
  34669. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34670. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34671. */
  34672. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34673. min: Vector3;
  34674. max: Vector3;
  34675. };
  34676. /**
  34677. * Creates a ray that can be used to pick in the scene
  34678. * @param x defines the x coordinate of the origin (on-screen)
  34679. * @param y defines the y coordinate of the origin (on-screen)
  34680. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34681. * @param camera defines the camera to use for the picking
  34682. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34683. * @returns a Ray
  34684. */
  34685. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34686. /**
  34687. * Creates a ray that can be used to pick in the scene
  34688. * @param x defines the x coordinate of the origin (on-screen)
  34689. * @param y defines the y coordinate of the origin (on-screen)
  34690. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34691. * @param result defines the ray where to store the picking ray
  34692. * @param camera defines the camera to use for the picking
  34693. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34694. * @returns the current scene
  34695. */
  34696. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34697. /**
  34698. * Creates a ray that can be used to pick in the scene
  34699. * @param x defines the x coordinate of the origin (on-screen)
  34700. * @param y defines the y coordinate of the origin (on-screen)
  34701. * @param camera defines the camera to use for the picking
  34702. * @returns a Ray
  34703. */
  34704. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34705. /**
  34706. * Creates a ray that can be used to pick in the scene
  34707. * @param x defines the x coordinate of the origin (on-screen)
  34708. * @param y defines the y coordinate of the origin (on-screen)
  34709. * @param result defines the ray where to store the picking ray
  34710. * @param camera defines the camera to use for the picking
  34711. * @returns the current scene
  34712. */
  34713. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34714. /** Launch a ray to try to pick a mesh in the scene
  34715. * @param x position on screen
  34716. * @param y position on screen
  34717. * @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
  34718. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34719. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34720. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34721. * @returns a PickingInfo
  34722. */
  34723. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34724. /** Use the given ray to pick a mesh in the scene
  34725. * @param ray The ray to use to pick meshes
  34726. * @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
  34727. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34728. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34729. * @returns a PickingInfo
  34730. */
  34731. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34732. /**
  34733. * Launch a ray to try to pick a mesh in the scene
  34734. * @param x X position on screen
  34735. * @param y Y position on screen
  34736. * @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
  34737. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34738. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34739. * @returns an array of PickingInfo
  34740. */
  34741. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34742. /**
  34743. * Launch a ray to try to pick a mesh in the scene
  34744. * @param ray Ray to use
  34745. * @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
  34746. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34747. * @returns an array of PickingInfo
  34748. */
  34749. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34750. /**
  34751. * Force the value of meshUnderPointer
  34752. * @param mesh defines the mesh to use
  34753. */
  34754. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34755. /**
  34756. * Gets the mesh under the pointer
  34757. * @returns a Mesh or null if no mesh is under the pointer
  34758. */
  34759. getPointerOverMesh(): Nullable<AbstractMesh>;
  34760. /** @hidden */
  34761. _rebuildGeometries(): void;
  34762. /** @hidden */
  34763. _rebuildTextures(): void;
  34764. private _getByTags;
  34765. /**
  34766. * Get a list of meshes by tags
  34767. * @param tagsQuery defines the tags query to use
  34768. * @param forEach defines a predicate used to filter results
  34769. * @returns an array of Mesh
  34770. */
  34771. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34772. /**
  34773. * Get a list of cameras by tags
  34774. * @param tagsQuery defines the tags query to use
  34775. * @param forEach defines a predicate used to filter results
  34776. * @returns an array of Camera
  34777. */
  34778. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34779. /**
  34780. * Get a list of lights by tags
  34781. * @param tagsQuery defines the tags query to use
  34782. * @param forEach defines a predicate used to filter results
  34783. * @returns an array of Light
  34784. */
  34785. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34786. /**
  34787. * Get a list of materials by tags
  34788. * @param tagsQuery defines the tags query to use
  34789. * @param forEach defines a predicate used to filter results
  34790. * @returns an array of Material
  34791. */
  34792. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34793. /**
  34794. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34795. * This allowed control for front to back rendering or reversly depending of the special needs.
  34796. *
  34797. * @param renderingGroupId The rendering group id corresponding to its index
  34798. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34799. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34800. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34801. */
  34802. 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;
  34803. /**
  34804. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34805. *
  34806. * @param renderingGroupId The rendering group id corresponding to its index
  34807. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34808. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34809. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34810. */
  34811. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34812. /**
  34813. * Gets the current auto clear configuration for one rendering group of the rendering
  34814. * manager.
  34815. * @param index the rendering group index to get the information for
  34816. * @returns The auto clear setup for the requested rendering group
  34817. */
  34818. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34819. private _blockMaterialDirtyMechanism;
  34820. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34821. blockMaterialDirtyMechanism: boolean;
  34822. /**
  34823. * Will flag all materials as dirty to trigger new shader compilation
  34824. * @param flag defines the flag used to specify which material part must be marked as dirty
  34825. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34826. */
  34827. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34828. /** @hidden */
  34829. _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;
  34830. /** @hidden */
  34831. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34832. }
  34833. }
  34834. declare module "babylonjs/assetContainer" {
  34835. import { AbstractScene } from "babylonjs/abstractScene";
  34836. import { Scene } from "babylonjs/scene";
  34837. import { Mesh } from "babylonjs/Meshes/mesh";
  34838. /**
  34839. * Set of assets to keep when moving a scene into an asset container.
  34840. */
  34841. export class KeepAssets extends AbstractScene {
  34842. }
  34843. /**
  34844. * Container with a set of assets that can be added or removed from a scene.
  34845. */
  34846. export class AssetContainer extends AbstractScene {
  34847. /**
  34848. * The scene the AssetContainer belongs to.
  34849. */
  34850. scene: Scene;
  34851. /**
  34852. * Instantiates an AssetContainer.
  34853. * @param scene The scene the AssetContainer belongs to.
  34854. */
  34855. constructor(scene: Scene);
  34856. /**
  34857. * Adds all the assets from the container to the scene.
  34858. */
  34859. addAllToScene(): void;
  34860. /**
  34861. * Removes all the assets in the container from the scene
  34862. */
  34863. removeAllFromScene(): void;
  34864. /**
  34865. * Disposes all the assets in the container
  34866. */
  34867. dispose(): void;
  34868. private _moveAssets;
  34869. /**
  34870. * Removes all the assets contained in the scene and adds them to the container.
  34871. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34872. */
  34873. moveAllFromScene(keepAssets?: KeepAssets): void;
  34874. /**
  34875. * 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.
  34876. * @returns the root mesh
  34877. */
  34878. createRootMesh(): Mesh;
  34879. }
  34880. }
  34881. declare module "babylonjs/abstractScene" {
  34882. import { Scene } from "babylonjs/scene";
  34883. import { Nullable } from "babylonjs/types";
  34884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34885. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34886. import { Geometry } from "babylonjs/Meshes/geometry";
  34887. import { Skeleton } from "babylonjs/Bones/skeleton";
  34888. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34889. import { AssetContainer } from "babylonjs/assetContainer";
  34890. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34891. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34893. import { Material } from "babylonjs/Materials/material";
  34894. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34895. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34896. import { Camera } from "babylonjs/Cameras/camera";
  34897. import { Light } from "babylonjs/Lights/light";
  34898. import { Node } from "babylonjs/node";
  34899. import { Animation } from "babylonjs/Animations/animation";
  34900. /**
  34901. * Defines how the parser contract is defined.
  34902. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34903. */
  34904. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34905. /**
  34906. * Defines how the individual parser contract is defined.
  34907. * These parser can parse an individual asset
  34908. */
  34909. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34910. /**
  34911. * Base class of the scene acting as a container for the different elements composing a scene.
  34912. * This class is dynamically extended by the different components of the scene increasing
  34913. * flexibility and reducing coupling
  34914. */
  34915. export abstract class AbstractScene {
  34916. /**
  34917. * Stores the list of available parsers in the application.
  34918. */
  34919. private static _BabylonFileParsers;
  34920. /**
  34921. * Stores the list of available individual parsers in the application.
  34922. */
  34923. private static _IndividualBabylonFileParsers;
  34924. /**
  34925. * Adds a parser in the list of available ones
  34926. * @param name Defines the name of the parser
  34927. * @param parser Defines the parser to add
  34928. */
  34929. static AddParser(name: string, parser: BabylonFileParser): void;
  34930. /**
  34931. * Gets a general parser from the list of avaialble ones
  34932. * @param name Defines the name of the parser
  34933. * @returns the requested parser or null
  34934. */
  34935. static GetParser(name: string): Nullable<BabylonFileParser>;
  34936. /**
  34937. * Adds n individual parser in the list of available ones
  34938. * @param name Defines the name of the parser
  34939. * @param parser Defines the parser to add
  34940. */
  34941. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34942. /**
  34943. * Gets an individual parser from the list of avaialble ones
  34944. * @param name Defines the name of the parser
  34945. * @returns the requested parser or null
  34946. */
  34947. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34948. /**
  34949. * Parser json data and populate both a scene and its associated container object
  34950. * @param jsonData Defines the data to parse
  34951. * @param scene Defines the scene to parse the data for
  34952. * @param container Defines the container attached to the parsing sequence
  34953. * @param rootUrl Defines the root url of the data
  34954. */
  34955. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34956. /**
  34957. * Gets the list of root nodes (ie. nodes with no parent)
  34958. */
  34959. rootNodes: Node[];
  34960. /** All of the cameras added to this scene
  34961. * @see http://doc.babylonjs.com/babylon101/cameras
  34962. */
  34963. cameras: Camera[];
  34964. /**
  34965. * All of the lights added to this scene
  34966. * @see http://doc.babylonjs.com/babylon101/lights
  34967. */
  34968. lights: Light[];
  34969. /**
  34970. * All of the (abstract) meshes added to this scene
  34971. */
  34972. meshes: AbstractMesh[];
  34973. /**
  34974. * The list of skeletons added to the scene
  34975. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34976. */
  34977. skeletons: Skeleton[];
  34978. /**
  34979. * All of the particle systems added to this scene
  34980. * @see http://doc.babylonjs.com/babylon101/particles
  34981. */
  34982. particleSystems: IParticleSystem[];
  34983. /**
  34984. * Gets a list of Animations associated with the scene
  34985. */
  34986. animations: Animation[];
  34987. /**
  34988. * All of the animation groups added to this scene
  34989. * @see http://doc.babylonjs.com/how_to/group
  34990. */
  34991. animationGroups: AnimationGroup[];
  34992. /**
  34993. * All of the multi-materials added to this scene
  34994. * @see http://doc.babylonjs.com/how_to/multi_materials
  34995. */
  34996. multiMaterials: MultiMaterial[];
  34997. /**
  34998. * All of the materials added to this scene
  34999. * In the context of a Scene, it is not supposed to be modified manually.
  35000. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35001. * Note also that the order of the Material wihin the array is not significant and might change.
  35002. * @see http://doc.babylonjs.com/babylon101/materials
  35003. */
  35004. materials: Material[];
  35005. /**
  35006. * The list of morph target managers added to the scene
  35007. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35008. */
  35009. morphTargetManagers: MorphTargetManager[];
  35010. /**
  35011. * The list of geometries used in the scene.
  35012. */
  35013. geometries: Geometry[];
  35014. /**
  35015. * All of the tranform nodes added to this scene
  35016. * In the context of a Scene, it is not supposed to be modified manually.
  35017. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35018. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35019. * @see http://doc.babylonjs.com/how_to/transformnode
  35020. */
  35021. transformNodes: TransformNode[];
  35022. /**
  35023. * ActionManagers available on the scene.
  35024. */
  35025. actionManagers: AbstractActionManager[];
  35026. /**
  35027. * Textures to keep.
  35028. */
  35029. textures: BaseTexture[];
  35030. /**
  35031. * Environment texture for the scene
  35032. */
  35033. environmentTexture: Nullable<BaseTexture>;
  35034. }
  35035. }
  35036. declare module "babylonjs/Audio/sound" {
  35037. import { Observable } from "babylonjs/Misc/observable";
  35038. import { Vector3 } from "babylonjs/Maths/math";
  35039. import { Nullable } from "babylonjs/types";
  35040. import { Scene } from "babylonjs/scene";
  35041. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35042. /**
  35043. * Defines a sound that can be played in the application.
  35044. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35046. */
  35047. export class Sound {
  35048. /**
  35049. * The name of the sound in the scene.
  35050. */
  35051. name: string;
  35052. /**
  35053. * Does the sound autoplay once loaded.
  35054. */
  35055. autoplay: boolean;
  35056. /**
  35057. * Does the sound loop after it finishes playing once.
  35058. */
  35059. loop: boolean;
  35060. /**
  35061. * Does the sound use a custom attenuation curve to simulate the falloff
  35062. * happening when the source gets further away from the camera.
  35063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35064. */
  35065. useCustomAttenuation: boolean;
  35066. /**
  35067. * The sound track id this sound belongs to.
  35068. */
  35069. soundTrackId: number;
  35070. /**
  35071. * Is this sound currently played.
  35072. */
  35073. isPlaying: boolean;
  35074. /**
  35075. * Is this sound currently paused.
  35076. */
  35077. isPaused: boolean;
  35078. /**
  35079. * Does this sound enables spatial sound.
  35080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35081. */
  35082. spatialSound: boolean;
  35083. /**
  35084. * Define the reference distance the sound should be heard perfectly.
  35085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35086. */
  35087. refDistance: number;
  35088. /**
  35089. * Define the roll off factor of spatial sounds.
  35090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35091. */
  35092. rolloffFactor: number;
  35093. /**
  35094. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35096. */
  35097. maxDistance: number;
  35098. /**
  35099. * Define the distance attenuation model the sound will follow.
  35100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35101. */
  35102. distanceModel: string;
  35103. /**
  35104. * @hidden
  35105. * Back Compat
  35106. **/
  35107. onended: () => any;
  35108. /**
  35109. * Observable event when the current playing sound finishes.
  35110. */
  35111. onEndedObservable: Observable<Sound>;
  35112. private _panningModel;
  35113. private _playbackRate;
  35114. private _streaming;
  35115. private _startTime;
  35116. private _startOffset;
  35117. private _position;
  35118. /** @hidden */
  35119. _positionInEmitterSpace: boolean;
  35120. private _localDirection;
  35121. private _volume;
  35122. private _isReadyToPlay;
  35123. private _isDirectional;
  35124. private _readyToPlayCallback;
  35125. private _audioBuffer;
  35126. private _soundSource;
  35127. private _streamingSource;
  35128. private _soundPanner;
  35129. private _soundGain;
  35130. private _inputAudioNode;
  35131. private _outputAudioNode;
  35132. private _coneInnerAngle;
  35133. private _coneOuterAngle;
  35134. private _coneOuterGain;
  35135. private _scene;
  35136. private _connectedTransformNode;
  35137. private _customAttenuationFunction;
  35138. private _registerFunc;
  35139. private _isOutputConnected;
  35140. private _htmlAudioElement;
  35141. private _urlType;
  35142. /** @hidden */
  35143. static _SceneComponentInitialization: (scene: Scene) => void;
  35144. /**
  35145. * Create a sound and attach it to a scene
  35146. * @param name Name of your sound
  35147. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35148. * @param scene defines the scene the sound belongs to
  35149. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35150. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35151. */
  35152. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  35153. /**
  35154. * Release the sound and its associated resources
  35155. */
  35156. dispose(): void;
  35157. /**
  35158. * Gets if the sounds is ready to be played or not.
  35159. * @returns true if ready, otherwise false
  35160. */
  35161. isReady(): boolean;
  35162. private _soundLoaded;
  35163. /**
  35164. * Sets the data of the sound from an audiobuffer
  35165. * @param audioBuffer The audioBuffer containing the data
  35166. */
  35167. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35168. /**
  35169. * Updates the current sounds options such as maxdistance, loop...
  35170. * @param options A JSON object containing values named as the object properties
  35171. */
  35172. updateOptions(options: any): void;
  35173. private _createSpatialParameters;
  35174. private _updateSpatialParameters;
  35175. /**
  35176. * Switch the panning model to HRTF:
  35177. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35179. */
  35180. switchPanningModelToHRTF(): void;
  35181. /**
  35182. * Switch the panning model to Equal Power:
  35183. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35185. */
  35186. switchPanningModelToEqualPower(): void;
  35187. private _switchPanningModel;
  35188. /**
  35189. * Connect this sound to a sound track audio node like gain...
  35190. * @param soundTrackAudioNode the sound track audio node to connect to
  35191. */
  35192. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35193. /**
  35194. * Transform this sound into a directional source
  35195. * @param coneInnerAngle Size of the inner cone in degree
  35196. * @param coneOuterAngle Size of the outer cone in degree
  35197. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35198. */
  35199. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35200. /**
  35201. * Gets or sets the inner angle for the directional cone.
  35202. */
  35203. /**
  35204. * Gets or sets the inner angle for the directional cone.
  35205. */
  35206. directionalConeInnerAngle: number;
  35207. /**
  35208. * Gets or sets the outer angle for the directional cone.
  35209. */
  35210. /**
  35211. * Gets or sets the outer angle for the directional cone.
  35212. */
  35213. directionalConeOuterAngle: number;
  35214. /**
  35215. * Sets the position of the emitter if spatial sound is enabled
  35216. * @param newPosition Defines the new posisiton
  35217. */
  35218. setPosition(newPosition: Vector3): void;
  35219. /**
  35220. * Sets the local direction of the emitter if spatial sound is enabled
  35221. * @param newLocalDirection Defines the new local direction
  35222. */
  35223. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35224. private _updateDirection;
  35225. /** @hidden */
  35226. updateDistanceFromListener(): void;
  35227. /**
  35228. * Sets a new custom attenuation function for the sound.
  35229. * @param callback Defines the function used for the attenuation
  35230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35231. */
  35232. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35233. /**
  35234. * Play the sound
  35235. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35236. * @param offset (optional) Start the sound setting it at a specific time
  35237. */
  35238. play(time?: number, offset?: number): void;
  35239. private _onended;
  35240. /**
  35241. * Stop the sound
  35242. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35243. */
  35244. stop(time?: number): void;
  35245. /**
  35246. * Put the sound in pause
  35247. */
  35248. pause(): void;
  35249. /**
  35250. * Sets a dedicated volume for this sounds
  35251. * @param newVolume Define the new volume of the sound
  35252. * @param time Define in how long the sound should be at this value
  35253. */
  35254. setVolume(newVolume: number, time?: number): void;
  35255. /**
  35256. * Set the sound play back rate
  35257. * @param newPlaybackRate Define the playback rate the sound should be played at
  35258. */
  35259. setPlaybackRate(newPlaybackRate: number): void;
  35260. /**
  35261. * Gets the volume of the sound.
  35262. * @returns the volume of the sound
  35263. */
  35264. getVolume(): number;
  35265. /**
  35266. * Attach the sound to a dedicated mesh
  35267. * @param transformNode The transform node to connect the sound with
  35268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35269. */
  35270. attachToMesh(transformNode: TransformNode): void;
  35271. /**
  35272. * Detach the sound from the previously attached mesh
  35273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35274. */
  35275. detachFromMesh(): void;
  35276. private _onRegisterAfterWorldMatrixUpdate;
  35277. /**
  35278. * Clone the current sound in the scene.
  35279. * @returns the new sound clone
  35280. */
  35281. clone(): Nullable<Sound>;
  35282. /**
  35283. * Gets the current underlying audio buffer containing the data
  35284. * @returns the audio buffer
  35285. */
  35286. getAudioBuffer(): Nullable<AudioBuffer>;
  35287. /**
  35288. * Serializes the Sound in a JSON representation
  35289. * @returns the JSON representation of the sound
  35290. */
  35291. serialize(): any;
  35292. /**
  35293. * Parse a JSON representation of a sound to innstantiate in a given scene
  35294. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35295. * @param scene Define the scene the new parsed sound should be created in
  35296. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35297. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35298. * @returns the newly parsed sound
  35299. */
  35300. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35301. }
  35302. }
  35303. declare module "babylonjs/Actions/directAudioActions" {
  35304. import { Action } from "babylonjs/Actions/action";
  35305. import { Condition } from "babylonjs/Actions/condition";
  35306. import { Sound } from "babylonjs/Audio/sound";
  35307. /**
  35308. * This defines an action helpful to play a defined sound on a triggered action.
  35309. */
  35310. export class PlaySoundAction extends Action {
  35311. private _sound;
  35312. /**
  35313. * Instantiate the action
  35314. * @param triggerOptions defines the trigger options
  35315. * @param sound defines the sound to play
  35316. * @param condition defines the trigger related conditions
  35317. */
  35318. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35319. /** @hidden */
  35320. _prepare(): void;
  35321. /**
  35322. * Execute the action and play the sound.
  35323. */
  35324. execute(): void;
  35325. /**
  35326. * Serializes the actions and its related information.
  35327. * @param parent defines the object to serialize in
  35328. * @returns the serialized object
  35329. */
  35330. serialize(parent: any): any;
  35331. }
  35332. /**
  35333. * This defines an action helpful to stop a defined sound on a triggered action.
  35334. */
  35335. export class StopSoundAction extends Action {
  35336. private _sound;
  35337. /**
  35338. * Instantiate the action
  35339. * @param triggerOptions defines the trigger options
  35340. * @param sound defines the sound to stop
  35341. * @param condition defines the trigger related conditions
  35342. */
  35343. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35344. /** @hidden */
  35345. _prepare(): void;
  35346. /**
  35347. * Execute the action and stop the sound.
  35348. */
  35349. execute(): void;
  35350. /**
  35351. * Serializes the actions and its related information.
  35352. * @param parent defines the object to serialize in
  35353. * @returns the serialized object
  35354. */
  35355. serialize(parent: any): any;
  35356. }
  35357. }
  35358. declare module "babylonjs/Actions/interpolateValueAction" {
  35359. import { Action } from "babylonjs/Actions/action";
  35360. import { Condition } from "babylonjs/Actions/condition";
  35361. import { Observable } from "babylonjs/Misc/observable";
  35362. /**
  35363. * This defines an action responsible to change the value of a property
  35364. * by interpolating between its current value and the newly set one once triggered.
  35365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35366. */
  35367. export class InterpolateValueAction extends Action {
  35368. /**
  35369. * Defines the path of the property where the value should be interpolated
  35370. */
  35371. propertyPath: string;
  35372. /**
  35373. * Defines the target value at the end of the interpolation.
  35374. */
  35375. value: any;
  35376. /**
  35377. * Defines the time it will take for the property to interpolate to the value.
  35378. */
  35379. duration: number;
  35380. /**
  35381. * Defines if the other scene animations should be stopped when the action has been triggered
  35382. */
  35383. stopOtherAnimations?: boolean;
  35384. /**
  35385. * Defines a callback raised once the interpolation animation has been done.
  35386. */
  35387. onInterpolationDone?: () => void;
  35388. /**
  35389. * Observable triggered once the interpolation animation has been done.
  35390. */
  35391. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35392. private _target;
  35393. private _effectiveTarget;
  35394. private _property;
  35395. /**
  35396. * Instantiate the action
  35397. * @param triggerOptions defines the trigger options
  35398. * @param target defines the object containing the value to interpolate
  35399. * @param propertyPath defines the path to the property in the target object
  35400. * @param value defines the target value at the end of the interpolation
  35401. * @param duration deines the time it will take for the property to interpolate to the value.
  35402. * @param condition defines the trigger related conditions
  35403. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35404. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35405. */
  35406. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35407. /** @hidden */
  35408. _prepare(): void;
  35409. /**
  35410. * Execute the action starts the value interpolation.
  35411. */
  35412. execute(): void;
  35413. /**
  35414. * Serializes the actions and its related information.
  35415. * @param parent defines the object to serialize in
  35416. * @returns the serialized object
  35417. */
  35418. serialize(parent: any): any;
  35419. }
  35420. }
  35421. declare module "babylonjs/Actions/index" {
  35422. export * from "babylonjs/Actions/action";
  35423. export * from "babylonjs/Actions/actionEvent";
  35424. export * from "babylonjs/Actions/actionManager";
  35425. export * from "babylonjs/Actions/condition";
  35426. export * from "babylonjs/Actions/directActions";
  35427. export * from "babylonjs/Actions/directAudioActions";
  35428. export * from "babylonjs/Actions/interpolateValueAction";
  35429. }
  35430. declare module "babylonjs/Animations/index" {
  35431. export * from "babylonjs/Animations/animatable";
  35432. export * from "babylonjs/Animations/animation";
  35433. export * from "babylonjs/Animations/animationGroup";
  35434. export * from "babylonjs/Animations/animationPropertiesOverride";
  35435. export * from "babylonjs/Animations/easing";
  35436. export * from "babylonjs/Animations/runtimeAnimation";
  35437. export * from "babylonjs/Animations/animationEvent";
  35438. export * from "babylonjs/Animations/animationGroup";
  35439. export * from "babylonjs/Animations/animationKey";
  35440. export * from "babylonjs/Animations/animationRange";
  35441. }
  35442. declare module "babylonjs/Audio/soundTrack" {
  35443. import { Sound } from "babylonjs/Audio/sound";
  35444. import { Analyser } from "babylonjs/Audio/analyser";
  35445. import { Scene } from "babylonjs/scene";
  35446. /**
  35447. * Options allowed during the creation of a sound track.
  35448. */
  35449. export interface ISoundTrackOptions {
  35450. /**
  35451. * The volume the sound track should take during creation
  35452. */
  35453. volume?: number;
  35454. /**
  35455. * Define if the sound track is the main sound track of the scene
  35456. */
  35457. mainTrack?: boolean;
  35458. }
  35459. /**
  35460. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35461. * It will be also used in a future release to apply effects on a specific track.
  35462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35463. */
  35464. export class SoundTrack {
  35465. /**
  35466. * The unique identifier of the sound track in the scene.
  35467. */
  35468. id: number;
  35469. /**
  35470. * The list of sounds included in the sound track.
  35471. */
  35472. soundCollection: Array<Sound>;
  35473. private _outputAudioNode;
  35474. private _scene;
  35475. private _isMainTrack;
  35476. private _connectedAnalyser;
  35477. private _options;
  35478. private _isInitialized;
  35479. /**
  35480. * Creates a new sound track.
  35481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35482. * @param scene Define the scene the sound track belongs to
  35483. * @param options
  35484. */
  35485. constructor(scene: Scene, options?: ISoundTrackOptions);
  35486. private _initializeSoundTrackAudioGraph;
  35487. /**
  35488. * Release the sound track and its associated resources
  35489. */
  35490. dispose(): void;
  35491. /**
  35492. * Adds a sound to this sound track
  35493. * @param sound define the cound to add
  35494. * @ignoreNaming
  35495. */
  35496. AddSound(sound: Sound): void;
  35497. /**
  35498. * Removes a sound to this sound track
  35499. * @param sound define the cound to remove
  35500. * @ignoreNaming
  35501. */
  35502. RemoveSound(sound: Sound): void;
  35503. /**
  35504. * Set a global volume for the full sound track.
  35505. * @param newVolume Define the new volume of the sound track
  35506. */
  35507. setVolume(newVolume: number): void;
  35508. /**
  35509. * Switch the panning model to HRTF:
  35510. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35512. */
  35513. switchPanningModelToHRTF(): void;
  35514. /**
  35515. * Switch the panning model to Equal Power:
  35516. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35518. */
  35519. switchPanningModelToEqualPower(): void;
  35520. /**
  35521. * Connect the sound track to an audio analyser allowing some amazing
  35522. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35524. * @param analyser The analyser to connect to the engine
  35525. */
  35526. connectToAnalyser(analyser: Analyser): void;
  35527. }
  35528. }
  35529. declare module "babylonjs/Audio/audioSceneComponent" {
  35530. import { Sound } from "babylonjs/Audio/sound";
  35531. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35532. import { Nullable } from "babylonjs/types";
  35533. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35534. import { Scene } from "babylonjs/scene";
  35535. import { AbstractScene } from "babylonjs/abstractScene";
  35536. module "babylonjs/abstractScene" {
  35537. interface AbstractScene {
  35538. /**
  35539. * The list of sounds used in the scene.
  35540. */
  35541. sounds: Nullable<Array<Sound>>;
  35542. }
  35543. }
  35544. module "babylonjs/scene" {
  35545. interface Scene {
  35546. /**
  35547. * @hidden
  35548. * Backing field
  35549. */
  35550. _mainSoundTrack: SoundTrack;
  35551. /**
  35552. * The main sound track played by the scene.
  35553. * It cotains your primary collection of sounds.
  35554. */
  35555. mainSoundTrack: SoundTrack;
  35556. /**
  35557. * The list of sound tracks added to the scene
  35558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35559. */
  35560. soundTracks: Nullable<Array<SoundTrack>>;
  35561. /**
  35562. * Gets a sound using a given name
  35563. * @param name defines the name to search for
  35564. * @return the found sound or null if not found at all.
  35565. */
  35566. getSoundByName(name: string): Nullable<Sound>;
  35567. /**
  35568. * Gets or sets if audio support is enabled
  35569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35570. */
  35571. audioEnabled: boolean;
  35572. /**
  35573. * Gets or sets if audio will be output to headphones
  35574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35575. */
  35576. headphone: boolean;
  35577. }
  35578. }
  35579. /**
  35580. * Defines the sound scene component responsible to manage any sounds
  35581. * in a given scene.
  35582. */
  35583. export class AudioSceneComponent implements ISceneSerializableComponent {
  35584. /**
  35585. * The component name helpfull to identify the component in the list of scene components.
  35586. */
  35587. readonly name: string;
  35588. /**
  35589. * The scene the component belongs to.
  35590. */
  35591. scene: Scene;
  35592. private _audioEnabled;
  35593. /**
  35594. * Gets whether audio is enabled or not.
  35595. * Please use related enable/disable method to switch state.
  35596. */
  35597. readonly audioEnabled: boolean;
  35598. private _headphone;
  35599. /**
  35600. * Gets whether audio is outputing to headphone or not.
  35601. * Please use the according Switch methods to change output.
  35602. */
  35603. readonly headphone: boolean;
  35604. /**
  35605. * Creates a new instance of the component for the given scene
  35606. * @param scene Defines the scene to register the component in
  35607. */
  35608. constructor(scene: Scene);
  35609. /**
  35610. * Registers the component in a given scene
  35611. */
  35612. register(): void;
  35613. /**
  35614. * Rebuilds the elements related to this component in case of
  35615. * context lost for instance.
  35616. */
  35617. rebuild(): void;
  35618. /**
  35619. * Serializes the component data to the specified json object
  35620. * @param serializationObject The object to serialize to
  35621. */
  35622. serialize(serializationObject: any): void;
  35623. /**
  35624. * Adds all the elements from the container to the scene
  35625. * @param container the container holding the elements
  35626. */
  35627. addFromContainer(container: AbstractScene): void;
  35628. /**
  35629. * Removes all the elements in the container from the scene
  35630. * @param container contains the elements to remove
  35631. * @param dispose if the removed element should be disposed (default: false)
  35632. */
  35633. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35634. /**
  35635. * Disposes the component and the associated ressources.
  35636. */
  35637. dispose(): void;
  35638. /**
  35639. * Disables audio in the associated scene.
  35640. */
  35641. disableAudio(): void;
  35642. /**
  35643. * Enables audio in the associated scene.
  35644. */
  35645. enableAudio(): void;
  35646. /**
  35647. * Switch audio to headphone output.
  35648. */
  35649. switchAudioModeForHeadphones(): void;
  35650. /**
  35651. * Switch audio to normal speakers.
  35652. */
  35653. switchAudioModeForNormalSpeakers(): void;
  35654. private _afterRender;
  35655. }
  35656. }
  35657. declare module "babylonjs/Audio/weightedsound" {
  35658. import { Sound } from "babylonjs/Audio/sound";
  35659. /**
  35660. * Wraps one or more Sound objects and selects one with random weight for playback.
  35661. */
  35662. export class WeightedSound {
  35663. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35664. loop: boolean;
  35665. private _coneInnerAngle;
  35666. private _coneOuterAngle;
  35667. private _volume;
  35668. /** A Sound is currently playing. */
  35669. isPlaying: boolean;
  35670. /** A Sound is currently paused. */
  35671. isPaused: boolean;
  35672. private _sounds;
  35673. private _weights;
  35674. private _currentIndex?;
  35675. /**
  35676. * Creates a new WeightedSound from the list of sounds given.
  35677. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35678. * @param sounds Array of Sounds that will be selected from.
  35679. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35680. */
  35681. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35682. /**
  35683. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35684. */
  35685. /**
  35686. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35687. */
  35688. directionalConeInnerAngle: number;
  35689. /**
  35690. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35691. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35692. */
  35693. /**
  35694. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35695. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35696. */
  35697. directionalConeOuterAngle: number;
  35698. /**
  35699. * Playback volume.
  35700. */
  35701. /**
  35702. * Playback volume.
  35703. */
  35704. volume: number;
  35705. private _onended;
  35706. /**
  35707. * Suspend playback
  35708. */
  35709. pause(): void;
  35710. /**
  35711. * Stop playback
  35712. */
  35713. stop(): void;
  35714. /**
  35715. * Start playback.
  35716. * @param startOffset Position the clip head at a specific time in seconds.
  35717. */
  35718. play(startOffset?: number): void;
  35719. }
  35720. }
  35721. declare module "babylonjs/Audio/index" {
  35722. export * from "babylonjs/Audio/analyser";
  35723. export * from "babylonjs/Audio/audioEngine";
  35724. export * from "babylonjs/Audio/audioSceneComponent";
  35725. export * from "babylonjs/Audio/sound";
  35726. export * from "babylonjs/Audio/soundTrack";
  35727. export * from "babylonjs/Audio/weightedsound";
  35728. }
  35729. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35730. import { Behavior } from "babylonjs/Behaviors/behavior";
  35731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35732. import { BackEase } from "babylonjs/Animations/easing";
  35733. /**
  35734. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35735. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35736. */
  35737. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35738. /**
  35739. * Gets the name of the behavior.
  35740. */
  35741. readonly name: string;
  35742. /**
  35743. * The easing function used by animations
  35744. */
  35745. static EasingFunction: BackEase;
  35746. /**
  35747. * The easing mode used by animations
  35748. */
  35749. static EasingMode: number;
  35750. /**
  35751. * The duration of the animation, in milliseconds
  35752. */
  35753. transitionDuration: number;
  35754. /**
  35755. * Length of the distance animated by the transition when lower radius is reached
  35756. */
  35757. lowerRadiusTransitionRange: number;
  35758. /**
  35759. * Length of the distance animated by the transition when upper radius is reached
  35760. */
  35761. upperRadiusTransitionRange: number;
  35762. private _autoTransitionRange;
  35763. /**
  35764. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35765. */
  35766. /**
  35767. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35768. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35769. */
  35770. autoTransitionRange: boolean;
  35771. private _attachedCamera;
  35772. private _onAfterCheckInputsObserver;
  35773. private _onMeshTargetChangedObserver;
  35774. /**
  35775. * Initializes the behavior.
  35776. */
  35777. init(): void;
  35778. /**
  35779. * Attaches the behavior to its arc rotate camera.
  35780. * @param camera Defines the camera to attach the behavior to
  35781. */
  35782. attach(camera: ArcRotateCamera): void;
  35783. /**
  35784. * Detaches the behavior from its current arc rotate camera.
  35785. */
  35786. detach(): void;
  35787. private _radiusIsAnimating;
  35788. private _radiusBounceTransition;
  35789. private _animatables;
  35790. private _cachedWheelPrecision;
  35791. /**
  35792. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35793. * @param radiusLimit The limit to check against.
  35794. * @return Bool to indicate if at limit.
  35795. */
  35796. private _isRadiusAtLimit;
  35797. /**
  35798. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35799. * @param radiusDelta The delta by which to animate to. Can be negative.
  35800. */
  35801. private _applyBoundRadiusAnimation;
  35802. /**
  35803. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35804. */
  35805. protected _clearAnimationLocks(): void;
  35806. /**
  35807. * Stops and removes all animations that have been applied to the camera
  35808. */
  35809. stopAllAnimations(): void;
  35810. }
  35811. }
  35812. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35813. import { Behavior } from "babylonjs/Behaviors/behavior";
  35814. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35815. import { ExponentialEase } from "babylonjs/Animations/easing";
  35816. import { Nullable } from "babylonjs/types";
  35817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35818. import { Vector3 } from "babylonjs/Maths/math";
  35819. /**
  35820. * 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.
  35821. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35822. */
  35823. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35824. /**
  35825. * Gets the name of the behavior.
  35826. */
  35827. readonly name: string;
  35828. private _mode;
  35829. private _radiusScale;
  35830. private _positionScale;
  35831. private _defaultElevation;
  35832. private _elevationReturnTime;
  35833. private _elevationReturnWaitTime;
  35834. private _zoomStopsAnimation;
  35835. private _framingTime;
  35836. /**
  35837. * The easing function used by animations
  35838. */
  35839. static EasingFunction: ExponentialEase;
  35840. /**
  35841. * The easing mode used by animations
  35842. */
  35843. static EasingMode: number;
  35844. /**
  35845. * Sets the current mode used by the behavior
  35846. */
  35847. /**
  35848. * Gets current mode used by the behavior.
  35849. */
  35850. mode: number;
  35851. /**
  35852. * Sets the scale applied to the radius (1 by default)
  35853. */
  35854. /**
  35855. * Gets the scale applied to the radius
  35856. */
  35857. radiusScale: number;
  35858. /**
  35859. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35860. */
  35861. /**
  35862. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35863. */
  35864. positionScale: number;
  35865. /**
  35866. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35867. * behaviour is triggered, in radians.
  35868. */
  35869. /**
  35870. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35871. * behaviour is triggered, in radians.
  35872. */
  35873. defaultElevation: number;
  35874. /**
  35875. * Sets the time (in milliseconds) taken to return to the default beta position.
  35876. * Negative value indicates camera should not return to default.
  35877. */
  35878. /**
  35879. * Gets the time (in milliseconds) taken to return to the default beta position.
  35880. * Negative value indicates camera should not return to default.
  35881. */
  35882. elevationReturnTime: number;
  35883. /**
  35884. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35885. */
  35886. /**
  35887. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35888. */
  35889. elevationReturnWaitTime: number;
  35890. /**
  35891. * Sets the flag that indicates if user zooming should stop animation.
  35892. */
  35893. /**
  35894. * Gets the flag that indicates if user zooming should stop animation.
  35895. */
  35896. zoomStopsAnimation: boolean;
  35897. /**
  35898. * Sets the transition time when framing the mesh, in milliseconds
  35899. */
  35900. /**
  35901. * Gets the transition time when framing the mesh, in milliseconds
  35902. */
  35903. framingTime: number;
  35904. /**
  35905. * Define if the behavior should automatically change the configured
  35906. * camera limits and sensibilities.
  35907. */
  35908. autoCorrectCameraLimitsAndSensibility: boolean;
  35909. private _onPrePointerObservableObserver;
  35910. private _onAfterCheckInputsObserver;
  35911. private _onMeshTargetChangedObserver;
  35912. private _attachedCamera;
  35913. private _isPointerDown;
  35914. private _lastInteractionTime;
  35915. /**
  35916. * Initializes the behavior.
  35917. */
  35918. init(): void;
  35919. /**
  35920. * Attaches the behavior to its arc rotate camera.
  35921. * @param camera Defines the camera to attach the behavior to
  35922. */
  35923. attach(camera: ArcRotateCamera): void;
  35924. /**
  35925. * Detaches the behavior from its current arc rotate camera.
  35926. */
  35927. detach(): void;
  35928. private _animatables;
  35929. private _betaIsAnimating;
  35930. private _betaTransition;
  35931. private _radiusTransition;
  35932. private _vectorTransition;
  35933. /**
  35934. * Targets the given mesh and updates zoom level accordingly.
  35935. * @param mesh The mesh to target.
  35936. * @param radius Optional. If a cached radius position already exists, overrides default.
  35937. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35938. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35939. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35940. */
  35941. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35942. /**
  35943. * Targets the given mesh with its children and updates zoom level accordingly.
  35944. * @param mesh The mesh to target.
  35945. * @param radius Optional. If a cached radius position already exists, overrides default.
  35946. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35947. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35948. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35949. */
  35950. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35951. /**
  35952. * Targets the given meshes with their children and updates zoom level accordingly.
  35953. * @param meshes The mesh to target.
  35954. * @param radius Optional. If a cached radius position already exists, overrides default.
  35955. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35956. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35957. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35958. */
  35959. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35960. /**
  35961. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35962. * @param minimumWorld Determines the smaller position of the bounding box extend
  35963. * @param maximumWorld Determines the bigger position of the bounding box extend
  35964. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35965. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35966. */
  35967. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35968. /**
  35969. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35970. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35971. * frustum width.
  35972. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35973. * to fully enclose the mesh in the viewing frustum.
  35974. */
  35975. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35976. /**
  35977. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35978. * is automatically returned to its default position (expected to be above ground plane).
  35979. */
  35980. private _maintainCameraAboveGround;
  35981. /**
  35982. * Returns the frustum slope based on the canvas ratio and camera FOV
  35983. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35984. */
  35985. private _getFrustumSlope;
  35986. /**
  35987. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35988. */
  35989. private _clearAnimationLocks;
  35990. /**
  35991. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35992. */
  35993. private _applyUserInteraction;
  35994. /**
  35995. * Stops and removes all animations that have been applied to the camera
  35996. */
  35997. stopAllAnimations(): void;
  35998. /**
  35999. * Gets a value indicating if the user is moving the camera
  36000. */
  36001. readonly isUserIsMoving: boolean;
  36002. /**
  36003. * The camera can move all the way towards the mesh.
  36004. */
  36005. static IgnoreBoundsSizeMode: number;
  36006. /**
  36007. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36008. */
  36009. static FitFrustumSidesMode: number;
  36010. }
  36011. }
  36012. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36013. import { Nullable } from "babylonjs/types";
  36014. import { Camera } from "babylonjs/Cameras/camera";
  36015. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36016. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36017. /**
  36018. * Base class for Camera Pointer Inputs.
  36019. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36020. * for example usage.
  36021. */
  36022. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36023. /**
  36024. * Defines the camera the input is attached to.
  36025. */
  36026. abstract camera: Camera;
  36027. /**
  36028. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36029. */
  36030. protected _altKey: boolean;
  36031. protected _ctrlKey: boolean;
  36032. protected _metaKey: boolean;
  36033. protected _shiftKey: boolean;
  36034. /**
  36035. * Which mouse buttons were pressed at time of last mouse event.
  36036. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36037. */
  36038. protected _buttonsPressed: number;
  36039. /**
  36040. * Defines the buttons associated with the input to handle camera move.
  36041. */
  36042. buttons: number[];
  36043. /**
  36044. * Attach the input controls to a specific dom element to get the input from.
  36045. * @param element Defines the element the controls should be listened from
  36046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36047. */
  36048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36049. /**
  36050. * Detach the current controls from the specified dom element.
  36051. * @param element Defines the element to stop listening the inputs from
  36052. */
  36053. detachControl(element: Nullable<HTMLElement>): void;
  36054. /**
  36055. * Gets the class name of the current input.
  36056. * @returns the class name
  36057. */
  36058. getClassName(): string;
  36059. /**
  36060. * Get the friendly name associated with the input class.
  36061. * @returns the input friendly name
  36062. */
  36063. getSimpleName(): string;
  36064. /**
  36065. * Called on pointer POINTERDOUBLETAP event.
  36066. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36067. */
  36068. protected onDoubleTap(type: string): void;
  36069. /**
  36070. * Called on pointer POINTERMOVE event if only a single touch is active.
  36071. * Override this method to provide functionality.
  36072. */
  36073. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36074. /**
  36075. * Called on pointer POINTERMOVE event if multiple touches are active.
  36076. * Override this method to provide functionality.
  36077. */
  36078. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36079. /**
  36080. * Called on JS contextmenu event.
  36081. * Override this method to provide functionality.
  36082. */
  36083. protected onContextMenu(evt: PointerEvent): void;
  36084. /**
  36085. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36086. * press.
  36087. * Override this method to provide functionality.
  36088. */
  36089. protected onButtonDown(evt: PointerEvent): void;
  36090. /**
  36091. * Called each time a new POINTERUP event occurs. Ie, for each button
  36092. * release.
  36093. * Override this method to provide functionality.
  36094. */
  36095. protected onButtonUp(evt: PointerEvent): void;
  36096. /**
  36097. * Called when window becomes inactive.
  36098. * Override this method to provide functionality.
  36099. */
  36100. protected onLostFocus(): void;
  36101. private _pointerInput;
  36102. private _observer;
  36103. private _onLostFocus;
  36104. private pointA;
  36105. private pointB;
  36106. }
  36107. }
  36108. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36109. import { Nullable } from "babylonjs/types";
  36110. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36111. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36112. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36113. /**
  36114. * Manage the pointers inputs to control an arc rotate camera.
  36115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36116. */
  36117. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36118. /**
  36119. * Defines the camera the input is attached to.
  36120. */
  36121. camera: ArcRotateCamera;
  36122. /**
  36123. * Gets the class name of the current input.
  36124. * @returns the class name
  36125. */
  36126. getClassName(): string;
  36127. /**
  36128. * Defines the buttons associated with the input to handle camera move.
  36129. */
  36130. buttons: number[];
  36131. /**
  36132. * Defines the pointer angular sensibility along the X axis or how fast is
  36133. * the camera rotating.
  36134. */
  36135. angularSensibilityX: number;
  36136. /**
  36137. * Defines the pointer angular sensibility along the Y axis or how fast is
  36138. * the camera rotating.
  36139. */
  36140. angularSensibilityY: number;
  36141. /**
  36142. * Defines the pointer pinch precision or how fast is the camera zooming.
  36143. */
  36144. pinchPrecision: number;
  36145. /**
  36146. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36147. * from 0.
  36148. * It defines the percentage of current camera.radius to use as delta when
  36149. * pinch zoom is used.
  36150. */
  36151. pinchDeltaPercentage: number;
  36152. /**
  36153. * Defines the pointer panning sensibility or how fast is the camera moving.
  36154. */
  36155. panningSensibility: number;
  36156. /**
  36157. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36158. */
  36159. multiTouchPanning: boolean;
  36160. /**
  36161. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36162. * zoom (pinch) through multitouch.
  36163. */
  36164. multiTouchPanAndZoom: boolean;
  36165. /**
  36166. * Revers pinch action direction.
  36167. */
  36168. pinchInwards: boolean;
  36169. private _isPanClick;
  36170. private _twoFingerActivityCount;
  36171. private _isPinching;
  36172. /**
  36173. * Called on pointer POINTERMOVE event if only a single touch is active.
  36174. */
  36175. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36176. /**
  36177. * Called on pointer POINTERDOUBLETAP event.
  36178. */
  36179. protected onDoubleTap(type: string): void;
  36180. /**
  36181. * Called on pointer POINTERMOVE event if multiple touches are active.
  36182. */
  36183. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36184. /**
  36185. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36186. * press.
  36187. */
  36188. protected onButtonDown(evt: PointerEvent): void;
  36189. /**
  36190. * Called each time a new POINTERUP event occurs. Ie, for each button
  36191. * release.
  36192. */
  36193. protected onButtonUp(evt: PointerEvent): void;
  36194. /**
  36195. * Called when window becomes inactive.
  36196. */
  36197. protected onLostFocus(): void;
  36198. }
  36199. }
  36200. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36201. import { Nullable } from "babylonjs/types";
  36202. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36203. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36204. /**
  36205. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36207. */
  36208. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36209. /**
  36210. * Defines the camera the input is attached to.
  36211. */
  36212. camera: ArcRotateCamera;
  36213. /**
  36214. * Defines the list of key codes associated with the up action (increase alpha)
  36215. */
  36216. keysUp: number[];
  36217. /**
  36218. * Defines the list of key codes associated with the down action (decrease alpha)
  36219. */
  36220. keysDown: number[];
  36221. /**
  36222. * Defines the list of key codes associated with the left action (increase beta)
  36223. */
  36224. keysLeft: number[];
  36225. /**
  36226. * Defines the list of key codes associated with the right action (decrease beta)
  36227. */
  36228. keysRight: number[];
  36229. /**
  36230. * Defines the list of key codes associated with the reset action.
  36231. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36232. */
  36233. keysReset: number[];
  36234. /**
  36235. * Defines the panning sensibility of the inputs.
  36236. * (How fast is the camera paning)
  36237. */
  36238. panningSensibility: number;
  36239. /**
  36240. * Defines the zooming sensibility of the inputs.
  36241. * (How fast is the camera zooming)
  36242. */
  36243. zoomingSensibility: number;
  36244. /**
  36245. * Defines wether maintaining the alt key down switch the movement mode from
  36246. * orientation to zoom.
  36247. */
  36248. useAltToZoom: boolean;
  36249. /**
  36250. * Rotation speed of the camera
  36251. */
  36252. angularSpeed: number;
  36253. private _keys;
  36254. private _ctrlPressed;
  36255. private _altPressed;
  36256. private _onCanvasBlurObserver;
  36257. private _onKeyboardObserver;
  36258. private _engine;
  36259. private _scene;
  36260. /**
  36261. * Attach the input controls to a specific dom element to get the input from.
  36262. * @param element Defines the element the controls should be listened from
  36263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36264. */
  36265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36266. /**
  36267. * Detach the current controls from the specified dom element.
  36268. * @param element Defines the element to stop listening the inputs from
  36269. */
  36270. detachControl(element: Nullable<HTMLElement>): void;
  36271. /**
  36272. * Update the current camera state depending on the inputs that have been used this frame.
  36273. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36274. */
  36275. checkInputs(): void;
  36276. /**
  36277. * Gets the class name of the current intput.
  36278. * @returns the class name
  36279. */
  36280. getClassName(): string;
  36281. /**
  36282. * Get the friendly name associated with the input class.
  36283. * @returns the input friendly name
  36284. */
  36285. getSimpleName(): string;
  36286. }
  36287. }
  36288. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36289. import { Nullable } from "babylonjs/types";
  36290. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36291. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36292. /**
  36293. * Manage the mouse wheel inputs to control an arc rotate camera.
  36294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36295. */
  36296. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36297. /**
  36298. * Defines the camera the input is attached to.
  36299. */
  36300. camera: ArcRotateCamera;
  36301. /**
  36302. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36303. */
  36304. wheelPrecision: number;
  36305. /**
  36306. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36307. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36308. */
  36309. wheelDeltaPercentage: number;
  36310. private _wheel;
  36311. private _observer;
  36312. private computeDeltaFromMouseWheelLegacyEvent;
  36313. /**
  36314. * Attach the input controls to a specific dom element to get the input from.
  36315. * @param element Defines the element the controls should be listened from
  36316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36317. */
  36318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36319. /**
  36320. * Detach the current controls from the specified dom element.
  36321. * @param element Defines the element to stop listening the inputs from
  36322. */
  36323. detachControl(element: Nullable<HTMLElement>): void;
  36324. /**
  36325. * Gets the class name of the current intput.
  36326. * @returns the class name
  36327. */
  36328. getClassName(): string;
  36329. /**
  36330. * Get the friendly name associated with the input class.
  36331. * @returns the input friendly name
  36332. */
  36333. getSimpleName(): string;
  36334. }
  36335. }
  36336. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36337. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36338. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36339. /**
  36340. * Default Inputs manager for the ArcRotateCamera.
  36341. * It groups all the default supported inputs for ease of use.
  36342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36343. */
  36344. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36345. /**
  36346. * Instantiates a new ArcRotateCameraInputsManager.
  36347. * @param camera Defines the camera the inputs belong to
  36348. */
  36349. constructor(camera: ArcRotateCamera);
  36350. /**
  36351. * Add mouse wheel input support to the input manager.
  36352. * @returns the current input manager
  36353. */
  36354. addMouseWheel(): ArcRotateCameraInputsManager;
  36355. /**
  36356. * Add pointers input support to the input manager.
  36357. * @returns the current input manager
  36358. */
  36359. addPointers(): ArcRotateCameraInputsManager;
  36360. /**
  36361. * Add keyboard input support to the input manager.
  36362. * @returns the current input manager
  36363. */
  36364. addKeyboard(): ArcRotateCameraInputsManager;
  36365. }
  36366. }
  36367. declare module "babylonjs/Cameras/arcRotateCamera" {
  36368. import { Observable } from "babylonjs/Misc/observable";
  36369. import { Nullable } from "babylonjs/types";
  36370. import { Scene } from "babylonjs/scene";
  36371. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36373. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36374. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36375. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36376. import { Camera } from "babylonjs/Cameras/camera";
  36377. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36378. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36379. import { Collider } from "babylonjs/Collisions/collider";
  36380. /**
  36381. * This represents an orbital type of camera.
  36382. *
  36383. * 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.
  36384. * 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.
  36385. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36386. */
  36387. export class ArcRotateCamera extends TargetCamera {
  36388. /**
  36389. * Defines the rotation angle of the camera along the longitudinal axis.
  36390. */
  36391. alpha: number;
  36392. /**
  36393. * Defines the rotation angle of the camera along the latitudinal axis.
  36394. */
  36395. beta: number;
  36396. /**
  36397. * Defines the radius of the camera from it s target point.
  36398. */
  36399. radius: number;
  36400. protected _target: Vector3;
  36401. protected _targetHost: Nullable<AbstractMesh>;
  36402. /**
  36403. * Defines the target point of the camera.
  36404. * The camera looks towards it form the radius distance.
  36405. */
  36406. target: Vector3;
  36407. /**
  36408. * Define the current local position of the camera in the scene
  36409. */
  36410. position: Vector3;
  36411. protected _upVector: Vector3;
  36412. protected _upToYMatrix: Matrix;
  36413. protected _YToUpMatrix: Matrix;
  36414. /**
  36415. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36416. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36417. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36418. */
  36419. upVector: Vector3;
  36420. /**
  36421. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36422. */
  36423. setMatUp(): void;
  36424. /**
  36425. * Current inertia value on the longitudinal axis.
  36426. * The bigger this number the longer it will take for the camera to stop.
  36427. */
  36428. inertialAlphaOffset: number;
  36429. /**
  36430. * Current inertia value on the latitudinal axis.
  36431. * The bigger this number the longer it will take for the camera to stop.
  36432. */
  36433. inertialBetaOffset: number;
  36434. /**
  36435. * Current inertia value on the radius axis.
  36436. * The bigger this number the longer it will take for the camera to stop.
  36437. */
  36438. inertialRadiusOffset: number;
  36439. /**
  36440. * Minimum allowed angle on the longitudinal axis.
  36441. * This can help limiting how the Camera is able to move in the scene.
  36442. */
  36443. lowerAlphaLimit: Nullable<number>;
  36444. /**
  36445. * Maximum allowed angle on the longitudinal axis.
  36446. * This can help limiting how the Camera is able to move in the scene.
  36447. */
  36448. upperAlphaLimit: Nullable<number>;
  36449. /**
  36450. * Minimum allowed angle on the latitudinal axis.
  36451. * This can help limiting how the Camera is able to move in the scene.
  36452. */
  36453. lowerBetaLimit: number;
  36454. /**
  36455. * Maximum allowed angle on the latitudinal axis.
  36456. * This can help limiting how the Camera is able to move in the scene.
  36457. */
  36458. upperBetaLimit: number;
  36459. /**
  36460. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36461. * This can help limiting how the Camera is able to move in the scene.
  36462. */
  36463. lowerRadiusLimit: Nullable<number>;
  36464. /**
  36465. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36466. * This can help limiting how the Camera is able to move in the scene.
  36467. */
  36468. upperRadiusLimit: Nullable<number>;
  36469. /**
  36470. * Defines the current inertia value used during panning of the camera along the X axis.
  36471. */
  36472. inertialPanningX: number;
  36473. /**
  36474. * Defines the current inertia value used during panning of the camera along the Y axis.
  36475. */
  36476. inertialPanningY: number;
  36477. /**
  36478. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36479. * Basically if your fingers moves away from more than this distance you will be considered
  36480. * in pinch mode.
  36481. */
  36482. pinchToPanMaxDistance: number;
  36483. /**
  36484. * Defines the maximum distance the camera can pan.
  36485. * This could help keeping the cammera always in your scene.
  36486. */
  36487. panningDistanceLimit: Nullable<number>;
  36488. /**
  36489. * Defines the target of the camera before paning.
  36490. */
  36491. panningOriginTarget: Vector3;
  36492. /**
  36493. * Defines the value of the inertia used during panning.
  36494. * 0 would mean stop inertia and one would mean no decelleration at all.
  36495. */
  36496. panningInertia: number;
  36497. /**
  36498. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36499. */
  36500. angularSensibilityX: number;
  36501. /**
  36502. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36503. */
  36504. angularSensibilityY: number;
  36505. /**
  36506. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36507. */
  36508. pinchPrecision: number;
  36509. /**
  36510. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36511. * It will be used instead of pinchDeltaPrecision if different from 0.
  36512. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36513. */
  36514. pinchDeltaPercentage: number;
  36515. /**
  36516. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36517. */
  36518. panningSensibility: number;
  36519. /**
  36520. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36521. */
  36522. keysUp: number[];
  36523. /**
  36524. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36525. */
  36526. keysDown: number[];
  36527. /**
  36528. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36529. */
  36530. keysLeft: number[];
  36531. /**
  36532. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36533. */
  36534. keysRight: number[];
  36535. /**
  36536. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36537. */
  36538. wheelPrecision: number;
  36539. /**
  36540. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36541. * It will be used instead of pinchDeltaPrecision if different from 0.
  36542. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36543. */
  36544. wheelDeltaPercentage: number;
  36545. /**
  36546. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36547. */
  36548. zoomOnFactor: number;
  36549. /**
  36550. * Defines a screen offset for the camera position.
  36551. */
  36552. targetScreenOffset: Vector2;
  36553. /**
  36554. * Allows the camera to be completely reversed.
  36555. * If false the camera can not arrive upside down.
  36556. */
  36557. allowUpsideDown: boolean;
  36558. /**
  36559. * Define if double tap/click is used to restore the previously saved state of the camera.
  36560. */
  36561. useInputToRestoreState: boolean;
  36562. /** @hidden */
  36563. _viewMatrix: Matrix;
  36564. /** @hidden */
  36565. _useCtrlForPanning: boolean;
  36566. /** @hidden */
  36567. _panningMouseButton: number;
  36568. /**
  36569. * Defines the input associated to the camera.
  36570. */
  36571. inputs: ArcRotateCameraInputsManager;
  36572. /** @hidden */
  36573. _reset: () => void;
  36574. /**
  36575. * Defines the allowed panning axis.
  36576. */
  36577. panningAxis: Vector3;
  36578. protected _localDirection: Vector3;
  36579. protected _transformedDirection: Vector3;
  36580. private _bouncingBehavior;
  36581. /**
  36582. * Gets the bouncing behavior of the camera if it has been enabled.
  36583. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36584. */
  36585. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36586. /**
  36587. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36589. */
  36590. useBouncingBehavior: boolean;
  36591. private _framingBehavior;
  36592. /**
  36593. * Gets the framing behavior of the camera if it has been enabled.
  36594. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36595. */
  36596. readonly framingBehavior: Nullable<FramingBehavior>;
  36597. /**
  36598. * Defines if the framing behavior of the camera is enabled on the camera.
  36599. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36600. */
  36601. useFramingBehavior: boolean;
  36602. private _autoRotationBehavior;
  36603. /**
  36604. * Gets the auto rotation behavior of the camera if it has been enabled.
  36605. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36606. */
  36607. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36608. /**
  36609. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36610. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36611. */
  36612. useAutoRotationBehavior: boolean;
  36613. /**
  36614. * Observable triggered when the mesh target has been changed on the camera.
  36615. */
  36616. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36617. /**
  36618. * Event raised when the camera is colliding with a mesh.
  36619. */
  36620. onCollide: (collidedMesh: AbstractMesh) => void;
  36621. /**
  36622. * Defines whether the camera should check collision with the objects oh the scene.
  36623. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36624. */
  36625. checkCollisions: boolean;
  36626. /**
  36627. * Defines the collision radius of the camera.
  36628. * This simulates a sphere around the camera.
  36629. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36630. */
  36631. collisionRadius: Vector3;
  36632. protected _collider: Collider;
  36633. protected _previousPosition: Vector3;
  36634. protected _collisionVelocity: Vector3;
  36635. protected _newPosition: Vector3;
  36636. protected _previousAlpha: number;
  36637. protected _previousBeta: number;
  36638. protected _previousRadius: number;
  36639. protected _collisionTriggered: boolean;
  36640. protected _targetBoundingCenter: Nullable<Vector3>;
  36641. private _computationVector;
  36642. /**
  36643. * Instantiates a new ArcRotateCamera in a given scene
  36644. * @param name Defines the name of the camera
  36645. * @param alpha Defines the camera rotation along the logitudinal axis
  36646. * @param beta Defines the camera rotation along the latitudinal axis
  36647. * @param radius Defines the camera distance from its target
  36648. * @param target Defines the camera target
  36649. * @param scene Defines the scene the camera belongs to
  36650. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36651. */
  36652. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36653. /** @hidden */
  36654. _initCache(): void;
  36655. /** @hidden */
  36656. _updateCache(ignoreParentClass?: boolean): void;
  36657. protected _getTargetPosition(): Vector3;
  36658. private _storedAlpha;
  36659. private _storedBeta;
  36660. private _storedRadius;
  36661. private _storedTarget;
  36662. /**
  36663. * Stores the current state of the camera (alpha, beta, radius and target)
  36664. * @returns the camera itself
  36665. */
  36666. storeState(): Camera;
  36667. /**
  36668. * @hidden
  36669. * Restored camera state. You must call storeState() first
  36670. */
  36671. _restoreStateValues(): boolean;
  36672. /** @hidden */
  36673. _isSynchronizedViewMatrix(): boolean;
  36674. /**
  36675. * Attached controls to the current camera.
  36676. * @param element Defines the element the controls should be listened from
  36677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36678. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36679. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36680. */
  36681. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36682. /**
  36683. * Detach the current controls from the camera.
  36684. * The camera will stop reacting to inputs.
  36685. * @param element Defines the element to stop listening the inputs from
  36686. */
  36687. detachControl(element: HTMLElement): void;
  36688. /** @hidden */
  36689. _checkInputs(): void;
  36690. protected _checkLimits(): void;
  36691. /**
  36692. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36693. */
  36694. rebuildAnglesAndRadius(): void;
  36695. /**
  36696. * Use a position to define the current camera related information like aplha, beta and radius
  36697. * @param position Defines the position to set the camera at
  36698. */
  36699. setPosition(position: Vector3): void;
  36700. /**
  36701. * Defines the target the camera should look at.
  36702. * This will automatically adapt alpha beta and radius to fit within the new target.
  36703. * @param target Defines the new target as a Vector or a mesh
  36704. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36705. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36706. */
  36707. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36708. /** @hidden */
  36709. _getViewMatrix(): Matrix;
  36710. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36711. /**
  36712. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36713. * @param meshes Defines the mesh to zoom on
  36714. * @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)
  36715. */
  36716. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36717. /**
  36718. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36719. * The target will be changed but the radius
  36720. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36721. * @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)
  36722. */
  36723. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36724. min: Vector3;
  36725. max: Vector3;
  36726. distance: number;
  36727. }, doNotUpdateMaxZ?: boolean): void;
  36728. /**
  36729. * @override
  36730. * Override Camera.createRigCamera
  36731. */
  36732. createRigCamera(name: string, cameraIndex: number): Camera;
  36733. /**
  36734. * @hidden
  36735. * @override
  36736. * Override Camera._updateRigCameras
  36737. */
  36738. _updateRigCameras(): void;
  36739. /**
  36740. * Destroy the camera and release the current resources hold by it.
  36741. */
  36742. dispose(): void;
  36743. /**
  36744. * Gets the current object class name.
  36745. * @return the class name
  36746. */
  36747. getClassName(): string;
  36748. }
  36749. }
  36750. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36751. import { Behavior } from "babylonjs/Behaviors/behavior";
  36752. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36753. /**
  36754. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36755. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36756. */
  36757. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36758. /**
  36759. * Gets the name of the behavior.
  36760. */
  36761. readonly name: string;
  36762. private _zoomStopsAnimation;
  36763. private _idleRotationSpeed;
  36764. private _idleRotationWaitTime;
  36765. private _idleRotationSpinupTime;
  36766. /**
  36767. * Sets the flag that indicates if user zooming should stop animation.
  36768. */
  36769. /**
  36770. * Gets the flag that indicates if user zooming should stop animation.
  36771. */
  36772. zoomStopsAnimation: boolean;
  36773. /**
  36774. * Sets the default speed at which the camera rotates around the model.
  36775. */
  36776. /**
  36777. * Gets the default speed at which the camera rotates around the model.
  36778. */
  36779. idleRotationSpeed: number;
  36780. /**
  36781. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36782. */
  36783. /**
  36784. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36785. */
  36786. idleRotationWaitTime: number;
  36787. /**
  36788. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36789. */
  36790. /**
  36791. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36792. */
  36793. idleRotationSpinupTime: number;
  36794. /**
  36795. * Gets a value indicating if the camera is currently rotating because of this behavior
  36796. */
  36797. readonly rotationInProgress: boolean;
  36798. private _onPrePointerObservableObserver;
  36799. private _onAfterCheckInputsObserver;
  36800. private _attachedCamera;
  36801. private _isPointerDown;
  36802. private _lastFrameTime;
  36803. private _lastInteractionTime;
  36804. private _cameraRotationSpeed;
  36805. /**
  36806. * Initializes the behavior.
  36807. */
  36808. init(): void;
  36809. /**
  36810. * Attaches the behavior to its arc rotate camera.
  36811. * @param camera Defines the camera to attach the behavior to
  36812. */
  36813. attach(camera: ArcRotateCamera): void;
  36814. /**
  36815. * Detaches the behavior from its current arc rotate camera.
  36816. */
  36817. detach(): void;
  36818. /**
  36819. * Returns true if user is scrolling.
  36820. * @return true if user is scrolling.
  36821. */
  36822. private _userIsZooming;
  36823. private _lastFrameRadius;
  36824. private _shouldAnimationStopForInteraction;
  36825. /**
  36826. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36827. */
  36828. private _applyUserInteraction;
  36829. private _userIsMoving;
  36830. }
  36831. }
  36832. declare module "babylonjs/Behaviors/Cameras/index" {
  36833. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36834. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36835. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36836. }
  36837. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36838. import { Mesh } from "babylonjs/Meshes/mesh";
  36839. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36840. import { Behavior } from "babylonjs/Behaviors/behavior";
  36841. /**
  36842. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36843. */
  36844. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36845. private ui;
  36846. /**
  36847. * The name of the behavior
  36848. */
  36849. name: string;
  36850. /**
  36851. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36852. */
  36853. distanceAwayFromFace: number;
  36854. /**
  36855. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36856. */
  36857. distanceAwayFromBottomOfFace: number;
  36858. private _faceVectors;
  36859. private _target;
  36860. private _scene;
  36861. private _onRenderObserver;
  36862. private _tmpMatrix;
  36863. private _tmpVector;
  36864. /**
  36865. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36866. * @param ui The transform node that should be attched to the mesh
  36867. */
  36868. constructor(ui: TransformNode);
  36869. /**
  36870. * Initializes the behavior
  36871. */
  36872. init(): void;
  36873. private _closestFace;
  36874. private _zeroVector;
  36875. private _lookAtTmpMatrix;
  36876. private _lookAtToRef;
  36877. /**
  36878. * Attaches the AttachToBoxBehavior to the passed in mesh
  36879. * @param target The mesh that the specified node will be attached to
  36880. */
  36881. attach(target: Mesh): void;
  36882. /**
  36883. * Detaches the behavior from the mesh
  36884. */
  36885. detach(): void;
  36886. }
  36887. }
  36888. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36889. import { Behavior } from "babylonjs/Behaviors/behavior";
  36890. import { Mesh } from "babylonjs/Meshes/mesh";
  36891. /**
  36892. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36893. */
  36894. export class FadeInOutBehavior implements Behavior<Mesh> {
  36895. /**
  36896. * Time in milliseconds to delay before fading in (Default: 0)
  36897. */
  36898. delay: number;
  36899. /**
  36900. * Time in milliseconds for the mesh to fade in (Default: 300)
  36901. */
  36902. fadeInTime: number;
  36903. private _millisecondsPerFrame;
  36904. private _hovered;
  36905. private _hoverValue;
  36906. private _ownerNode;
  36907. /**
  36908. * Instatiates the FadeInOutBehavior
  36909. */
  36910. constructor();
  36911. /**
  36912. * The name of the behavior
  36913. */
  36914. readonly name: string;
  36915. /**
  36916. * Initializes the behavior
  36917. */
  36918. init(): void;
  36919. /**
  36920. * Attaches the fade behavior on the passed in mesh
  36921. * @param ownerNode The mesh that will be faded in/out once attached
  36922. */
  36923. attach(ownerNode: Mesh): void;
  36924. /**
  36925. * Detaches the behavior from the mesh
  36926. */
  36927. detach(): void;
  36928. /**
  36929. * Triggers the mesh to begin fading in or out
  36930. * @param value if the object should fade in or out (true to fade in)
  36931. */
  36932. fadeIn(value: boolean): void;
  36933. private _update;
  36934. private _setAllVisibility;
  36935. }
  36936. }
  36937. declare module "babylonjs/Misc/pivotTools" {
  36938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36939. /**
  36940. * Class containing a set of static utilities functions for managing Pivots
  36941. * @hidden
  36942. */
  36943. export class PivotTools {
  36944. private static _PivotCached;
  36945. private static _OldPivotPoint;
  36946. private static _PivotTranslation;
  36947. private static _PivotTmpVector;
  36948. /** @hidden */
  36949. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36950. /** @hidden */
  36951. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36952. }
  36953. }
  36954. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36955. import { Scene } from "babylonjs/scene";
  36956. import { Vector4, Plane } from "babylonjs/Maths/math";
  36957. import { Mesh } from "babylonjs/Meshes/mesh";
  36958. import { Nullable } from "babylonjs/types";
  36959. /**
  36960. * Class containing static functions to help procedurally build meshes
  36961. */
  36962. export class PlaneBuilder {
  36963. /**
  36964. * Creates a plane mesh
  36965. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36966. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36967. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36971. * @param name defines the name of the mesh
  36972. * @param options defines the options used to create the mesh
  36973. * @param scene defines the hosting scene
  36974. * @returns the plane mesh
  36975. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36976. */
  36977. static CreatePlane(name: string, options: {
  36978. size?: number;
  36979. width?: number;
  36980. height?: number;
  36981. sideOrientation?: number;
  36982. frontUVs?: Vector4;
  36983. backUVs?: Vector4;
  36984. updatable?: boolean;
  36985. sourcePlane?: Plane;
  36986. }, scene?: Nullable<Scene>): Mesh;
  36987. }
  36988. }
  36989. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36990. import { Behavior } from "babylonjs/Behaviors/behavior";
  36991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36992. import { Observable } from "babylonjs/Misc/observable";
  36993. import { Vector3 } from "babylonjs/Maths/math";
  36994. import { Ray } from "babylonjs/Culling/ray";
  36995. import "babylonjs/Meshes/Builders/planeBuilder";
  36996. /**
  36997. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36998. */
  36999. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37000. private static _AnyMouseID;
  37001. /**
  37002. * Abstract mesh the behavior is set on
  37003. */
  37004. attachedNode: AbstractMesh;
  37005. private _dragPlane;
  37006. private _scene;
  37007. private _pointerObserver;
  37008. private _beforeRenderObserver;
  37009. private static _planeScene;
  37010. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37011. /**
  37012. * 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)
  37013. */
  37014. maxDragAngle: number;
  37015. /**
  37016. * @hidden
  37017. */
  37018. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37019. /**
  37020. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37021. */
  37022. currentDraggingPointerID: number;
  37023. /**
  37024. * The last position where the pointer hit the drag plane in world space
  37025. */
  37026. lastDragPosition: Vector3;
  37027. /**
  37028. * If the behavior is currently in a dragging state
  37029. */
  37030. dragging: boolean;
  37031. /**
  37032. * 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)
  37033. */
  37034. dragDeltaRatio: number;
  37035. /**
  37036. * If the drag plane orientation should be updated during the dragging (Default: true)
  37037. */
  37038. updateDragPlane: boolean;
  37039. private _debugMode;
  37040. private _moving;
  37041. /**
  37042. * Fires each time the attached mesh is dragged with the pointer
  37043. * * delta between last drag position and current drag position in world space
  37044. * * dragDistance along the drag axis
  37045. * * dragPlaneNormal normal of the current drag plane used during the drag
  37046. * * dragPlanePoint in world space where the drag intersects the drag plane
  37047. */
  37048. onDragObservable: Observable<{
  37049. delta: Vector3;
  37050. dragPlanePoint: Vector3;
  37051. dragPlaneNormal: Vector3;
  37052. dragDistance: number;
  37053. pointerId: number;
  37054. }>;
  37055. /**
  37056. * Fires each time a drag begins (eg. mouse down on mesh)
  37057. */
  37058. onDragStartObservable: Observable<{
  37059. dragPlanePoint: Vector3;
  37060. pointerId: number;
  37061. }>;
  37062. /**
  37063. * Fires each time a drag ends (eg. mouse release after drag)
  37064. */
  37065. onDragEndObservable: Observable<{
  37066. dragPlanePoint: Vector3;
  37067. pointerId: number;
  37068. }>;
  37069. /**
  37070. * If the attached mesh should be moved when dragged
  37071. */
  37072. moveAttached: boolean;
  37073. /**
  37074. * If the drag behavior will react to drag events (Default: true)
  37075. */
  37076. enabled: boolean;
  37077. /**
  37078. * If camera controls should be detached during the drag
  37079. */
  37080. detachCameraControls: boolean;
  37081. /**
  37082. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37083. */
  37084. useObjectOrienationForDragging: boolean;
  37085. private _options;
  37086. /**
  37087. * Creates a pointer drag behavior that can be attached to a mesh
  37088. * @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)
  37089. */
  37090. constructor(options?: {
  37091. dragAxis?: Vector3;
  37092. dragPlaneNormal?: Vector3;
  37093. });
  37094. /**
  37095. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37096. */
  37097. validateDrag: (targetPosition: Vector3) => boolean;
  37098. /**
  37099. * The name of the behavior
  37100. */
  37101. readonly name: string;
  37102. /**
  37103. * Initializes the behavior
  37104. */
  37105. init(): void;
  37106. private _tmpVector;
  37107. private _alternatePickedPoint;
  37108. private _worldDragAxis;
  37109. private _targetPosition;
  37110. private _attachedElement;
  37111. /**
  37112. * Attaches the drag behavior the passed in mesh
  37113. * @param ownerNode The mesh that will be dragged around once attached
  37114. */
  37115. attach(ownerNode: AbstractMesh): void;
  37116. /**
  37117. * Force relase the drag action by code.
  37118. */
  37119. releaseDrag(): void;
  37120. private _startDragRay;
  37121. private _lastPointerRay;
  37122. /**
  37123. * Simulates the start of a pointer drag event on the behavior
  37124. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37125. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37126. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37127. */
  37128. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37129. private _startDrag;
  37130. private _dragDelta;
  37131. private _moveDrag;
  37132. private _pickWithRayOnDragPlane;
  37133. private _pointA;
  37134. private _pointB;
  37135. private _pointC;
  37136. private _lineA;
  37137. private _lineB;
  37138. private _localAxis;
  37139. private _lookAt;
  37140. private _updateDragPlanePosition;
  37141. /**
  37142. * Detaches the behavior from the mesh
  37143. */
  37144. detach(): void;
  37145. }
  37146. }
  37147. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37148. import { Mesh } from "babylonjs/Meshes/mesh";
  37149. import { Behavior } from "babylonjs/Behaviors/behavior";
  37150. /**
  37151. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37152. */
  37153. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37154. private _dragBehaviorA;
  37155. private _dragBehaviorB;
  37156. private _startDistance;
  37157. private _initialScale;
  37158. private _targetScale;
  37159. private _ownerNode;
  37160. private _sceneRenderObserver;
  37161. /**
  37162. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37163. */
  37164. constructor();
  37165. /**
  37166. * The name of the behavior
  37167. */
  37168. readonly name: string;
  37169. /**
  37170. * Initializes the behavior
  37171. */
  37172. init(): void;
  37173. private _getCurrentDistance;
  37174. /**
  37175. * Attaches the scale behavior the passed in mesh
  37176. * @param ownerNode The mesh that will be scaled around once attached
  37177. */
  37178. attach(ownerNode: Mesh): void;
  37179. /**
  37180. * Detaches the behavior from the mesh
  37181. */
  37182. detach(): void;
  37183. }
  37184. }
  37185. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37186. import { Behavior } from "babylonjs/Behaviors/behavior";
  37187. import { Mesh } from "babylonjs/Meshes/mesh";
  37188. import { Observable } from "babylonjs/Misc/observable";
  37189. /**
  37190. * 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
  37191. */
  37192. export class SixDofDragBehavior implements Behavior<Mesh> {
  37193. private static _virtualScene;
  37194. private _ownerNode;
  37195. private _sceneRenderObserver;
  37196. private _scene;
  37197. private _targetPosition;
  37198. private _virtualOriginMesh;
  37199. private _virtualDragMesh;
  37200. private _pointerObserver;
  37201. private _moving;
  37202. private _startingOrientation;
  37203. /**
  37204. * 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)
  37205. */
  37206. private zDragFactor;
  37207. /**
  37208. * If the object should rotate to face the drag origin
  37209. */
  37210. rotateDraggedObject: boolean;
  37211. /**
  37212. * If the behavior is currently in a dragging state
  37213. */
  37214. dragging: boolean;
  37215. /**
  37216. * 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)
  37217. */
  37218. dragDeltaRatio: number;
  37219. /**
  37220. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37221. */
  37222. currentDraggingPointerID: number;
  37223. /**
  37224. * If camera controls should be detached during the drag
  37225. */
  37226. detachCameraControls: boolean;
  37227. /**
  37228. * Fires each time a drag starts
  37229. */
  37230. onDragStartObservable: Observable<{}>;
  37231. /**
  37232. * Fires each time a drag ends (eg. mouse release after drag)
  37233. */
  37234. onDragEndObservable: Observable<{}>;
  37235. /**
  37236. * 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
  37237. */
  37238. constructor();
  37239. /**
  37240. * The name of the behavior
  37241. */
  37242. readonly name: string;
  37243. /**
  37244. * Initializes the behavior
  37245. */
  37246. init(): void;
  37247. /**
  37248. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37249. */
  37250. private readonly _pointerCamera;
  37251. /**
  37252. * Attaches the scale behavior the passed in mesh
  37253. * @param ownerNode The mesh that will be scaled around once attached
  37254. */
  37255. attach(ownerNode: Mesh): void;
  37256. /**
  37257. * Detaches the behavior from the mesh
  37258. */
  37259. detach(): void;
  37260. }
  37261. }
  37262. declare module "babylonjs/Behaviors/Meshes/index" {
  37263. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37264. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37265. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37266. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37267. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37268. }
  37269. declare module "babylonjs/Behaviors/index" {
  37270. export * from "babylonjs/Behaviors/behavior";
  37271. export * from "babylonjs/Behaviors/Cameras/index";
  37272. export * from "babylonjs/Behaviors/Meshes/index";
  37273. }
  37274. declare module "babylonjs/Bones/boneIKController" {
  37275. import { Bone } from "babylonjs/Bones/bone";
  37276. import { Vector3 } from "babylonjs/Maths/math";
  37277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37278. import { Nullable } from "babylonjs/types";
  37279. /**
  37280. * Class used to apply inverse kinematics to bones
  37281. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37282. */
  37283. export class BoneIKController {
  37284. private static _tmpVecs;
  37285. private static _tmpQuat;
  37286. private static _tmpMats;
  37287. /**
  37288. * Gets or sets the target mesh
  37289. */
  37290. targetMesh: AbstractMesh;
  37291. /** Gets or sets the mesh used as pole */
  37292. poleTargetMesh: AbstractMesh;
  37293. /**
  37294. * Gets or sets the bone used as pole
  37295. */
  37296. poleTargetBone: Nullable<Bone>;
  37297. /**
  37298. * Gets or sets the target position
  37299. */
  37300. targetPosition: Vector3;
  37301. /**
  37302. * Gets or sets the pole target position
  37303. */
  37304. poleTargetPosition: Vector3;
  37305. /**
  37306. * Gets or sets the pole target local offset
  37307. */
  37308. poleTargetLocalOffset: Vector3;
  37309. /**
  37310. * Gets or sets the pole angle
  37311. */
  37312. poleAngle: number;
  37313. /**
  37314. * Gets or sets the mesh associated with the controller
  37315. */
  37316. mesh: AbstractMesh;
  37317. /**
  37318. * 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)
  37319. */
  37320. slerpAmount: number;
  37321. private _bone1Quat;
  37322. private _bone1Mat;
  37323. private _bone2Ang;
  37324. private _bone1;
  37325. private _bone2;
  37326. private _bone1Length;
  37327. private _bone2Length;
  37328. private _maxAngle;
  37329. private _maxReach;
  37330. private _rightHandedSystem;
  37331. private _bendAxis;
  37332. private _slerping;
  37333. private _adjustRoll;
  37334. /**
  37335. * Gets or sets maximum allowed angle
  37336. */
  37337. maxAngle: number;
  37338. /**
  37339. * Creates a new BoneIKController
  37340. * @param mesh defines the mesh to control
  37341. * @param bone defines the bone to control
  37342. * @param options defines options to set up the controller
  37343. */
  37344. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37345. targetMesh?: AbstractMesh;
  37346. poleTargetMesh?: AbstractMesh;
  37347. poleTargetBone?: Bone;
  37348. poleTargetLocalOffset?: Vector3;
  37349. poleAngle?: number;
  37350. bendAxis?: Vector3;
  37351. maxAngle?: number;
  37352. slerpAmount?: number;
  37353. });
  37354. private _setMaxAngle;
  37355. /**
  37356. * Force the controller to update the bones
  37357. */
  37358. update(): void;
  37359. }
  37360. }
  37361. declare module "babylonjs/Bones/boneLookController" {
  37362. import { Vector3, Space } from "babylonjs/Maths/math";
  37363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37364. import { Bone } from "babylonjs/Bones/bone";
  37365. /**
  37366. * Class used to make a bone look toward a point in space
  37367. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37368. */
  37369. export class BoneLookController {
  37370. private static _tmpVecs;
  37371. private static _tmpQuat;
  37372. private static _tmpMats;
  37373. /**
  37374. * The target Vector3 that the bone will look at
  37375. */
  37376. target: Vector3;
  37377. /**
  37378. * The mesh that the bone is attached to
  37379. */
  37380. mesh: AbstractMesh;
  37381. /**
  37382. * The bone that will be looking to the target
  37383. */
  37384. bone: Bone;
  37385. /**
  37386. * The up axis of the coordinate system that is used when the bone is rotated
  37387. */
  37388. upAxis: Vector3;
  37389. /**
  37390. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37391. */
  37392. upAxisSpace: Space;
  37393. /**
  37394. * Used to make an adjustment to the yaw of the bone
  37395. */
  37396. adjustYaw: number;
  37397. /**
  37398. * Used to make an adjustment to the pitch of the bone
  37399. */
  37400. adjustPitch: number;
  37401. /**
  37402. * Used to make an adjustment to the roll of the bone
  37403. */
  37404. adjustRoll: number;
  37405. /**
  37406. * 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)
  37407. */
  37408. slerpAmount: number;
  37409. private _minYaw;
  37410. private _maxYaw;
  37411. private _minPitch;
  37412. private _maxPitch;
  37413. private _minYawSin;
  37414. private _minYawCos;
  37415. private _maxYawSin;
  37416. private _maxYawCos;
  37417. private _midYawConstraint;
  37418. private _minPitchTan;
  37419. private _maxPitchTan;
  37420. private _boneQuat;
  37421. private _slerping;
  37422. private _transformYawPitch;
  37423. private _transformYawPitchInv;
  37424. private _firstFrameSkipped;
  37425. private _yawRange;
  37426. private _fowardAxis;
  37427. /**
  37428. * Gets or sets the minimum yaw angle that the bone can look to
  37429. */
  37430. minYaw: number;
  37431. /**
  37432. * Gets or sets the maximum yaw angle that the bone can look to
  37433. */
  37434. maxYaw: number;
  37435. /**
  37436. * Gets or sets the minimum pitch angle that the bone can look to
  37437. */
  37438. minPitch: number;
  37439. /**
  37440. * Gets or sets the maximum pitch angle that the bone can look to
  37441. */
  37442. maxPitch: number;
  37443. /**
  37444. * Create a BoneLookController
  37445. * @param mesh the mesh that the bone belongs to
  37446. * @param bone the bone that will be looking to the target
  37447. * @param target the target Vector3 to look at
  37448. * @param options optional settings:
  37449. * * maxYaw: the maximum angle the bone will yaw to
  37450. * * minYaw: the minimum angle the bone will yaw to
  37451. * * maxPitch: the maximum angle the bone will pitch to
  37452. * * minPitch: the minimum angle the bone will yaw to
  37453. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37454. * * upAxis: the up axis of the coordinate system
  37455. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37456. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37457. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37458. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37459. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37460. * * adjustRoll: used to make an adjustment to the roll of the bone
  37461. **/
  37462. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37463. maxYaw?: number;
  37464. minYaw?: number;
  37465. maxPitch?: number;
  37466. minPitch?: number;
  37467. slerpAmount?: number;
  37468. upAxis?: Vector3;
  37469. upAxisSpace?: Space;
  37470. yawAxis?: Vector3;
  37471. pitchAxis?: Vector3;
  37472. adjustYaw?: number;
  37473. adjustPitch?: number;
  37474. adjustRoll?: number;
  37475. });
  37476. /**
  37477. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37478. */
  37479. update(): void;
  37480. private _getAngleDiff;
  37481. private _getAngleBetween;
  37482. private _isAngleBetween;
  37483. }
  37484. }
  37485. declare module "babylonjs/Bones/index" {
  37486. export * from "babylonjs/Bones/bone";
  37487. export * from "babylonjs/Bones/boneIKController";
  37488. export * from "babylonjs/Bones/boneLookController";
  37489. export * from "babylonjs/Bones/skeleton";
  37490. }
  37491. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37492. import { Nullable } from "babylonjs/types";
  37493. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37494. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37495. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37496. /**
  37497. * Manage the gamepad inputs to control an arc rotate camera.
  37498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37499. */
  37500. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37501. /**
  37502. * Defines the camera the input is attached to.
  37503. */
  37504. camera: ArcRotateCamera;
  37505. /**
  37506. * Defines the gamepad the input is gathering event from.
  37507. */
  37508. gamepad: Nullable<Gamepad>;
  37509. /**
  37510. * Defines the gamepad rotation sensiblity.
  37511. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37512. */
  37513. gamepadRotationSensibility: number;
  37514. /**
  37515. * Defines the gamepad move sensiblity.
  37516. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37517. */
  37518. gamepadMoveSensibility: number;
  37519. private _onGamepadConnectedObserver;
  37520. private _onGamepadDisconnectedObserver;
  37521. /**
  37522. * Attach the input controls to a specific dom element to get the input from.
  37523. * @param element Defines the element the controls should be listened from
  37524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37525. */
  37526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37527. /**
  37528. * Detach the current controls from the specified dom element.
  37529. * @param element Defines the element to stop listening the inputs from
  37530. */
  37531. detachControl(element: Nullable<HTMLElement>): void;
  37532. /**
  37533. * Update the current camera state depending on the inputs that have been used this frame.
  37534. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37535. */
  37536. checkInputs(): void;
  37537. /**
  37538. * Gets the class name of the current intput.
  37539. * @returns the class name
  37540. */
  37541. getClassName(): string;
  37542. /**
  37543. * Get the friendly name associated with the input class.
  37544. * @returns the input friendly name
  37545. */
  37546. getSimpleName(): string;
  37547. }
  37548. }
  37549. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37550. import { Nullable } from "babylonjs/types";
  37551. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37552. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37553. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37554. interface ArcRotateCameraInputsManager {
  37555. /**
  37556. * Add orientation input support to the input manager.
  37557. * @returns the current input manager
  37558. */
  37559. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37560. }
  37561. }
  37562. /**
  37563. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37565. */
  37566. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37567. /**
  37568. * Defines the camera the input is attached to.
  37569. */
  37570. camera: ArcRotateCamera;
  37571. /**
  37572. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37573. */
  37574. alphaCorrection: number;
  37575. /**
  37576. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37577. */
  37578. gammaCorrection: number;
  37579. private _alpha;
  37580. private _gamma;
  37581. private _dirty;
  37582. private _deviceOrientationHandler;
  37583. /**
  37584. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37585. */
  37586. constructor();
  37587. /**
  37588. * Attach the input controls to a specific dom element to get the input from.
  37589. * @param element Defines the element the controls should be listened from
  37590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37591. */
  37592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37593. /** @hidden */
  37594. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37595. /**
  37596. * Update the current camera state depending on the inputs that have been used this frame.
  37597. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37598. */
  37599. checkInputs(): void;
  37600. /**
  37601. * Detach the current controls from the specified dom element.
  37602. * @param element Defines the element to stop listening the inputs from
  37603. */
  37604. detachControl(element: Nullable<HTMLElement>): void;
  37605. /**
  37606. * Gets the class name of the current intput.
  37607. * @returns the class name
  37608. */
  37609. getClassName(): string;
  37610. /**
  37611. * Get the friendly name associated with the input class.
  37612. * @returns the input friendly name
  37613. */
  37614. getSimpleName(): string;
  37615. }
  37616. }
  37617. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37618. import { Nullable } from "babylonjs/types";
  37619. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37620. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37621. /**
  37622. * Listen to mouse events to control the camera.
  37623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37624. */
  37625. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37626. /**
  37627. * Defines the camera the input is attached to.
  37628. */
  37629. camera: FlyCamera;
  37630. /**
  37631. * Defines if touch is enabled. (Default is true.)
  37632. */
  37633. touchEnabled: boolean;
  37634. /**
  37635. * Defines the buttons associated with the input to handle camera rotation.
  37636. */
  37637. buttons: number[];
  37638. /**
  37639. * Assign buttons for Yaw control.
  37640. */
  37641. buttonsYaw: number[];
  37642. /**
  37643. * Assign buttons for Pitch control.
  37644. */
  37645. buttonsPitch: number[];
  37646. /**
  37647. * Assign buttons for Roll control.
  37648. */
  37649. buttonsRoll: number[];
  37650. /**
  37651. * Detect if any button is being pressed while mouse is moved.
  37652. * -1 = Mouse locked.
  37653. * 0 = Left button.
  37654. * 1 = Middle Button.
  37655. * 2 = Right Button.
  37656. */
  37657. activeButton: number;
  37658. /**
  37659. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37660. * Higher values reduce its sensitivity.
  37661. */
  37662. angularSensibility: number;
  37663. private _mousemoveCallback;
  37664. private _observer;
  37665. private _rollObserver;
  37666. private previousPosition;
  37667. private noPreventDefault;
  37668. private element;
  37669. /**
  37670. * Listen to mouse events to control the camera.
  37671. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37673. */
  37674. constructor(touchEnabled?: boolean);
  37675. /**
  37676. * Attach the mouse control to the HTML DOM element.
  37677. * @param element Defines the element that listens to the input events.
  37678. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37679. */
  37680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37681. /**
  37682. * Detach the current controls from the specified dom element.
  37683. * @param element Defines the element to stop listening the inputs from
  37684. */
  37685. detachControl(element: Nullable<HTMLElement>): void;
  37686. /**
  37687. * Gets the class name of the current input.
  37688. * @returns the class name.
  37689. */
  37690. getClassName(): string;
  37691. /**
  37692. * Get the friendly name associated with the input class.
  37693. * @returns the input's friendly name.
  37694. */
  37695. getSimpleName(): string;
  37696. private _pointerInput;
  37697. private _onMouseMove;
  37698. /**
  37699. * Rotate camera by mouse offset.
  37700. */
  37701. private rotateCamera;
  37702. }
  37703. }
  37704. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37705. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37706. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37707. /**
  37708. * Default Inputs manager for the FlyCamera.
  37709. * It groups all the default supported inputs for ease of use.
  37710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37711. */
  37712. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37713. /**
  37714. * Instantiates a new FlyCameraInputsManager.
  37715. * @param camera Defines the camera the inputs belong to.
  37716. */
  37717. constructor(camera: FlyCamera);
  37718. /**
  37719. * Add keyboard input support to the input manager.
  37720. * @returns the new FlyCameraKeyboardMoveInput().
  37721. */
  37722. addKeyboard(): FlyCameraInputsManager;
  37723. /**
  37724. * Add mouse input support to the input manager.
  37725. * @param touchEnabled Enable touch screen support.
  37726. * @returns the new FlyCameraMouseInput().
  37727. */
  37728. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37729. }
  37730. }
  37731. declare module "babylonjs/Cameras/flyCamera" {
  37732. import { Scene } from "babylonjs/scene";
  37733. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37735. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37736. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37737. /**
  37738. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37739. * such as in a 3D Space Shooter or a Flight Simulator.
  37740. */
  37741. export class FlyCamera extends TargetCamera {
  37742. /**
  37743. * Define the collision ellipsoid of the camera.
  37744. * This is helpful for simulating a camera body, like a player's body.
  37745. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37746. */
  37747. ellipsoid: Vector3;
  37748. /**
  37749. * Define an offset for the position of the ellipsoid around the camera.
  37750. * This can be helpful if the camera is attached away from the player's body center,
  37751. * such as at its head.
  37752. */
  37753. ellipsoidOffset: Vector3;
  37754. /**
  37755. * Enable or disable collisions of the camera with the rest of the scene objects.
  37756. */
  37757. checkCollisions: boolean;
  37758. /**
  37759. * Enable or disable gravity on the camera.
  37760. */
  37761. applyGravity: boolean;
  37762. /**
  37763. * Define the current direction the camera is moving to.
  37764. */
  37765. cameraDirection: Vector3;
  37766. /**
  37767. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37768. * This overrides and empties cameraRotation.
  37769. */
  37770. rotationQuaternion: Quaternion;
  37771. /**
  37772. * Track Roll to maintain the wanted Rolling when looking around.
  37773. */
  37774. _trackRoll: number;
  37775. /**
  37776. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37777. */
  37778. rollCorrect: number;
  37779. /**
  37780. * Mimic a banked turn, Rolling the camera when Yawing.
  37781. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37782. */
  37783. bankedTurn: boolean;
  37784. /**
  37785. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37786. */
  37787. bankedTurnLimit: number;
  37788. /**
  37789. * Value of 0 disables the banked Roll.
  37790. * Value of 1 is equal to the Yaw angle in radians.
  37791. */
  37792. bankedTurnMultiplier: number;
  37793. /**
  37794. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37795. */
  37796. inputs: FlyCameraInputsManager;
  37797. /**
  37798. * Gets the input sensibility for mouse input.
  37799. * Higher values reduce sensitivity.
  37800. */
  37801. /**
  37802. * Sets the input sensibility for a mouse input.
  37803. * Higher values reduce sensitivity.
  37804. */
  37805. angularSensibility: number;
  37806. /**
  37807. * Get the keys for camera movement forward.
  37808. */
  37809. /**
  37810. * Set the keys for camera movement forward.
  37811. */
  37812. keysForward: number[];
  37813. /**
  37814. * Get the keys for camera movement backward.
  37815. */
  37816. keysBackward: number[];
  37817. /**
  37818. * Get the keys for camera movement up.
  37819. */
  37820. /**
  37821. * Set the keys for camera movement up.
  37822. */
  37823. keysUp: number[];
  37824. /**
  37825. * Get the keys for camera movement down.
  37826. */
  37827. /**
  37828. * Set the keys for camera movement down.
  37829. */
  37830. keysDown: number[];
  37831. /**
  37832. * Get the keys for camera movement left.
  37833. */
  37834. /**
  37835. * Set the keys for camera movement left.
  37836. */
  37837. keysLeft: number[];
  37838. /**
  37839. * Set the keys for camera movement right.
  37840. */
  37841. /**
  37842. * Set the keys for camera movement right.
  37843. */
  37844. keysRight: number[];
  37845. /**
  37846. * Event raised when the camera collides with a mesh in the scene.
  37847. */
  37848. onCollide: (collidedMesh: AbstractMesh) => void;
  37849. private _collider;
  37850. private _needMoveForGravity;
  37851. private _oldPosition;
  37852. private _diffPosition;
  37853. private _newPosition;
  37854. /** @hidden */
  37855. _localDirection: Vector3;
  37856. /** @hidden */
  37857. _transformedDirection: Vector3;
  37858. /**
  37859. * Instantiates a FlyCamera.
  37860. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37861. * such as in a 3D Space Shooter or a Flight Simulator.
  37862. * @param name Define the name of the camera in the scene.
  37863. * @param position Define the starting position of the camera in the scene.
  37864. * @param scene Define the scene the camera belongs to.
  37865. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37866. */
  37867. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37868. /**
  37869. * Attach a control to the HTML DOM element.
  37870. * @param element Defines the element that listens to the input events.
  37871. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37872. */
  37873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37874. /**
  37875. * Detach a control from the HTML DOM element.
  37876. * The camera will stop reacting to that input.
  37877. * @param element Defines the element that listens to the input events.
  37878. */
  37879. detachControl(element: HTMLElement): void;
  37880. private _collisionMask;
  37881. /**
  37882. * Get the mask that the camera ignores in collision events.
  37883. */
  37884. /**
  37885. * Set the mask that the camera ignores in collision events.
  37886. */
  37887. collisionMask: number;
  37888. /** @hidden */
  37889. _collideWithWorld(displacement: Vector3): void;
  37890. /** @hidden */
  37891. private _onCollisionPositionChange;
  37892. /** @hidden */
  37893. _checkInputs(): void;
  37894. /** @hidden */
  37895. _decideIfNeedsToMove(): boolean;
  37896. /** @hidden */
  37897. _updatePosition(): void;
  37898. /**
  37899. * Restore the Roll to its target value at the rate specified.
  37900. * @param rate - Higher means slower restoring.
  37901. * @hidden
  37902. */
  37903. restoreRoll(rate: number): void;
  37904. /**
  37905. * Destroy the camera and release the current resources held by it.
  37906. */
  37907. dispose(): void;
  37908. /**
  37909. * Get the current object class name.
  37910. * @returns the class name.
  37911. */
  37912. getClassName(): string;
  37913. }
  37914. }
  37915. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37916. import { Nullable } from "babylonjs/types";
  37917. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37918. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37919. /**
  37920. * Listen to keyboard events to control the camera.
  37921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37922. */
  37923. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37924. /**
  37925. * Defines the camera the input is attached to.
  37926. */
  37927. camera: FlyCamera;
  37928. /**
  37929. * The list of keyboard keys used to control the forward move of the camera.
  37930. */
  37931. keysForward: number[];
  37932. /**
  37933. * The list of keyboard keys used to control the backward move of the camera.
  37934. */
  37935. keysBackward: number[];
  37936. /**
  37937. * The list of keyboard keys used to control the forward move of the camera.
  37938. */
  37939. keysUp: number[];
  37940. /**
  37941. * The list of keyboard keys used to control the backward move of the camera.
  37942. */
  37943. keysDown: number[];
  37944. /**
  37945. * The list of keyboard keys used to control the right strafe move of the camera.
  37946. */
  37947. keysRight: number[];
  37948. /**
  37949. * The list of keyboard keys used to control the left strafe move of the camera.
  37950. */
  37951. keysLeft: number[];
  37952. private _keys;
  37953. private _onCanvasBlurObserver;
  37954. private _onKeyboardObserver;
  37955. private _engine;
  37956. private _scene;
  37957. /**
  37958. * Attach the input controls to a specific dom element to get the input from.
  37959. * @param element Defines the element the controls should be listened from
  37960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37961. */
  37962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37963. /**
  37964. * Detach the current controls from the specified dom element.
  37965. * @param element Defines the element to stop listening the inputs from
  37966. */
  37967. detachControl(element: Nullable<HTMLElement>): void;
  37968. /**
  37969. * Gets the class name of the current intput.
  37970. * @returns the class name
  37971. */
  37972. getClassName(): string;
  37973. /** @hidden */
  37974. _onLostFocus(e: FocusEvent): void;
  37975. /**
  37976. * Get the friendly name associated with the input class.
  37977. * @returns the input friendly name
  37978. */
  37979. getSimpleName(): string;
  37980. /**
  37981. * Update the current camera state depending on the inputs that have been used this frame.
  37982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37983. */
  37984. checkInputs(): void;
  37985. }
  37986. }
  37987. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37988. import { Nullable } from "babylonjs/types";
  37989. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37990. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37991. /**
  37992. * Manage the mouse wheel inputs to control a follow camera.
  37993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37994. */
  37995. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37996. /**
  37997. * Defines the camera the input is attached to.
  37998. */
  37999. camera: FollowCamera;
  38000. /**
  38001. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38002. */
  38003. axisControlRadius: boolean;
  38004. /**
  38005. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38006. */
  38007. axisControlHeight: boolean;
  38008. /**
  38009. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38010. */
  38011. axisControlRotation: boolean;
  38012. /**
  38013. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38014. * relation to mouseWheel events.
  38015. */
  38016. wheelPrecision: number;
  38017. /**
  38018. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38019. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38020. */
  38021. wheelDeltaPercentage: number;
  38022. private _wheel;
  38023. private _observer;
  38024. /**
  38025. * Attach the input controls to a specific dom element to get the input from.
  38026. * @param element Defines the element the controls should be listened from
  38027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38028. */
  38029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38030. /**
  38031. * Detach the current controls from the specified dom element.
  38032. * @param element Defines the element to stop listening the inputs from
  38033. */
  38034. detachControl(element: Nullable<HTMLElement>): void;
  38035. /**
  38036. * Gets the class name of the current intput.
  38037. * @returns the class name
  38038. */
  38039. getClassName(): string;
  38040. /**
  38041. * Get the friendly name associated with the input class.
  38042. * @returns the input friendly name
  38043. */
  38044. getSimpleName(): string;
  38045. }
  38046. }
  38047. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38048. import { Nullable } from "babylonjs/types";
  38049. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38050. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38051. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38052. /**
  38053. * Manage the pointers inputs to control an follow camera.
  38054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38055. */
  38056. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38057. /**
  38058. * Defines the camera the input is attached to.
  38059. */
  38060. camera: FollowCamera;
  38061. /**
  38062. * Gets the class name of the current input.
  38063. * @returns the class name
  38064. */
  38065. getClassName(): string;
  38066. /**
  38067. * Defines the pointer angular sensibility along the X axis or how fast is
  38068. * the camera rotating.
  38069. * A negative number will reverse the axis direction.
  38070. */
  38071. angularSensibilityX: number;
  38072. /**
  38073. * Defines the pointer angular sensibility along the Y axis or how fast is
  38074. * the camera rotating.
  38075. * A negative number will reverse the axis direction.
  38076. */
  38077. angularSensibilityY: number;
  38078. /**
  38079. * Defines the pointer pinch precision or how fast is the camera zooming.
  38080. * A negative number will reverse the axis direction.
  38081. */
  38082. pinchPrecision: number;
  38083. /**
  38084. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38085. * from 0.
  38086. * It defines the percentage of current camera.radius to use as delta when
  38087. * pinch zoom is used.
  38088. */
  38089. pinchDeltaPercentage: number;
  38090. /**
  38091. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38092. */
  38093. axisXControlRadius: boolean;
  38094. /**
  38095. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38096. */
  38097. axisXControlHeight: boolean;
  38098. /**
  38099. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38100. */
  38101. axisXControlRotation: boolean;
  38102. /**
  38103. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38104. */
  38105. axisYControlRadius: boolean;
  38106. /**
  38107. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38108. */
  38109. axisYControlHeight: boolean;
  38110. /**
  38111. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38112. */
  38113. axisYControlRotation: boolean;
  38114. /**
  38115. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38116. */
  38117. axisPinchControlRadius: boolean;
  38118. /**
  38119. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38120. */
  38121. axisPinchControlHeight: boolean;
  38122. /**
  38123. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38124. */
  38125. axisPinchControlRotation: boolean;
  38126. /**
  38127. * Log error messages if basic misconfiguration has occurred.
  38128. */
  38129. warningEnable: boolean;
  38130. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38131. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38132. private _warningCounter;
  38133. private _warning;
  38134. }
  38135. }
  38136. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38137. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38138. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38139. /**
  38140. * Default Inputs manager for the FollowCamera.
  38141. * It groups all the default supported inputs for ease of use.
  38142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38143. */
  38144. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38145. /**
  38146. * Instantiates a new FollowCameraInputsManager.
  38147. * @param camera Defines the camera the inputs belong to
  38148. */
  38149. constructor(camera: FollowCamera);
  38150. /**
  38151. * Add keyboard input support to the input manager.
  38152. * @returns the current input manager
  38153. */
  38154. addKeyboard(): FollowCameraInputsManager;
  38155. /**
  38156. * Add mouse wheel input support to the input manager.
  38157. * @returns the current input manager
  38158. */
  38159. addMouseWheel(): FollowCameraInputsManager;
  38160. /**
  38161. * Add pointers input support to the input manager.
  38162. * @returns the current input manager
  38163. */
  38164. addPointers(): FollowCameraInputsManager;
  38165. /**
  38166. * Add orientation input support to the input manager.
  38167. * @returns the current input manager
  38168. */
  38169. addVRDeviceOrientation(): FollowCameraInputsManager;
  38170. }
  38171. }
  38172. declare module "babylonjs/Cameras/followCamera" {
  38173. import { Nullable } from "babylonjs/types";
  38174. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38175. import { Scene } from "babylonjs/scene";
  38176. import { Vector3 } from "babylonjs/Maths/math";
  38177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38178. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38179. /**
  38180. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38181. * an arc rotate version arcFollowCamera are available.
  38182. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38183. */
  38184. export class FollowCamera extends TargetCamera {
  38185. /**
  38186. * Distance the follow camera should follow an object at
  38187. */
  38188. radius: number;
  38189. /**
  38190. * Minimum allowed distance of the camera to the axis of rotation
  38191. * (The camera can not get closer).
  38192. * This can help limiting how the Camera is able to move in the scene.
  38193. */
  38194. lowerRadiusLimit: Nullable<number>;
  38195. /**
  38196. * Maximum allowed distance of the camera to the axis of rotation
  38197. * (The camera can not get further).
  38198. * This can help limiting how the Camera is able to move in the scene.
  38199. */
  38200. upperRadiusLimit: Nullable<number>;
  38201. /**
  38202. * Define a rotation offset between the camera and the object it follows
  38203. */
  38204. rotationOffset: number;
  38205. /**
  38206. * Minimum allowed angle to camera position relative to target object.
  38207. * This can help limiting how the Camera is able to move in the scene.
  38208. */
  38209. lowerRotationOffsetLimit: Nullable<number>;
  38210. /**
  38211. * Maximum allowed angle to camera position relative to target object.
  38212. * This can help limiting how the Camera is able to move in the scene.
  38213. */
  38214. upperRotationOffsetLimit: Nullable<number>;
  38215. /**
  38216. * Define a height offset between the camera and the object it follows.
  38217. * It can help following an object from the top (like a car chaing a plane)
  38218. */
  38219. heightOffset: number;
  38220. /**
  38221. * Minimum allowed height of camera position relative to target object.
  38222. * This can help limiting how the Camera is able to move in the scene.
  38223. */
  38224. lowerHeightOffsetLimit: Nullable<number>;
  38225. /**
  38226. * Maximum allowed height of camera position relative to target object.
  38227. * This can help limiting how the Camera is able to move in the scene.
  38228. */
  38229. upperHeightOffsetLimit: Nullable<number>;
  38230. /**
  38231. * Define how fast the camera can accelerate to follow it s target.
  38232. */
  38233. cameraAcceleration: number;
  38234. /**
  38235. * Define the speed limit of the camera following an object.
  38236. */
  38237. maxCameraSpeed: number;
  38238. /**
  38239. * Define the target of the camera.
  38240. */
  38241. lockedTarget: Nullable<AbstractMesh>;
  38242. /**
  38243. * Defines the input associated with the camera.
  38244. */
  38245. inputs: FollowCameraInputsManager;
  38246. /**
  38247. * Instantiates the follow camera.
  38248. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38249. * @param name Define the name of the camera in the scene
  38250. * @param position Define the position of the camera
  38251. * @param scene Define the scene the camera belong to
  38252. * @param lockedTarget Define the target of the camera
  38253. */
  38254. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38255. private _follow;
  38256. /**
  38257. * Attached controls to the current camera.
  38258. * @param element Defines the element the controls should be listened from
  38259. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38260. */
  38261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38262. /**
  38263. * Detach the current controls from the camera.
  38264. * The camera will stop reacting to inputs.
  38265. * @param element Defines the element to stop listening the inputs from
  38266. */
  38267. detachControl(element: HTMLElement): void;
  38268. /** @hidden */
  38269. _checkInputs(): void;
  38270. private _checkLimits;
  38271. /**
  38272. * Gets the camera class name.
  38273. * @returns the class name
  38274. */
  38275. getClassName(): string;
  38276. }
  38277. /**
  38278. * Arc Rotate version of the follow camera.
  38279. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38280. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38281. */
  38282. export class ArcFollowCamera extends TargetCamera {
  38283. /** The longitudinal angle of the camera */
  38284. alpha: number;
  38285. /** The latitudinal angle of the camera */
  38286. beta: number;
  38287. /** The radius of the camera from its target */
  38288. radius: number;
  38289. /** Define the camera target (the messh it should follow) */
  38290. target: Nullable<AbstractMesh>;
  38291. private _cartesianCoordinates;
  38292. /**
  38293. * Instantiates a new ArcFollowCamera
  38294. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38295. * @param name Define the name of the camera
  38296. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38297. * @param beta Define the rotation angle of the camera around the elevation axis
  38298. * @param radius Define the radius of the camera from its target point
  38299. * @param target Define the target of the camera
  38300. * @param scene Define the scene the camera belongs to
  38301. */
  38302. constructor(name: string,
  38303. /** The longitudinal angle of the camera */
  38304. alpha: number,
  38305. /** The latitudinal angle of the camera */
  38306. beta: number,
  38307. /** The radius of the camera from its target */
  38308. radius: number,
  38309. /** Define the camera target (the messh it should follow) */
  38310. target: Nullable<AbstractMesh>, scene: Scene);
  38311. private _follow;
  38312. /** @hidden */
  38313. _checkInputs(): void;
  38314. /**
  38315. * Returns the class name of the object.
  38316. * It is mostly used internally for serialization purposes.
  38317. */
  38318. getClassName(): string;
  38319. }
  38320. }
  38321. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38322. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38323. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38324. import { Nullable } from "babylonjs/types";
  38325. /**
  38326. * Manage the keyboard inputs to control the movement of a follow camera.
  38327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38328. */
  38329. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38330. /**
  38331. * Defines the camera the input is attached to.
  38332. */
  38333. camera: FollowCamera;
  38334. /**
  38335. * Defines the list of key codes associated with the up action (increase heightOffset)
  38336. */
  38337. keysHeightOffsetIncr: number[];
  38338. /**
  38339. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38340. */
  38341. keysHeightOffsetDecr: number[];
  38342. /**
  38343. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38344. */
  38345. keysHeightOffsetModifierAlt: boolean;
  38346. /**
  38347. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38348. */
  38349. keysHeightOffsetModifierCtrl: boolean;
  38350. /**
  38351. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38352. */
  38353. keysHeightOffsetModifierShift: boolean;
  38354. /**
  38355. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38356. */
  38357. keysRotationOffsetIncr: number[];
  38358. /**
  38359. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38360. */
  38361. keysRotationOffsetDecr: number[];
  38362. /**
  38363. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38364. */
  38365. keysRotationOffsetModifierAlt: boolean;
  38366. /**
  38367. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38368. */
  38369. keysRotationOffsetModifierCtrl: boolean;
  38370. /**
  38371. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38372. */
  38373. keysRotationOffsetModifierShift: boolean;
  38374. /**
  38375. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38376. */
  38377. keysRadiusIncr: number[];
  38378. /**
  38379. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38380. */
  38381. keysRadiusDecr: number[];
  38382. /**
  38383. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38384. */
  38385. keysRadiusModifierAlt: boolean;
  38386. /**
  38387. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38388. */
  38389. keysRadiusModifierCtrl: boolean;
  38390. /**
  38391. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38392. */
  38393. keysRadiusModifierShift: boolean;
  38394. /**
  38395. * Defines the rate of change of heightOffset.
  38396. */
  38397. heightSensibility: number;
  38398. /**
  38399. * Defines the rate of change of rotationOffset.
  38400. */
  38401. rotationSensibility: number;
  38402. /**
  38403. * Defines the rate of change of radius.
  38404. */
  38405. radiusSensibility: number;
  38406. private _keys;
  38407. private _ctrlPressed;
  38408. private _altPressed;
  38409. private _shiftPressed;
  38410. private _onCanvasBlurObserver;
  38411. private _onKeyboardObserver;
  38412. private _engine;
  38413. private _scene;
  38414. /**
  38415. * Attach the input controls to a specific dom element to get the input from.
  38416. * @param element Defines the element the controls should be listened from
  38417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38418. */
  38419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38420. /**
  38421. * Detach the current controls from the specified dom element.
  38422. * @param element Defines the element to stop listening the inputs from
  38423. */
  38424. detachControl(element: Nullable<HTMLElement>): void;
  38425. /**
  38426. * Update the current camera state depending on the inputs that have been used this frame.
  38427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38428. */
  38429. checkInputs(): void;
  38430. /**
  38431. * Gets the class name of the current input.
  38432. * @returns the class name
  38433. */
  38434. getClassName(): string;
  38435. /**
  38436. * Get the friendly name associated with the input class.
  38437. * @returns the input friendly name
  38438. */
  38439. getSimpleName(): string;
  38440. /**
  38441. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38442. * allow modification of the heightOffset value.
  38443. */
  38444. private _modifierHeightOffset;
  38445. /**
  38446. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38447. * allow modification of the rotationOffset value.
  38448. */
  38449. private _modifierRotationOffset;
  38450. /**
  38451. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38452. * allow modification of the radius value.
  38453. */
  38454. private _modifierRadius;
  38455. }
  38456. }
  38457. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38458. import { Nullable } from "babylonjs/types";
  38459. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38460. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38461. import { Observable } from "babylonjs/Misc/observable";
  38462. module "babylonjs/Cameras/freeCameraInputsManager" {
  38463. interface FreeCameraInputsManager {
  38464. /**
  38465. * @hidden
  38466. */
  38467. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38468. /**
  38469. * Add orientation input support to the input manager.
  38470. * @returns the current input manager
  38471. */
  38472. addDeviceOrientation(): FreeCameraInputsManager;
  38473. }
  38474. }
  38475. /**
  38476. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38477. * Screen rotation is taken into account.
  38478. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38479. */
  38480. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38481. private _camera;
  38482. private _screenOrientationAngle;
  38483. private _constantTranform;
  38484. private _screenQuaternion;
  38485. private _alpha;
  38486. private _beta;
  38487. private _gamma;
  38488. /**
  38489. * Can be used to detect if a device orientation sensor is availible on a device
  38490. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38491. * @returns a promise that will resolve on orientation change
  38492. */
  38493. static WaitForOrientationChangeAsync(timeout?: number): Promise<{}>;
  38494. /**
  38495. * @hidden
  38496. */
  38497. _onDeviceOrientationChangedObservable: Observable<void>;
  38498. /**
  38499. * Instantiates a new input
  38500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38501. */
  38502. constructor();
  38503. /**
  38504. * Define the camera controlled by the input.
  38505. */
  38506. camera: FreeCamera;
  38507. /**
  38508. * Attach the input controls to a specific dom element to get the input from.
  38509. * @param element Defines the element the controls should be listened from
  38510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38511. */
  38512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38513. private _orientationChanged;
  38514. private _deviceOrientation;
  38515. /**
  38516. * Detach the current controls from the specified dom element.
  38517. * @param element Defines the element to stop listening the inputs from
  38518. */
  38519. detachControl(element: Nullable<HTMLElement>): void;
  38520. /**
  38521. * Update the current camera state depending on the inputs that have been used this frame.
  38522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38523. */
  38524. checkInputs(): void;
  38525. /**
  38526. * Gets the class name of the current intput.
  38527. * @returns the class name
  38528. */
  38529. getClassName(): string;
  38530. /**
  38531. * Get the friendly name associated with the input class.
  38532. * @returns the input friendly name
  38533. */
  38534. getSimpleName(): string;
  38535. }
  38536. }
  38537. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38538. import { Nullable } from "babylonjs/types";
  38539. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38540. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38541. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38542. /**
  38543. * Manage the gamepad inputs to control a free camera.
  38544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38545. */
  38546. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38547. /**
  38548. * Define the camera the input is attached to.
  38549. */
  38550. camera: FreeCamera;
  38551. /**
  38552. * Define the Gamepad controlling the input
  38553. */
  38554. gamepad: Nullable<Gamepad>;
  38555. /**
  38556. * Defines the gamepad rotation sensiblity.
  38557. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38558. */
  38559. gamepadAngularSensibility: number;
  38560. /**
  38561. * Defines the gamepad move sensiblity.
  38562. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38563. */
  38564. gamepadMoveSensibility: number;
  38565. private _onGamepadConnectedObserver;
  38566. private _onGamepadDisconnectedObserver;
  38567. private _cameraTransform;
  38568. private _deltaTransform;
  38569. private _vector3;
  38570. private _vector2;
  38571. /**
  38572. * Attach the input controls to a specific dom element to get the input from.
  38573. * @param element Defines the element the controls should be listened from
  38574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38575. */
  38576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38577. /**
  38578. * Detach the current controls from the specified dom element.
  38579. * @param element Defines the element to stop listening the inputs from
  38580. */
  38581. detachControl(element: Nullable<HTMLElement>): void;
  38582. /**
  38583. * Update the current camera state depending on the inputs that have been used this frame.
  38584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38585. */
  38586. checkInputs(): void;
  38587. /**
  38588. * Gets the class name of the current intput.
  38589. * @returns the class name
  38590. */
  38591. getClassName(): string;
  38592. /**
  38593. * Get the friendly name associated with the input class.
  38594. * @returns the input friendly name
  38595. */
  38596. getSimpleName(): string;
  38597. }
  38598. }
  38599. declare module "babylonjs/Misc/virtualJoystick" {
  38600. import { Nullable } from "babylonjs/types";
  38601. import { Vector3 } from "babylonjs/Maths/math";
  38602. /**
  38603. * Defines the potential axis of a Joystick
  38604. */
  38605. export enum JoystickAxis {
  38606. /** X axis */
  38607. X = 0,
  38608. /** Y axis */
  38609. Y = 1,
  38610. /** Z axis */
  38611. Z = 2
  38612. }
  38613. /**
  38614. * Class used to define virtual joystick (used in touch mode)
  38615. */
  38616. export class VirtualJoystick {
  38617. /**
  38618. * Gets or sets a boolean indicating that left and right values must be inverted
  38619. */
  38620. reverseLeftRight: boolean;
  38621. /**
  38622. * Gets or sets a boolean indicating that up and down values must be inverted
  38623. */
  38624. reverseUpDown: boolean;
  38625. /**
  38626. * Gets the offset value for the position (ie. the change of the position value)
  38627. */
  38628. deltaPosition: Vector3;
  38629. /**
  38630. * Gets a boolean indicating if the virtual joystick was pressed
  38631. */
  38632. pressed: boolean;
  38633. /**
  38634. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38635. */
  38636. static Canvas: Nullable<HTMLCanvasElement>;
  38637. private static _globalJoystickIndex;
  38638. private static vjCanvasContext;
  38639. private static vjCanvasWidth;
  38640. private static vjCanvasHeight;
  38641. private static halfWidth;
  38642. private _action;
  38643. private _axisTargetedByLeftAndRight;
  38644. private _axisTargetedByUpAndDown;
  38645. private _joystickSensibility;
  38646. private _inversedSensibility;
  38647. private _joystickPointerID;
  38648. private _joystickColor;
  38649. private _joystickPointerPos;
  38650. private _joystickPreviousPointerPos;
  38651. private _joystickPointerStartPos;
  38652. private _deltaJoystickVector;
  38653. private _leftJoystick;
  38654. private _touches;
  38655. private _onPointerDownHandlerRef;
  38656. private _onPointerMoveHandlerRef;
  38657. private _onPointerUpHandlerRef;
  38658. private _onResize;
  38659. /**
  38660. * Creates a new virtual joystick
  38661. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38662. */
  38663. constructor(leftJoystick?: boolean);
  38664. /**
  38665. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38666. * @param newJoystickSensibility defines the new sensibility
  38667. */
  38668. setJoystickSensibility(newJoystickSensibility: number): void;
  38669. private _onPointerDown;
  38670. private _onPointerMove;
  38671. private _onPointerUp;
  38672. /**
  38673. * Change the color of the virtual joystick
  38674. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38675. */
  38676. setJoystickColor(newColor: string): void;
  38677. /**
  38678. * Defines a callback to call when the joystick is touched
  38679. * @param action defines the callback
  38680. */
  38681. setActionOnTouch(action: () => any): void;
  38682. /**
  38683. * Defines which axis you'd like to control for left & right
  38684. * @param axis defines the axis to use
  38685. */
  38686. setAxisForLeftRight(axis: JoystickAxis): void;
  38687. /**
  38688. * Defines which axis you'd like to control for up & down
  38689. * @param axis defines the axis to use
  38690. */
  38691. setAxisForUpDown(axis: JoystickAxis): void;
  38692. private _drawVirtualJoystick;
  38693. /**
  38694. * Release internal HTML canvas
  38695. */
  38696. releaseCanvas(): void;
  38697. }
  38698. }
  38699. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38700. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38701. import { Nullable } from "babylonjs/types";
  38702. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38703. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38704. module "babylonjs/Cameras/freeCameraInputsManager" {
  38705. interface FreeCameraInputsManager {
  38706. /**
  38707. * Add virtual joystick input support to the input manager.
  38708. * @returns the current input manager
  38709. */
  38710. addVirtualJoystick(): FreeCameraInputsManager;
  38711. }
  38712. }
  38713. /**
  38714. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38716. */
  38717. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38718. /**
  38719. * Defines the camera the input is attached to.
  38720. */
  38721. camera: FreeCamera;
  38722. private _leftjoystick;
  38723. private _rightjoystick;
  38724. /**
  38725. * Gets the left stick of the virtual joystick.
  38726. * @returns The virtual Joystick
  38727. */
  38728. getLeftJoystick(): VirtualJoystick;
  38729. /**
  38730. * Gets the right stick of the virtual joystick.
  38731. * @returns The virtual Joystick
  38732. */
  38733. getRightJoystick(): VirtualJoystick;
  38734. /**
  38735. * Update the current camera state depending on the inputs that have been used this frame.
  38736. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38737. */
  38738. checkInputs(): void;
  38739. /**
  38740. * Attach the input controls to a specific dom element to get the input from.
  38741. * @param element Defines the element the controls should be listened from
  38742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38743. */
  38744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38745. /**
  38746. * Detach the current controls from the specified dom element.
  38747. * @param element Defines the element to stop listening the inputs from
  38748. */
  38749. detachControl(element: Nullable<HTMLElement>): void;
  38750. /**
  38751. * Gets the class name of the current intput.
  38752. * @returns the class name
  38753. */
  38754. getClassName(): string;
  38755. /**
  38756. * Get the friendly name associated with the input class.
  38757. * @returns the input friendly name
  38758. */
  38759. getSimpleName(): string;
  38760. }
  38761. }
  38762. declare module "babylonjs/Cameras/Inputs/index" {
  38763. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38764. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38765. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38766. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38767. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38768. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38769. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38770. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38771. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38772. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38773. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38774. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38775. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38776. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38777. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38778. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38779. }
  38780. declare module "babylonjs/Cameras/touchCamera" {
  38781. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38782. import { Scene } from "babylonjs/scene";
  38783. import { Vector3 } from "babylonjs/Maths/math";
  38784. /**
  38785. * This represents a FPS type of camera controlled by touch.
  38786. * This is like a universal camera minus the Gamepad controls.
  38787. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38788. */
  38789. export class TouchCamera extends FreeCamera {
  38790. /**
  38791. * Defines the touch sensibility for rotation.
  38792. * The higher the faster.
  38793. */
  38794. touchAngularSensibility: number;
  38795. /**
  38796. * Defines the touch sensibility for move.
  38797. * The higher the faster.
  38798. */
  38799. touchMoveSensibility: number;
  38800. /**
  38801. * Instantiates a new touch camera.
  38802. * This represents a FPS type of camera controlled by touch.
  38803. * This is like a universal camera minus the Gamepad controls.
  38804. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38805. * @param name Define the name of the camera in the scene
  38806. * @param position Define the start position of the camera in the scene
  38807. * @param scene Define the scene the camera belongs to
  38808. */
  38809. constructor(name: string, position: Vector3, scene: Scene);
  38810. /**
  38811. * Gets the current object class name.
  38812. * @return the class name
  38813. */
  38814. getClassName(): string;
  38815. /** @hidden */
  38816. _setupInputs(): void;
  38817. }
  38818. }
  38819. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38820. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38821. import { Scene } from "babylonjs/scene";
  38822. import { Vector3, Axis } from "babylonjs/Maths/math";
  38823. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38824. /**
  38825. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38826. * being tilted forward or back and left or right.
  38827. */
  38828. export class DeviceOrientationCamera extends FreeCamera {
  38829. private _initialQuaternion;
  38830. private _quaternionCache;
  38831. private _tmpDragQuaternion;
  38832. /**
  38833. * Creates a new device orientation camera
  38834. * @param name The name of the camera
  38835. * @param position The start position camera
  38836. * @param scene The scene the camera belongs to
  38837. */
  38838. constructor(name: string, position: Vector3, scene: Scene);
  38839. /**
  38840. * @hidden
  38841. * Disabled pointer input on first orientation sensor update (Default: true)
  38842. */
  38843. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38844. private _dragFactor;
  38845. /**
  38846. * Enabled turning on the y axis when the orientation sensor is active
  38847. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38848. */
  38849. enableHorizontalDragging(dragFactor?: number): void;
  38850. /**
  38851. * Gets the current instance class name ("DeviceOrientationCamera").
  38852. * This helps avoiding instanceof at run time.
  38853. * @returns the class name
  38854. */
  38855. getClassName(): string;
  38856. /**
  38857. * @hidden
  38858. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38859. */
  38860. _checkInputs(): void;
  38861. /**
  38862. * Reset the camera to its default orientation on the specified axis only.
  38863. * @param axis The axis to reset
  38864. */
  38865. resetToCurrentRotation(axis?: Axis): void;
  38866. }
  38867. }
  38868. declare module "babylonjs/Gamepads/xboxGamepad" {
  38869. import { Observable } from "babylonjs/Misc/observable";
  38870. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38871. /**
  38872. * Defines supported buttons for XBox360 compatible gamepads
  38873. */
  38874. export enum Xbox360Button {
  38875. /** A */
  38876. A = 0,
  38877. /** B */
  38878. B = 1,
  38879. /** X */
  38880. X = 2,
  38881. /** Y */
  38882. Y = 3,
  38883. /** Start */
  38884. Start = 4,
  38885. /** Back */
  38886. Back = 5,
  38887. /** Left button */
  38888. LB = 6,
  38889. /** Right button */
  38890. RB = 7,
  38891. /** Left stick */
  38892. LeftStick = 8,
  38893. /** Right stick */
  38894. RightStick = 9
  38895. }
  38896. /** Defines values for XBox360 DPad */
  38897. export enum Xbox360Dpad {
  38898. /** Up */
  38899. Up = 0,
  38900. /** Down */
  38901. Down = 1,
  38902. /** Left */
  38903. Left = 2,
  38904. /** Right */
  38905. Right = 3
  38906. }
  38907. /**
  38908. * Defines a XBox360 gamepad
  38909. */
  38910. export class Xbox360Pad extends Gamepad {
  38911. private _leftTrigger;
  38912. private _rightTrigger;
  38913. private _onlefttriggerchanged;
  38914. private _onrighttriggerchanged;
  38915. private _onbuttondown;
  38916. private _onbuttonup;
  38917. private _ondpaddown;
  38918. private _ondpadup;
  38919. /** Observable raised when a button is pressed */
  38920. onButtonDownObservable: Observable<Xbox360Button>;
  38921. /** Observable raised when a button is released */
  38922. onButtonUpObservable: Observable<Xbox360Button>;
  38923. /** Observable raised when a pad is pressed */
  38924. onPadDownObservable: Observable<Xbox360Dpad>;
  38925. /** Observable raised when a pad is released */
  38926. onPadUpObservable: Observable<Xbox360Dpad>;
  38927. private _buttonA;
  38928. private _buttonB;
  38929. private _buttonX;
  38930. private _buttonY;
  38931. private _buttonBack;
  38932. private _buttonStart;
  38933. private _buttonLB;
  38934. private _buttonRB;
  38935. private _buttonLeftStick;
  38936. private _buttonRightStick;
  38937. private _dPadUp;
  38938. private _dPadDown;
  38939. private _dPadLeft;
  38940. private _dPadRight;
  38941. private _isXboxOnePad;
  38942. /**
  38943. * Creates a new XBox360 gamepad object
  38944. * @param id defines the id of this gamepad
  38945. * @param index defines its index
  38946. * @param gamepad defines the internal HTML gamepad object
  38947. * @param xboxOne defines if it is a XBox One gamepad
  38948. */
  38949. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38950. /**
  38951. * Defines the callback to call when left trigger is pressed
  38952. * @param callback defines the callback to use
  38953. */
  38954. onlefttriggerchanged(callback: (value: number) => void): void;
  38955. /**
  38956. * Defines the callback to call when right trigger is pressed
  38957. * @param callback defines the callback to use
  38958. */
  38959. onrighttriggerchanged(callback: (value: number) => void): void;
  38960. /**
  38961. * Gets the left trigger value
  38962. */
  38963. /**
  38964. * Sets the left trigger value
  38965. */
  38966. leftTrigger: number;
  38967. /**
  38968. * Gets the right trigger value
  38969. */
  38970. /**
  38971. * Sets the right trigger value
  38972. */
  38973. rightTrigger: number;
  38974. /**
  38975. * Defines the callback to call when a button is pressed
  38976. * @param callback defines the callback to use
  38977. */
  38978. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38979. /**
  38980. * Defines the callback to call when a button is released
  38981. * @param callback defines the callback to use
  38982. */
  38983. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38984. /**
  38985. * Defines the callback to call when a pad is pressed
  38986. * @param callback defines the callback to use
  38987. */
  38988. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38989. /**
  38990. * Defines the callback to call when a pad is released
  38991. * @param callback defines the callback to use
  38992. */
  38993. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38994. private _setButtonValue;
  38995. private _setDPadValue;
  38996. /**
  38997. * Gets the value of the `A` button
  38998. */
  38999. /**
  39000. * Sets the value of the `A` button
  39001. */
  39002. buttonA: number;
  39003. /**
  39004. * Gets the value of the `B` button
  39005. */
  39006. /**
  39007. * Sets the value of the `B` button
  39008. */
  39009. buttonB: number;
  39010. /**
  39011. * Gets the value of the `X` button
  39012. */
  39013. /**
  39014. * Sets the value of the `X` button
  39015. */
  39016. buttonX: number;
  39017. /**
  39018. * Gets the value of the `Y` button
  39019. */
  39020. /**
  39021. * Sets the value of the `Y` button
  39022. */
  39023. buttonY: number;
  39024. /**
  39025. * Gets the value of the `Start` button
  39026. */
  39027. /**
  39028. * Sets the value of the `Start` button
  39029. */
  39030. buttonStart: number;
  39031. /**
  39032. * Gets the value of the `Back` button
  39033. */
  39034. /**
  39035. * Sets the value of the `Back` button
  39036. */
  39037. buttonBack: number;
  39038. /**
  39039. * Gets the value of the `Left` button
  39040. */
  39041. /**
  39042. * Sets the value of the `Left` button
  39043. */
  39044. buttonLB: number;
  39045. /**
  39046. * Gets the value of the `Right` button
  39047. */
  39048. /**
  39049. * Sets the value of the `Right` button
  39050. */
  39051. buttonRB: number;
  39052. /**
  39053. * Gets the value of the Left joystick
  39054. */
  39055. /**
  39056. * Sets the value of the Left joystick
  39057. */
  39058. buttonLeftStick: number;
  39059. /**
  39060. * Gets the value of the Right joystick
  39061. */
  39062. /**
  39063. * Sets the value of the Right joystick
  39064. */
  39065. buttonRightStick: number;
  39066. /**
  39067. * Gets the value of D-pad up
  39068. */
  39069. /**
  39070. * Sets the value of D-pad up
  39071. */
  39072. dPadUp: number;
  39073. /**
  39074. * Gets the value of D-pad down
  39075. */
  39076. /**
  39077. * Sets the value of D-pad down
  39078. */
  39079. dPadDown: number;
  39080. /**
  39081. * Gets the value of D-pad left
  39082. */
  39083. /**
  39084. * Sets the value of D-pad left
  39085. */
  39086. dPadLeft: number;
  39087. /**
  39088. * Gets the value of D-pad right
  39089. */
  39090. /**
  39091. * Sets the value of D-pad right
  39092. */
  39093. dPadRight: number;
  39094. /**
  39095. * Force the gamepad to synchronize with device values
  39096. */
  39097. update(): void;
  39098. /**
  39099. * Disposes the gamepad
  39100. */
  39101. dispose(): void;
  39102. }
  39103. }
  39104. declare module "babylonjs/Gamepads/gamepadManager" {
  39105. import { Observable } from "babylonjs/Misc/observable";
  39106. import { Nullable } from "babylonjs/types";
  39107. import { Scene } from "babylonjs/scene";
  39108. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39109. /**
  39110. * Manager for handling gamepads
  39111. */
  39112. export class GamepadManager {
  39113. private _scene?;
  39114. private _babylonGamepads;
  39115. private _oneGamepadConnected;
  39116. /** @hidden */
  39117. _isMonitoring: boolean;
  39118. private _gamepadEventSupported;
  39119. private _gamepadSupport;
  39120. /**
  39121. * observable to be triggered when the gamepad controller has been connected
  39122. */
  39123. onGamepadConnectedObservable: Observable<Gamepad>;
  39124. /**
  39125. * observable to be triggered when the gamepad controller has been disconnected
  39126. */
  39127. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39128. private _onGamepadConnectedEvent;
  39129. private _onGamepadDisconnectedEvent;
  39130. /**
  39131. * Initializes the gamepad manager
  39132. * @param _scene BabylonJS scene
  39133. */
  39134. constructor(_scene?: Scene | undefined);
  39135. /**
  39136. * The gamepads in the game pad manager
  39137. */
  39138. readonly gamepads: Gamepad[];
  39139. /**
  39140. * Get the gamepad controllers based on type
  39141. * @param type The type of gamepad controller
  39142. * @returns Nullable gamepad
  39143. */
  39144. getGamepadByType(type?: number): Nullable<Gamepad>;
  39145. /**
  39146. * Disposes the gamepad manager
  39147. */
  39148. dispose(): void;
  39149. private _addNewGamepad;
  39150. private _startMonitoringGamepads;
  39151. private _stopMonitoringGamepads;
  39152. /** @hidden */
  39153. _checkGamepadsStatus(): void;
  39154. private _updateGamepadObjects;
  39155. }
  39156. }
  39157. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39158. import { Nullable } from "babylonjs/types";
  39159. import { Scene } from "babylonjs/scene";
  39160. import { ISceneComponent } from "babylonjs/sceneComponent";
  39161. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39162. module "babylonjs/scene" {
  39163. interface Scene {
  39164. /** @hidden */
  39165. _gamepadManager: Nullable<GamepadManager>;
  39166. /**
  39167. * Gets the gamepad manager associated with the scene
  39168. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39169. */
  39170. gamepadManager: GamepadManager;
  39171. }
  39172. }
  39173. module "babylonjs/Cameras/freeCameraInputsManager" {
  39174. /**
  39175. * Interface representing a free camera inputs manager
  39176. */
  39177. interface FreeCameraInputsManager {
  39178. /**
  39179. * Adds gamepad input support to the FreeCameraInputsManager.
  39180. * @returns the FreeCameraInputsManager
  39181. */
  39182. addGamepad(): FreeCameraInputsManager;
  39183. }
  39184. }
  39185. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39186. /**
  39187. * Interface representing an arc rotate camera inputs manager
  39188. */
  39189. interface ArcRotateCameraInputsManager {
  39190. /**
  39191. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39192. * @returns the camera inputs manager
  39193. */
  39194. addGamepad(): ArcRotateCameraInputsManager;
  39195. }
  39196. }
  39197. /**
  39198. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39199. */
  39200. export class GamepadSystemSceneComponent implements ISceneComponent {
  39201. /**
  39202. * The component name helpfull to identify the component in the list of scene components.
  39203. */
  39204. readonly name: string;
  39205. /**
  39206. * The scene the component belongs to.
  39207. */
  39208. scene: Scene;
  39209. /**
  39210. * Creates a new instance of the component for the given scene
  39211. * @param scene Defines the scene to register the component in
  39212. */
  39213. constructor(scene: Scene);
  39214. /**
  39215. * Registers the component in a given scene
  39216. */
  39217. register(): void;
  39218. /**
  39219. * Rebuilds the elements related to this component in case of
  39220. * context lost for instance.
  39221. */
  39222. rebuild(): void;
  39223. /**
  39224. * Disposes the component and the associated ressources
  39225. */
  39226. dispose(): void;
  39227. private _beforeCameraUpdate;
  39228. }
  39229. }
  39230. declare module "babylonjs/Cameras/universalCamera" {
  39231. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39232. import { Scene } from "babylonjs/scene";
  39233. import { Vector3 } from "babylonjs/Maths/math";
  39234. import "babylonjs/Gamepads/gamepadSceneComponent";
  39235. /**
  39236. * 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,
  39237. * which still works and will still be found in many Playgrounds.
  39238. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39239. */
  39240. export class UniversalCamera extends TouchCamera {
  39241. /**
  39242. * Defines the gamepad rotation sensiblity.
  39243. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39244. */
  39245. gamepadAngularSensibility: number;
  39246. /**
  39247. * Defines the gamepad move sensiblity.
  39248. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39249. */
  39250. gamepadMoveSensibility: number;
  39251. /**
  39252. * 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,
  39253. * which still works and will still be found in many Playgrounds.
  39254. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39255. * @param name Define the name of the camera in the scene
  39256. * @param position Define the start position of the camera in the scene
  39257. * @param scene Define the scene the camera belongs to
  39258. */
  39259. constructor(name: string, position: Vector3, scene: Scene);
  39260. /**
  39261. * Gets the current object class name.
  39262. * @return the class name
  39263. */
  39264. getClassName(): string;
  39265. }
  39266. }
  39267. declare module "babylonjs/Cameras/gamepadCamera" {
  39268. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39269. import { Scene } from "babylonjs/scene";
  39270. import { Vector3 } from "babylonjs/Maths/math";
  39271. /**
  39272. * This represents a FPS type of camera. This is only here for back compat purpose.
  39273. * Please use the UniversalCamera instead as both are identical.
  39274. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39275. */
  39276. export class GamepadCamera extends UniversalCamera {
  39277. /**
  39278. * Instantiates a new Gamepad Camera
  39279. * This represents a FPS type of camera. This is only here for back compat purpose.
  39280. * Please use the UniversalCamera instead as both are identical.
  39281. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39282. * @param name Define the name of the camera in the scene
  39283. * @param position Define the start position of the camera in the scene
  39284. * @param scene Define the scene the camera belongs to
  39285. */
  39286. constructor(name: string, position: Vector3, scene: Scene);
  39287. /**
  39288. * Gets the current object class name.
  39289. * @return the class name
  39290. */
  39291. getClassName(): string;
  39292. }
  39293. }
  39294. declare module "babylonjs/Shaders/pass.fragment" {
  39295. /** @hidden */
  39296. export var passPixelShader: {
  39297. name: string;
  39298. shader: string;
  39299. };
  39300. }
  39301. declare module "babylonjs/Shaders/passCube.fragment" {
  39302. /** @hidden */
  39303. export var passCubePixelShader: {
  39304. name: string;
  39305. shader: string;
  39306. };
  39307. }
  39308. declare module "babylonjs/PostProcesses/passPostProcess" {
  39309. import { Nullable } from "babylonjs/types";
  39310. import { Camera } from "babylonjs/Cameras/camera";
  39311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39312. import { Engine } from "babylonjs/Engines/engine";
  39313. import "babylonjs/Shaders/pass.fragment";
  39314. import "babylonjs/Shaders/passCube.fragment";
  39315. /**
  39316. * PassPostProcess which produces an output the same as it's input
  39317. */
  39318. export class PassPostProcess extends PostProcess {
  39319. /**
  39320. * Creates the PassPostProcess
  39321. * @param name The name of the effect.
  39322. * @param options The required width/height ratio to downsize to before computing the render pass.
  39323. * @param camera The camera to apply the render pass to.
  39324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39325. * @param engine The engine which the post process will be applied. (default: current engine)
  39326. * @param reusable If the post process can be reused on the same frame. (default: false)
  39327. * @param textureType The type of texture to be used when performing the post processing.
  39328. * @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)
  39329. */
  39330. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39331. }
  39332. /**
  39333. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39334. */
  39335. export class PassCubePostProcess extends PostProcess {
  39336. private _face;
  39337. /**
  39338. * Gets or sets the cube face to display.
  39339. * * 0 is +X
  39340. * * 1 is -X
  39341. * * 2 is +Y
  39342. * * 3 is -Y
  39343. * * 4 is +Z
  39344. * * 5 is -Z
  39345. */
  39346. face: number;
  39347. /**
  39348. * Creates the PassCubePostProcess
  39349. * @param name The name of the effect.
  39350. * @param options The required width/height ratio to downsize to before computing the render pass.
  39351. * @param camera The camera to apply the render pass to.
  39352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39353. * @param engine The engine which the post process will be applied. (default: current engine)
  39354. * @param reusable If the post process can be reused on the same frame. (default: false)
  39355. * @param textureType The type of texture to be used when performing the post processing.
  39356. * @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)
  39357. */
  39358. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39359. }
  39360. }
  39361. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39362. /** @hidden */
  39363. export var anaglyphPixelShader: {
  39364. name: string;
  39365. shader: string;
  39366. };
  39367. }
  39368. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39369. import { Engine } from "babylonjs/Engines/engine";
  39370. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39371. import { Camera } from "babylonjs/Cameras/camera";
  39372. import "babylonjs/Shaders/anaglyph.fragment";
  39373. /**
  39374. * Postprocess used to generate anaglyphic rendering
  39375. */
  39376. export class AnaglyphPostProcess extends PostProcess {
  39377. private _passedProcess;
  39378. /**
  39379. * Creates a new AnaglyphPostProcess
  39380. * @param name defines postprocess name
  39381. * @param options defines creation options or target ratio scale
  39382. * @param rigCameras defines cameras using this postprocess
  39383. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39384. * @param engine defines hosting engine
  39385. * @param reusable defines if the postprocess will be reused multiple times per frame
  39386. */
  39387. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39388. }
  39389. }
  39390. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39391. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39392. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39393. import { Scene } from "babylonjs/scene";
  39394. import { Vector3 } from "babylonjs/Maths/math";
  39395. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39396. /**
  39397. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39398. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39399. */
  39400. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39401. /**
  39402. * Creates a new AnaglyphArcRotateCamera
  39403. * @param name defines camera name
  39404. * @param alpha defines alpha angle (in radians)
  39405. * @param beta defines beta angle (in radians)
  39406. * @param radius defines radius
  39407. * @param target defines camera target
  39408. * @param interaxialDistance defines distance between each color axis
  39409. * @param scene defines the hosting scene
  39410. */
  39411. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39412. /**
  39413. * Gets camera class name
  39414. * @returns AnaglyphArcRotateCamera
  39415. */
  39416. getClassName(): string;
  39417. }
  39418. }
  39419. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39420. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39421. import { Scene } from "babylonjs/scene";
  39422. import { Vector3 } from "babylonjs/Maths/math";
  39423. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39424. /**
  39425. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39426. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39427. */
  39428. export class AnaglyphFreeCamera extends FreeCamera {
  39429. /**
  39430. * Creates a new AnaglyphFreeCamera
  39431. * @param name defines camera name
  39432. * @param position defines initial position
  39433. * @param interaxialDistance defines distance between each color axis
  39434. * @param scene defines the hosting scene
  39435. */
  39436. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39437. /**
  39438. * Gets camera class name
  39439. * @returns AnaglyphFreeCamera
  39440. */
  39441. getClassName(): string;
  39442. }
  39443. }
  39444. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39445. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39446. import { Scene } from "babylonjs/scene";
  39447. import { Vector3 } from "babylonjs/Maths/math";
  39448. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39449. /**
  39450. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39451. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39452. */
  39453. export class AnaglyphGamepadCamera extends GamepadCamera {
  39454. /**
  39455. * Creates a new AnaglyphGamepadCamera
  39456. * @param name defines camera name
  39457. * @param position defines initial position
  39458. * @param interaxialDistance defines distance between each color axis
  39459. * @param scene defines the hosting scene
  39460. */
  39461. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39462. /**
  39463. * Gets camera class name
  39464. * @returns AnaglyphGamepadCamera
  39465. */
  39466. getClassName(): string;
  39467. }
  39468. }
  39469. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39470. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39471. import { Scene } from "babylonjs/scene";
  39472. import { Vector3 } from "babylonjs/Maths/math";
  39473. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39474. /**
  39475. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39476. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39477. */
  39478. export class AnaglyphUniversalCamera extends UniversalCamera {
  39479. /**
  39480. * Creates a new AnaglyphUniversalCamera
  39481. * @param name defines camera name
  39482. * @param position defines initial position
  39483. * @param interaxialDistance defines distance between each color axis
  39484. * @param scene defines the hosting scene
  39485. */
  39486. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39487. /**
  39488. * Gets camera class name
  39489. * @returns AnaglyphUniversalCamera
  39490. */
  39491. getClassName(): string;
  39492. }
  39493. }
  39494. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39495. /** @hidden */
  39496. export var stereoscopicInterlacePixelShader: {
  39497. name: string;
  39498. shader: string;
  39499. };
  39500. }
  39501. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39502. import { Camera } from "babylonjs/Cameras/camera";
  39503. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39504. import { Engine } from "babylonjs/Engines/engine";
  39505. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39506. /**
  39507. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39508. */
  39509. export class StereoscopicInterlacePostProcess extends PostProcess {
  39510. private _stepSize;
  39511. private _passedProcess;
  39512. /**
  39513. * Initializes a StereoscopicInterlacePostProcess
  39514. * @param name The name of the effect.
  39515. * @param rigCameras The rig cameras to be appled to the post process
  39516. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39518. * @param engine The engine which the post process will be applied. (default: current engine)
  39519. * @param reusable If the post process can be reused on the same frame. (default: false)
  39520. */
  39521. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39522. }
  39523. }
  39524. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39525. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39526. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39527. import { Scene } from "babylonjs/scene";
  39528. import { Vector3 } from "babylonjs/Maths/math";
  39529. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39530. /**
  39531. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39532. * @see http://doc.babylonjs.com/features/cameras
  39533. */
  39534. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39535. /**
  39536. * Creates a new StereoscopicArcRotateCamera
  39537. * @param name defines camera name
  39538. * @param alpha defines alpha angle (in radians)
  39539. * @param beta defines beta angle (in radians)
  39540. * @param radius defines radius
  39541. * @param target defines camera target
  39542. * @param interaxialDistance defines distance between each color axis
  39543. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39544. * @param scene defines the hosting scene
  39545. */
  39546. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39547. /**
  39548. * Gets camera class name
  39549. * @returns StereoscopicArcRotateCamera
  39550. */
  39551. getClassName(): string;
  39552. }
  39553. }
  39554. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39556. import { Scene } from "babylonjs/scene";
  39557. import { Vector3 } from "babylonjs/Maths/math";
  39558. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39559. /**
  39560. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39561. * @see http://doc.babylonjs.com/features/cameras
  39562. */
  39563. export class StereoscopicFreeCamera extends FreeCamera {
  39564. /**
  39565. * Creates a new StereoscopicFreeCamera
  39566. * @param name defines camera name
  39567. * @param position defines initial position
  39568. * @param interaxialDistance defines distance between each color axis
  39569. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39570. * @param scene defines the hosting scene
  39571. */
  39572. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39573. /**
  39574. * Gets camera class name
  39575. * @returns StereoscopicFreeCamera
  39576. */
  39577. getClassName(): string;
  39578. }
  39579. }
  39580. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39581. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39582. import { Scene } from "babylonjs/scene";
  39583. import { Vector3 } from "babylonjs/Maths/math";
  39584. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39585. /**
  39586. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39587. * @see http://doc.babylonjs.com/features/cameras
  39588. */
  39589. export class StereoscopicGamepadCamera extends GamepadCamera {
  39590. /**
  39591. * Creates a new StereoscopicGamepadCamera
  39592. * @param name defines camera name
  39593. * @param position defines initial position
  39594. * @param interaxialDistance defines distance between each color axis
  39595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39596. * @param scene defines the hosting scene
  39597. */
  39598. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39599. /**
  39600. * Gets camera class name
  39601. * @returns StereoscopicGamepadCamera
  39602. */
  39603. getClassName(): string;
  39604. }
  39605. }
  39606. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39607. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39608. import { Scene } from "babylonjs/scene";
  39609. import { Vector3 } from "babylonjs/Maths/math";
  39610. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39611. /**
  39612. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39613. * @see http://doc.babylonjs.com/features/cameras
  39614. */
  39615. export class StereoscopicUniversalCamera extends UniversalCamera {
  39616. /**
  39617. * Creates a new StereoscopicUniversalCamera
  39618. * @param name defines camera name
  39619. * @param position defines initial position
  39620. * @param interaxialDistance defines distance between each color axis
  39621. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39622. * @param scene defines the hosting scene
  39623. */
  39624. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39625. /**
  39626. * Gets camera class name
  39627. * @returns StereoscopicUniversalCamera
  39628. */
  39629. getClassName(): string;
  39630. }
  39631. }
  39632. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39633. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39634. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39635. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39636. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39637. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39638. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39639. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39640. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39641. }
  39642. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39643. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39644. import { Scene } from "babylonjs/scene";
  39645. import { Vector3 } from "babylonjs/Maths/math";
  39646. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39647. /**
  39648. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39649. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39650. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39651. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39652. */
  39653. export class VirtualJoysticksCamera extends FreeCamera {
  39654. /**
  39655. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39656. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39657. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39658. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39659. * @param name Define the name of the camera in the scene
  39660. * @param position Define the start position of the camera in the scene
  39661. * @param scene Define the scene the camera belongs to
  39662. */
  39663. constructor(name: string, position: Vector3, scene: Scene);
  39664. /**
  39665. * Gets the current object class name.
  39666. * @return the class name
  39667. */
  39668. getClassName(): string;
  39669. }
  39670. }
  39671. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39672. import { Matrix } from "babylonjs/Maths/math";
  39673. /**
  39674. * This represents all the required metrics to create a VR camera.
  39675. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39676. */
  39677. export class VRCameraMetrics {
  39678. /**
  39679. * Define the horizontal resolution off the screen.
  39680. */
  39681. hResolution: number;
  39682. /**
  39683. * Define the vertical resolution off the screen.
  39684. */
  39685. vResolution: number;
  39686. /**
  39687. * Define the horizontal screen size.
  39688. */
  39689. hScreenSize: number;
  39690. /**
  39691. * Define the vertical screen size.
  39692. */
  39693. vScreenSize: number;
  39694. /**
  39695. * Define the vertical screen center position.
  39696. */
  39697. vScreenCenter: number;
  39698. /**
  39699. * Define the distance of the eyes to the screen.
  39700. */
  39701. eyeToScreenDistance: number;
  39702. /**
  39703. * Define the distance between both lenses
  39704. */
  39705. lensSeparationDistance: number;
  39706. /**
  39707. * Define the distance between both viewer's eyes.
  39708. */
  39709. interpupillaryDistance: number;
  39710. /**
  39711. * Define the distortion factor of the VR postprocess.
  39712. * Please, touch with care.
  39713. */
  39714. distortionK: number[];
  39715. /**
  39716. * Define the chromatic aberration correction factors for the VR post process.
  39717. */
  39718. chromaAbCorrection: number[];
  39719. /**
  39720. * Define the scale factor of the post process.
  39721. * The smaller the better but the slower.
  39722. */
  39723. postProcessScaleFactor: number;
  39724. /**
  39725. * Define an offset for the lens center.
  39726. */
  39727. lensCenterOffset: number;
  39728. /**
  39729. * Define if the current vr camera should compensate the distortion of the lense or not.
  39730. */
  39731. compensateDistortion: boolean;
  39732. /**
  39733. * Defines if multiview should be enabled when rendering (Default: false)
  39734. */
  39735. multiviewEnabled: boolean;
  39736. /**
  39737. * Gets the rendering aspect ratio based on the provided resolutions.
  39738. */
  39739. readonly aspectRatio: number;
  39740. /**
  39741. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39742. */
  39743. readonly aspectRatioFov: number;
  39744. /**
  39745. * @hidden
  39746. */
  39747. readonly leftHMatrix: Matrix;
  39748. /**
  39749. * @hidden
  39750. */
  39751. readonly rightHMatrix: Matrix;
  39752. /**
  39753. * @hidden
  39754. */
  39755. readonly leftPreViewMatrix: Matrix;
  39756. /**
  39757. * @hidden
  39758. */
  39759. readonly rightPreViewMatrix: Matrix;
  39760. /**
  39761. * Get the default VRMetrics based on the most generic setup.
  39762. * @returns the default vr metrics
  39763. */
  39764. static GetDefault(): VRCameraMetrics;
  39765. }
  39766. }
  39767. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39768. /** @hidden */
  39769. export var vrDistortionCorrectionPixelShader: {
  39770. name: string;
  39771. shader: string;
  39772. };
  39773. }
  39774. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39775. import { Camera } from "babylonjs/Cameras/camera";
  39776. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39777. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39778. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39779. /**
  39780. * VRDistortionCorrectionPostProcess used for mobile VR
  39781. */
  39782. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39783. private _isRightEye;
  39784. private _distortionFactors;
  39785. private _postProcessScaleFactor;
  39786. private _lensCenterOffset;
  39787. private _scaleIn;
  39788. private _scaleFactor;
  39789. private _lensCenter;
  39790. /**
  39791. * Initializes the VRDistortionCorrectionPostProcess
  39792. * @param name The name of the effect.
  39793. * @param camera The camera to apply the render pass to.
  39794. * @param isRightEye If this is for the right eye distortion
  39795. * @param vrMetrics All the required metrics for the VR camera
  39796. */
  39797. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39798. }
  39799. }
  39800. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39801. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39802. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39803. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39804. import { Scene } from "babylonjs/scene";
  39805. import { Vector3 } from "babylonjs/Maths/math";
  39806. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39807. import "babylonjs/Cameras/RigModes/vrRigMode";
  39808. /**
  39809. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39810. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39811. */
  39812. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39813. /**
  39814. * Creates a new VRDeviceOrientationArcRotateCamera
  39815. * @param name defines camera name
  39816. * @param alpha defines the camera rotation along the logitudinal axis
  39817. * @param beta defines the camera rotation along the latitudinal axis
  39818. * @param radius defines the camera distance from its target
  39819. * @param target defines the camera target
  39820. * @param scene defines the scene the camera belongs to
  39821. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39822. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39823. */
  39824. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39825. /**
  39826. * Gets camera class name
  39827. * @returns VRDeviceOrientationArcRotateCamera
  39828. */
  39829. getClassName(): string;
  39830. }
  39831. }
  39832. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39833. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39834. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39835. import { Scene } from "babylonjs/scene";
  39836. import { Vector3 } from "babylonjs/Maths/math";
  39837. import "babylonjs/Cameras/RigModes/vrRigMode";
  39838. /**
  39839. * Camera used to simulate VR rendering (based on FreeCamera)
  39840. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39841. */
  39842. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39843. /**
  39844. * Creates a new VRDeviceOrientationFreeCamera
  39845. * @param name defines camera name
  39846. * @param position defines the start position of the camera
  39847. * @param scene defines the scene the camera belongs to
  39848. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39849. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39850. */
  39851. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39852. /**
  39853. * Gets camera class name
  39854. * @returns VRDeviceOrientationFreeCamera
  39855. */
  39856. getClassName(): string;
  39857. }
  39858. }
  39859. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39860. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39861. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39862. import { Scene } from "babylonjs/scene";
  39863. import { Vector3 } from "babylonjs/Maths/math";
  39864. import "babylonjs/Gamepads/gamepadSceneComponent";
  39865. /**
  39866. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39867. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39868. */
  39869. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39870. /**
  39871. * Creates a new VRDeviceOrientationGamepadCamera
  39872. * @param name defines camera name
  39873. * @param position defines the start position of the camera
  39874. * @param scene defines the scene the camera belongs to
  39875. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39876. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39877. */
  39878. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39879. /**
  39880. * Gets camera class name
  39881. * @returns VRDeviceOrientationGamepadCamera
  39882. */
  39883. getClassName(): string;
  39884. }
  39885. }
  39886. declare module "babylonjs/Materials/pushMaterial" {
  39887. import { Nullable } from "babylonjs/types";
  39888. import { Scene } from "babylonjs/scene";
  39889. import { Matrix } from "babylonjs/Maths/math";
  39890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39891. import { Mesh } from "babylonjs/Meshes/mesh";
  39892. import { Material } from "babylonjs/Materials/material";
  39893. import { Effect } from "babylonjs/Materials/effect";
  39894. /**
  39895. * Base class of materials working in push mode in babylon JS
  39896. * @hidden
  39897. */
  39898. export class PushMaterial extends Material {
  39899. protected _activeEffect: Effect;
  39900. protected _normalMatrix: Matrix;
  39901. /**
  39902. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39903. * This means that the material can keep using a previous shader while a new one is being compiled.
  39904. * This is mostly used when shader parallel compilation is supported (true by default)
  39905. */
  39906. allowShaderHotSwapping: boolean;
  39907. constructor(name: string, scene: Scene);
  39908. getEffect(): Effect;
  39909. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39910. /**
  39911. * Binds the given world matrix to the active effect
  39912. *
  39913. * @param world the matrix to bind
  39914. */
  39915. bindOnlyWorldMatrix(world: Matrix): void;
  39916. /**
  39917. * Binds the given normal matrix to the active effect
  39918. *
  39919. * @param normalMatrix the matrix to bind
  39920. */
  39921. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39922. bind(world: Matrix, mesh?: Mesh): void;
  39923. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39924. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39925. }
  39926. }
  39927. declare module "babylonjs/Materials/materialFlags" {
  39928. /**
  39929. * This groups all the flags used to control the materials channel.
  39930. */
  39931. export class MaterialFlags {
  39932. private static _DiffuseTextureEnabled;
  39933. /**
  39934. * Are diffuse textures enabled in the application.
  39935. */
  39936. static DiffuseTextureEnabled: boolean;
  39937. private static _AmbientTextureEnabled;
  39938. /**
  39939. * Are ambient textures enabled in the application.
  39940. */
  39941. static AmbientTextureEnabled: boolean;
  39942. private static _OpacityTextureEnabled;
  39943. /**
  39944. * Are opacity textures enabled in the application.
  39945. */
  39946. static OpacityTextureEnabled: boolean;
  39947. private static _ReflectionTextureEnabled;
  39948. /**
  39949. * Are reflection textures enabled in the application.
  39950. */
  39951. static ReflectionTextureEnabled: boolean;
  39952. private static _EmissiveTextureEnabled;
  39953. /**
  39954. * Are emissive textures enabled in the application.
  39955. */
  39956. static EmissiveTextureEnabled: boolean;
  39957. private static _SpecularTextureEnabled;
  39958. /**
  39959. * Are specular textures enabled in the application.
  39960. */
  39961. static SpecularTextureEnabled: boolean;
  39962. private static _BumpTextureEnabled;
  39963. /**
  39964. * Are bump textures enabled in the application.
  39965. */
  39966. static BumpTextureEnabled: boolean;
  39967. private static _LightmapTextureEnabled;
  39968. /**
  39969. * Are lightmap textures enabled in the application.
  39970. */
  39971. static LightmapTextureEnabled: boolean;
  39972. private static _RefractionTextureEnabled;
  39973. /**
  39974. * Are refraction textures enabled in the application.
  39975. */
  39976. static RefractionTextureEnabled: boolean;
  39977. private static _ColorGradingTextureEnabled;
  39978. /**
  39979. * Are color grading textures enabled in the application.
  39980. */
  39981. static ColorGradingTextureEnabled: boolean;
  39982. private static _FresnelEnabled;
  39983. /**
  39984. * Are fresnels enabled in the application.
  39985. */
  39986. static FresnelEnabled: boolean;
  39987. private static _ClearCoatTextureEnabled;
  39988. /**
  39989. * Are clear coat textures enabled in the application.
  39990. */
  39991. static ClearCoatTextureEnabled: boolean;
  39992. private static _ClearCoatBumpTextureEnabled;
  39993. /**
  39994. * Are clear coat bump textures enabled in the application.
  39995. */
  39996. static ClearCoatBumpTextureEnabled: boolean;
  39997. private static _ClearCoatTintTextureEnabled;
  39998. /**
  39999. * Are clear coat tint textures enabled in the application.
  40000. */
  40001. static ClearCoatTintTextureEnabled: boolean;
  40002. private static _SheenTextureEnabled;
  40003. /**
  40004. * Are sheen textures enabled in the application.
  40005. */
  40006. static SheenTextureEnabled: boolean;
  40007. private static _AnisotropicTextureEnabled;
  40008. /**
  40009. * Are anisotropic textures enabled in the application.
  40010. */
  40011. static AnisotropicTextureEnabled: boolean;
  40012. private static _ThicknessTextureEnabled;
  40013. /**
  40014. * Are thickness textures enabled in the application.
  40015. */
  40016. static ThicknessTextureEnabled: boolean;
  40017. }
  40018. }
  40019. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40020. /** @hidden */
  40021. export var defaultFragmentDeclaration: {
  40022. name: string;
  40023. shader: string;
  40024. };
  40025. }
  40026. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40027. /** @hidden */
  40028. export var defaultUboDeclaration: {
  40029. name: string;
  40030. shader: string;
  40031. };
  40032. }
  40033. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40034. /** @hidden */
  40035. export var lightFragmentDeclaration: {
  40036. name: string;
  40037. shader: string;
  40038. };
  40039. }
  40040. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40041. /** @hidden */
  40042. export var lightUboDeclaration: {
  40043. name: string;
  40044. shader: string;
  40045. };
  40046. }
  40047. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40048. /** @hidden */
  40049. export var lightsFragmentFunctions: {
  40050. name: string;
  40051. shader: string;
  40052. };
  40053. }
  40054. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40055. /** @hidden */
  40056. export var shadowsFragmentFunctions: {
  40057. name: string;
  40058. shader: string;
  40059. };
  40060. }
  40061. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40062. /** @hidden */
  40063. export var fresnelFunction: {
  40064. name: string;
  40065. shader: string;
  40066. };
  40067. }
  40068. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40069. /** @hidden */
  40070. export var reflectionFunction: {
  40071. name: string;
  40072. shader: string;
  40073. };
  40074. }
  40075. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40076. /** @hidden */
  40077. export var bumpFragmentFunctions: {
  40078. name: string;
  40079. shader: string;
  40080. };
  40081. }
  40082. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40083. /** @hidden */
  40084. export var logDepthDeclaration: {
  40085. name: string;
  40086. shader: string;
  40087. };
  40088. }
  40089. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40090. /** @hidden */
  40091. export var bumpFragment: {
  40092. name: string;
  40093. shader: string;
  40094. };
  40095. }
  40096. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40097. /** @hidden */
  40098. export var depthPrePass: {
  40099. name: string;
  40100. shader: string;
  40101. };
  40102. }
  40103. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40104. /** @hidden */
  40105. export var lightFragment: {
  40106. name: string;
  40107. shader: string;
  40108. };
  40109. }
  40110. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40111. /** @hidden */
  40112. export var logDepthFragment: {
  40113. name: string;
  40114. shader: string;
  40115. };
  40116. }
  40117. declare module "babylonjs/Shaders/default.fragment" {
  40118. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40119. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40120. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40121. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40122. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40123. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40124. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40125. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40126. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40127. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40128. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40129. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40130. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40131. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40132. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40133. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40134. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40135. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40136. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40137. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40138. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40139. /** @hidden */
  40140. export var defaultPixelShader: {
  40141. name: string;
  40142. shader: string;
  40143. };
  40144. }
  40145. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40146. /** @hidden */
  40147. export var defaultVertexDeclaration: {
  40148. name: string;
  40149. shader: string;
  40150. };
  40151. }
  40152. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40153. /** @hidden */
  40154. export var bumpVertexDeclaration: {
  40155. name: string;
  40156. shader: string;
  40157. };
  40158. }
  40159. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40160. /** @hidden */
  40161. export var bumpVertex: {
  40162. name: string;
  40163. shader: string;
  40164. };
  40165. }
  40166. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40167. /** @hidden */
  40168. export var fogVertex: {
  40169. name: string;
  40170. shader: string;
  40171. };
  40172. }
  40173. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40174. /** @hidden */
  40175. export var shadowsVertex: {
  40176. name: string;
  40177. shader: string;
  40178. };
  40179. }
  40180. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40181. /** @hidden */
  40182. export var pointCloudVertex: {
  40183. name: string;
  40184. shader: string;
  40185. };
  40186. }
  40187. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40188. /** @hidden */
  40189. export var logDepthVertex: {
  40190. name: string;
  40191. shader: string;
  40192. };
  40193. }
  40194. declare module "babylonjs/Shaders/default.vertex" {
  40195. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40196. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40197. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40198. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40199. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40200. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40202. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40203. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40204. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40206. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40207. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40208. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40209. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40210. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40211. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40212. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40213. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40214. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40215. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40216. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40217. /** @hidden */
  40218. export var defaultVertexShader: {
  40219. name: string;
  40220. shader: string;
  40221. };
  40222. }
  40223. declare module "babylonjs/Materials/standardMaterial" {
  40224. import { SmartArray } from "babylonjs/Misc/smartArray";
  40225. import { IAnimatable } from "babylonjs/Misc/tools";
  40226. import { Nullable } from "babylonjs/types";
  40227. import { Scene } from "babylonjs/scene";
  40228. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40229. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40231. import { Mesh } from "babylonjs/Meshes/mesh";
  40232. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40233. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40234. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40235. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40236. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40238. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40239. import "babylonjs/Shaders/default.fragment";
  40240. import "babylonjs/Shaders/default.vertex";
  40241. /** @hidden */
  40242. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40243. MAINUV1: boolean;
  40244. MAINUV2: boolean;
  40245. DIFFUSE: boolean;
  40246. DIFFUSEDIRECTUV: number;
  40247. AMBIENT: boolean;
  40248. AMBIENTDIRECTUV: number;
  40249. OPACITY: boolean;
  40250. OPACITYDIRECTUV: number;
  40251. OPACITYRGB: boolean;
  40252. REFLECTION: boolean;
  40253. EMISSIVE: boolean;
  40254. EMISSIVEDIRECTUV: number;
  40255. SPECULAR: boolean;
  40256. SPECULARDIRECTUV: number;
  40257. BUMP: boolean;
  40258. BUMPDIRECTUV: number;
  40259. PARALLAX: boolean;
  40260. PARALLAXOCCLUSION: boolean;
  40261. SPECULAROVERALPHA: boolean;
  40262. CLIPPLANE: boolean;
  40263. CLIPPLANE2: boolean;
  40264. CLIPPLANE3: boolean;
  40265. CLIPPLANE4: boolean;
  40266. ALPHATEST: boolean;
  40267. DEPTHPREPASS: boolean;
  40268. ALPHAFROMDIFFUSE: boolean;
  40269. POINTSIZE: boolean;
  40270. FOG: boolean;
  40271. SPECULARTERM: boolean;
  40272. DIFFUSEFRESNEL: boolean;
  40273. OPACITYFRESNEL: boolean;
  40274. REFLECTIONFRESNEL: boolean;
  40275. REFRACTIONFRESNEL: boolean;
  40276. EMISSIVEFRESNEL: boolean;
  40277. FRESNEL: boolean;
  40278. NORMAL: boolean;
  40279. UV1: boolean;
  40280. UV2: boolean;
  40281. VERTEXCOLOR: boolean;
  40282. VERTEXALPHA: boolean;
  40283. NUM_BONE_INFLUENCERS: number;
  40284. BonesPerMesh: number;
  40285. BONETEXTURE: boolean;
  40286. INSTANCES: boolean;
  40287. GLOSSINESS: boolean;
  40288. ROUGHNESS: boolean;
  40289. EMISSIVEASILLUMINATION: boolean;
  40290. LINKEMISSIVEWITHDIFFUSE: boolean;
  40291. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40292. LIGHTMAP: boolean;
  40293. LIGHTMAPDIRECTUV: number;
  40294. OBJECTSPACE_NORMALMAP: boolean;
  40295. USELIGHTMAPASSHADOWMAP: boolean;
  40296. REFLECTIONMAP_3D: boolean;
  40297. REFLECTIONMAP_SPHERICAL: boolean;
  40298. REFLECTIONMAP_PLANAR: boolean;
  40299. REFLECTIONMAP_CUBIC: boolean;
  40300. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40301. REFLECTIONMAP_PROJECTION: boolean;
  40302. REFLECTIONMAP_SKYBOX: boolean;
  40303. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40304. REFLECTIONMAP_EXPLICIT: boolean;
  40305. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40306. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40307. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40308. INVERTCUBICMAP: boolean;
  40309. LOGARITHMICDEPTH: boolean;
  40310. REFRACTION: boolean;
  40311. REFRACTIONMAP_3D: boolean;
  40312. REFLECTIONOVERALPHA: boolean;
  40313. TWOSIDEDLIGHTING: boolean;
  40314. SHADOWFLOAT: boolean;
  40315. MORPHTARGETS: boolean;
  40316. MORPHTARGETS_NORMAL: boolean;
  40317. MORPHTARGETS_TANGENT: boolean;
  40318. NUM_MORPH_INFLUENCERS: number;
  40319. NONUNIFORMSCALING: boolean;
  40320. PREMULTIPLYALPHA: boolean;
  40321. IMAGEPROCESSING: boolean;
  40322. VIGNETTE: boolean;
  40323. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40324. VIGNETTEBLENDMODEOPAQUE: boolean;
  40325. TONEMAPPING: boolean;
  40326. TONEMAPPING_ACES: boolean;
  40327. CONTRAST: boolean;
  40328. COLORCURVES: boolean;
  40329. COLORGRADING: boolean;
  40330. COLORGRADING3D: boolean;
  40331. SAMPLER3DGREENDEPTH: boolean;
  40332. SAMPLER3DBGRMAP: boolean;
  40333. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40334. MULTIVIEW: boolean;
  40335. /**
  40336. * If the reflection texture on this material is in linear color space
  40337. * @hidden
  40338. */
  40339. IS_REFLECTION_LINEAR: boolean;
  40340. /**
  40341. * If the refraction texture on this material is in linear color space
  40342. * @hidden
  40343. */
  40344. IS_REFRACTION_LINEAR: boolean;
  40345. EXPOSURE: boolean;
  40346. constructor();
  40347. setReflectionMode(modeToEnable: string): void;
  40348. }
  40349. /**
  40350. * This is the default material used in Babylon. It is the best trade off between quality
  40351. * and performances.
  40352. * @see http://doc.babylonjs.com/babylon101/materials
  40353. */
  40354. export class StandardMaterial extends PushMaterial {
  40355. private _diffuseTexture;
  40356. /**
  40357. * The basic texture of the material as viewed under a light.
  40358. */
  40359. diffuseTexture: Nullable<BaseTexture>;
  40360. private _ambientTexture;
  40361. /**
  40362. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40363. */
  40364. ambientTexture: Nullable<BaseTexture>;
  40365. private _opacityTexture;
  40366. /**
  40367. * Define the transparency of the material from a texture.
  40368. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40369. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40370. */
  40371. opacityTexture: Nullable<BaseTexture>;
  40372. private _reflectionTexture;
  40373. /**
  40374. * Define the texture used to display the reflection.
  40375. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40376. */
  40377. reflectionTexture: Nullable<BaseTexture>;
  40378. private _emissiveTexture;
  40379. /**
  40380. * Define texture of the material as if self lit.
  40381. * This will be mixed in the final result even in the absence of light.
  40382. */
  40383. emissiveTexture: Nullable<BaseTexture>;
  40384. private _specularTexture;
  40385. /**
  40386. * Define how the color and intensity of the highlight given by the light in the material.
  40387. */
  40388. specularTexture: Nullable<BaseTexture>;
  40389. private _bumpTexture;
  40390. /**
  40391. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40392. * 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.
  40393. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40394. */
  40395. bumpTexture: Nullable<BaseTexture>;
  40396. private _lightmapTexture;
  40397. /**
  40398. * Complex lighting can be computationally expensive to compute at runtime.
  40399. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40400. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40401. */
  40402. lightmapTexture: Nullable<BaseTexture>;
  40403. private _refractionTexture;
  40404. /**
  40405. * Define the texture used to display the refraction.
  40406. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40407. */
  40408. refractionTexture: Nullable<BaseTexture>;
  40409. /**
  40410. * The color of the material lit by the environmental background lighting.
  40411. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40412. */
  40413. ambientColor: Color3;
  40414. /**
  40415. * The basic color of the material as viewed under a light.
  40416. */
  40417. diffuseColor: Color3;
  40418. /**
  40419. * Define how the color and intensity of the highlight given by the light in the material.
  40420. */
  40421. specularColor: Color3;
  40422. /**
  40423. * Define the color of the material as if self lit.
  40424. * This will be mixed in the final result even in the absence of light.
  40425. */
  40426. emissiveColor: Color3;
  40427. /**
  40428. * Defines how sharp are the highlights in the material.
  40429. * The bigger the value the sharper giving a more glossy feeling to the result.
  40430. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40431. */
  40432. specularPower: number;
  40433. private _useAlphaFromDiffuseTexture;
  40434. /**
  40435. * Does the transparency come from the diffuse texture alpha channel.
  40436. */
  40437. useAlphaFromDiffuseTexture: boolean;
  40438. private _useEmissiveAsIllumination;
  40439. /**
  40440. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40441. */
  40442. useEmissiveAsIllumination: boolean;
  40443. private _linkEmissiveWithDiffuse;
  40444. /**
  40445. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40446. * the emissive level when the final color is close to one.
  40447. */
  40448. linkEmissiveWithDiffuse: boolean;
  40449. private _useSpecularOverAlpha;
  40450. /**
  40451. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40452. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40453. */
  40454. useSpecularOverAlpha: boolean;
  40455. private _useReflectionOverAlpha;
  40456. /**
  40457. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40458. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40459. */
  40460. useReflectionOverAlpha: boolean;
  40461. private _disableLighting;
  40462. /**
  40463. * Does lights from the scene impacts this material.
  40464. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40465. */
  40466. disableLighting: boolean;
  40467. private _useObjectSpaceNormalMap;
  40468. /**
  40469. * Allows using an object space normal map (instead of tangent space).
  40470. */
  40471. useObjectSpaceNormalMap: boolean;
  40472. private _useParallax;
  40473. /**
  40474. * Is parallax enabled or not.
  40475. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40476. */
  40477. useParallax: boolean;
  40478. private _useParallaxOcclusion;
  40479. /**
  40480. * Is parallax occlusion enabled or not.
  40481. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40482. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40483. */
  40484. useParallaxOcclusion: boolean;
  40485. /**
  40486. * 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.
  40487. */
  40488. parallaxScaleBias: number;
  40489. private _roughness;
  40490. /**
  40491. * Helps to define how blurry the reflections should appears in the material.
  40492. */
  40493. roughness: number;
  40494. /**
  40495. * In case of refraction, define the value of the index of refraction.
  40496. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40497. */
  40498. indexOfRefraction: number;
  40499. /**
  40500. * Invert the refraction texture alongside the y axis.
  40501. * It can be useful with procedural textures or probe for instance.
  40502. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40503. */
  40504. invertRefractionY: boolean;
  40505. /**
  40506. * Defines the alpha limits in alpha test mode.
  40507. */
  40508. alphaCutOff: number;
  40509. private _useLightmapAsShadowmap;
  40510. /**
  40511. * In case of light mapping, define whether the map contains light or shadow informations.
  40512. */
  40513. useLightmapAsShadowmap: boolean;
  40514. private _diffuseFresnelParameters;
  40515. /**
  40516. * Define the diffuse fresnel parameters of the material.
  40517. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40518. */
  40519. diffuseFresnelParameters: FresnelParameters;
  40520. private _opacityFresnelParameters;
  40521. /**
  40522. * Define the opacity fresnel parameters of the material.
  40523. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40524. */
  40525. opacityFresnelParameters: FresnelParameters;
  40526. private _reflectionFresnelParameters;
  40527. /**
  40528. * Define the reflection fresnel parameters of the material.
  40529. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40530. */
  40531. reflectionFresnelParameters: FresnelParameters;
  40532. private _refractionFresnelParameters;
  40533. /**
  40534. * Define the refraction fresnel parameters of the material.
  40535. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40536. */
  40537. refractionFresnelParameters: FresnelParameters;
  40538. private _emissiveFresnelParameters;
  40539. /**
  40540. * Define the emissive fresnel parameters of the material.
  40541. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40542. */
  40543. emissiveFresnelParameters: FresnelParameters;
  40544. private _useReflectionFresnelFromSpecular;
  40545. /**
  40546. * If true automatically deducts the fresnels values from the material specularity.
  40547. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40548. */
  40549. useReflectionFresnelFromSpecular: boolean;
  40550. private _useGlossinessFromSpecularMapAlpha;
  40551. /**
  40552. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40553. */
  40554. useGlossinessFromSpecularMapAlpha: boolean;
  40555. private _maxSimultaneousLights;
  40556. /**
  40557. * Defines the maximum number of lights that can be used in the material
  40558. */
  40559. maxSimultaneousLights: number;
  40560. private _invertNormalMapX;
  40561. /**
  40562. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40563. */
  40564. invertNormalMapX: boolean;
  40565. private _invertNormalMapY;
  40566. /**
  40567. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40568. */
  40569. invertNormalMapY: boolean;
  40570. private _twoSidedLighting;
  40571. /**
  40572. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40573. */
  40574. twoSidedLighting: boolean;
  40575. /**
  40576. * Default configuration related to image processing available in the standard Material.
  40577. */
  40578. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40579. /**
  40580. * Gets the image processing configuration used either in this material.
  40581. */
  40582. /**
  40583. * Sets the Default image processing configuration used either in the this material.
  40584. *
  40585. * If sets to null, the scene one is in use.
  40586. */
  40587. imageProcessingConfiguration: ImageProcessingConfiguration;
  40588. /**
  40589. * Keep track of the image processing observer to allow dispose and replace.
  40590. */
  40591. private _imageProcessingObserver;
  40592. /**
  40593. * Attaches a new image processing configuration to the Standard Material.
  40594. * @param configuration
  40595. */
  40596. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40597. /**
  40598. * Gets wether the color curves effect is enabled.
  40599. */
  40600. /**
  40601. * Sets wether the color curves effect is enabled.
  40602. */
  40603. cameraColorCurvesEnabled: boolean;
  40604. /**
  40605. * Gets wether the color grading effect is enabled.
  40606. */
  40607. /**
  40608. * Gets wether the color grading effect is enabled.
  40609. */
  40610. cameraColorGradingEnabled: boolean;
  40611. /**
  40612. * Gets wether tonemapping is enabled or not.
  40613. */
  40614. /**
  40615. * Sets wether tonemapping is enabled or not
  40616. */
  40617. cameraToneMappingEnabled: boolean;
  40618. /**
  40619. * The camera exposure used on this material.
  40620. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40621. * This corresponds to a photographic exposure.
  40622. */
  40623. /**
  40624. * The camera exposure used on this material.
  40625. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40626. * This corresponds to a photographic exposure.
  40627. */
  40628. cameraExposure: number;
  40629. /**
  40630. * Gets The camera contrast used on this material.
  40631. */
  40632. /**
  40633. * Sets The camera contrast used on this material.
  40634. */
  40635. cameraContrast: number;
  40636. /**
  40637. * Gets the Color Grading 2D Lookup Texture.
  40638. */
  40639. /**
  40640. * Sets the Color Grading 2D Lookup Texture.
  40641. */
  40642. cameraColorGradingTexture: Nullable<BaseTexture>;
  40643. /**
  40644. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40645. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40646. * 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;
  40647. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40648. */
  40649. /**
  40650. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40651. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40652. * 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;
  40653. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40654. */
  40655. cameraColorCurves: Nullable<ColorCurves>;
  40656. /**
  40657. * Custom callback helping to override the default shader used in the material.
  40658. */
  40659. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40660. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40661. protected _worldViewProjectionMatrix: Matrix;
  40662. protected _globalAmbientColor: Color3;
  40663. protected _useLogarithmicDepth: boolean;
  40664. /**
  40665. * Instantiates a new standard material.
  40666. * This is the default material used in Babylon. It is the best trade off between quality
  40667. * and performances.
  40668. * @see http://doc.babylonjs.com/babylon101/materials
  40669. * @param name Define the name of the material in the scene
  40670. * @param scene Define the scene the material belong to
  40671. */
  40672. constructor(name: string, scene: Scene);
  40673. /**
  40674. * Gets a boolean indicating that current material needs to register RTT
  40675. */
  40676. readonly hasRenderTargetTextures: boolean;
  40677. /**
  40678. * Gets the current class name of the material e.g. "StandardMaterial"
  40679. * Mainly use in serialization.
  40680. * @returns the class name
  40681. */
  40682. getClassName(): string;
  40683. /**
  40684. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40685. * You can try switching to logarithmic depth.
  40686. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40687. */
  40688. useLogarithmicDepth: boolean;
  40689. /**
  40690. * Specifies if the material will require alpha blending
  40691. * @returns a boolean specifying if alpha blending is needed
  40692. */
  40693. needAlphaBlending(): boolean;
  40694. /**
  40695. * Specifies if this material should be rendered in alpha test mode
  40696. * @returns a boolean specifying if an alpha test is needed.
  40697. */
  40698. needAlphaTesting(): boolean;
  40699. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40700. /**
  40701. * Get the texture used for alpha test purpose.
  40702. * @returns the diffuse texture in case of the standard material.
  40703. */
  40704. getAlphaTestTexture(): Nullable<BaseTexture>;
  40705. /**
  40706. * Get if the submesh is ready to be used and all its information available.
  40707. * Child classes can use it to update shaders
  40708. * @param mesh defines the mesh to check
  40709. * @param subMesh defines which submesh to check
  40710. * @param useInstances specifies that instances should be used
  40711. * @returns a boolean indicating that the submesh is ready or not
  40712. */
  40713. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40714. /**
  40715. * Builds the material UBO layouts.
  40716. * Used internally during the effect preparation.
  40717. */
  40718. buildUniformLayout(): void;
  40719. /**
  40720. * Unbinds the material from the mesh
  40721. */
  40722. unbind(): void;
  40723. /**
  40724. * Binds the submesh to this material by preparing the effect and shader to draw
  40725. * @param world defines the world transformation matrix
  40726. * @param mesh defines the mesh containing the submesh
  40727. * @param subMesh defines the submesh to bind the material to
  40728. */
  40729. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40730. /**
  40731. * Get the list of animatables in the material.
  40732. * @returns the list of animatables object used in the material
  40733. */
  40734. getAnimatables(): IAnimatable[];
  40735. /**
  40736. * Gets the active textures from the material
  40737. * @returns an array of textures
  40738. */
  40739. getActiveTextures(): BaseTexture[];
  40740. /**
  40741. * Specifies if the material uses a texture
  40742. * @param texture defines the texture to check against the material
  40743. * @returns a boolean specifying if the material uses the texture
  40744. */
  40745. hasTexture(texture: BaseTexture): boolean;
  40746. /**
  40747. * Disposes the material
  40748. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40749. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40750. */
  40751. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40752. /**
  40753. * Makes a duplicate of the material, and gives it a new name
  40754. * @param name defines the new name for the duplicated material
  40755. * @returns the cloned material
  40756. */
  40757. clone(name: string): StandardMaterial;
  40758. /**
  40759. * Serializes this material in a JSON representation
  40760. * @returns the serialized material object
  40761. */
  40762. serialize(): any;
  40763. /**
  40764. * Creates a standard material from parsed material data
  40765. * @param source defines the JSON representation of the material
  40766. * @param scene defines the hosting scene
  40767. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40768. * @returns a new standard material
  40769. */
  40770. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40771. /**
  40772. * Are diffuse textures enabled in the application.
  40773. */
  40774. static DiffuseTextureEnabled: boolean;
  40775. /**
  40776. * Are ambient textures enabled in the application.
  40777. */
  40778. static AmbientTextureEnabled: boolean;
  40779. /**
  40780. * Are opacity textures enabled in the application.
  40781. */
  40782. static OpacityTextureEnabled: boolean;
  40783. /**
  40784. * Are reflection textures enabled in the application.
  40785. */
  40786. static ReflectionTextureEnabled: boolean;
  40787. /**
  40788. * Are emissive textures enabled in the application.
  40789. */
  40790. static EmissiveTextureEnabled: boolean;
  40791. /**
  40792. * Are specular textures enabled in the application.
  40793. */
  40794. static SpecularTextureEnabled: boolean;
  40795. /**
  40796. * Are bump textures enabled in the application.
  40797. */
  40798. static BumpTextureEnabled: boolean;
  40799. /**
  40800. * Are lightmap textures enabled in the application.
  40801. */
  40802. static LightmapTextureEnabled: boolean;
  40803. /**
  40804. * Are refraction textures enabled in the application.
  40805. */
  40806. static RefractionTextureEnabled: boolean;
  40807. /**
  40808. * Are color grading textures enabled in the application.
  40809. */
  40810. static ColorGradingTextureEnabled: boolean;
  40811. /**
  40812. * Are fresnels enabled in the application.
  40813. */
  40814. static FresnelEnabled: boolean;
  40815. }
  40816. }
  40817. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40818. import { Scene } from "babylonjs/scene";
  40819. import { Texture } from "babylonjs/Materials/Textures/texture";
  40820. /**
  40821. * A class extending Texture allowing drawing on a texture
  40822. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40823. */
  40824. export class DynamicTexture extends Texture {
  40825. private _generateMipMaps;
  40826. private _canvas;
  40827. private _context;
  40828. private _engine;
  40829. /**
  40830. * Creates a DynamicTexture
  40831. * @param name defines the name of the texture
  40832. * @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
  40833. * @param scene defines the scene where you want the texture
  40834. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40835. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40836. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40837. */
  40838. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40839. /**
  40840. * Get the current class name of the texture useful for serialization or dynamic coding.
  40841. * @returns "DynamicTexture"
  40842. */
  40843. getClassName(): string;
  40844. /**
  40845. * Gets the current state of canRescale
  40846. */
  40847. readonly canRescale: boolean;
  40848. private _recreate;
  40849. /**
  40850. * Scales the texture
  40851. * @param ratio the scale factor to apply to both width and height
  40852. */
  40853. scale(ratio: number): void;
  40854. /**
  40855. * Resizes the texture
  40856. * @param width the new width
  40857. * @param height the new height
  40858. */
  40859. scaleTo(width: number, height: number): void;
  40860. /**
  40861. * Gets the context of the canvas used by the texture
  40862. * @returns the canvas context of the dynamic texture
  40863. */
  40864. getContext(): CanvasRenderingContext2D;
  40865. /**
  40866. * Clears the texture
  40867. */
  40868. clear(): void;
  40869. /**
  40870. * Updates the texture
  40871. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40872. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40873. */
  40874. update(invertY?: boolean, premulAlpha?: boolean): void;
  40875. /**
  40876. * Draws text onto the texture
  40877. * @param text defines the text to be drawn
  40878. * @param x defines the placement of the text from the left
  40879. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40880. * @param font defines the font to be used with font-style, font-size, font-name
  40881. * @param color defines the color used for the text
  40882. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40883. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40884. * @param update defines whether texture is immediately update (default is true)
  40885. */
  40886. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40887. /**
  40888. * Clones the texture
  40889. * @returns the clone of the texture.
  40890. */
  40891. clone(): DynamicTexture;
  40892. /**
  40893. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40894. * @returns a serialized dynamic texture object
  40895. */
  40896. serialize(): any;
  40897. /** @hidden */
  40898. _rebuild(): void;
  40899. }
  40900. }
  40901. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40902. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40903. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40904. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40905. /** @hidden */
  40906. export var imageProcessingPixelShader: {
  40907. name: string;
  40908. shader: string;
  40909. };
  40910. }
  40911. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40912. import { Nullable } from "babylonjs/types";
  40913. import { Color4 } from "babylonjs/Maths/math";
  40914. import { Camera } from "babylonjs/Cameras/camera";
  40915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40916. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40917. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40919. import { Engine } from "babylonjs/Engines/engine";
  40920. import "babylonjs/Shaders/imageProcessing.fragment";
  40921. import "babylonjs/Shaders/postprocess.vertex";
  40922. /**
  40923. * ImageProcessingPostProcess
  40924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40925. */
  40926. export class ImageProcessingPostProcess extends PostProcess {
  40927. /**
  40928. * Default configuration related to image processing available in the PBR Material.
  40929. */
  40930. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40931. /**
  40932. * Gets the image processing configuration used either in this material.
  40933. */
  40934. /**
  40935. * Sets the Default image processing configuration used either in the this material.
  40936. *
  40937. * If sets to null, the scene one is in use.
  40938. */
  40939. imageProcessingConfiguration: ImageProcessingConfiguration;
  40940. /**
  40941. * Keep track of the image processing observer to allow dispose and replace.
  40942. */
  40943. private _imageProcessingObserver;
  40944. /**
  40945. * Attaches a new image processing configuration to the PBR Material.
  40946. * @param configuration
  40947. */
  40948. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40949. /**
  40950. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40951. */
  40952. /**
  40953. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40954. */
  40955. colorCurves: Nullable<ColorCurves>;
  40956. /**
  40957. * Gets wether the color curves effect is enabled.
  40958. */
  40959. /**
  40960. * Sets wether the color curves effect is enabled.
  40961. */
  40962. colorCurvesEnabled: boolean;
  40963. /**
  40964. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40965. */
  40966. /**
  40967. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40968. */
  40969. colorGradingTexture: Nullable<BaseTexture>;
  40970. /**
  40971. * Gets wether the color grading effect is enabled.
  40972. */
  40973. /**
  40974. * Gets wether the color grading effect is enabled.
  40975. */
  40976. colorGradingEnabled: boolean;
  40977. /**
  40978. * Gets exposure used in the effect.
  40979. */
  40980. /**
  40981. * Sets exposure used in the effect.
  40982. */
  40983. exposure: number;
  40984. /**
  40985. * Gets wether tonemapping is enabled or not.
  40986. */
  40987. /**
  40988. * Sets wether tonemapping is enabled or not
  40989. */
  40990. toneMappingEnabled: boolean;
  40991. /**
  40992. * Gets the type of tone mapping effect.
  40993. */
  40994. /**
  40995. * Sets the type of tone mapping effect.
  40996. */
  40997. toneMappingType: number;
  40998. /**
  40999. * Gets contrast used in the effect.
  41000. */
  41001. /**
  41002. * Sets contrast used in the effect.
  41003. */
  41004. contrast: number;
  41005. /**
  41006. * Gets Vignette stretch size.
  41007. */
  41008. /**
  41009. * Sets Vignette stretch size.
  41010. */
  41011. vignetteStretch: number;
  41012. /**
  41013. * Gets Vignette centre X Offset.
  41014. */
  41015. /**
  41016. * Sets Vignette centre X Offset.
  41017. */
  41018. vignetteCentreX: number;
  41019. /**
  41020. * Gets Vignette centre Y Offset.
  41021. */
  41022. /**
  41023. * Sets Vignette centre Y Offset.
  41024. */
  41025. vignetteCentreY: number;
  41026. /**
  41027. * Gets Vignette weight or intensity of the vignette effect.
  41028. */
  41029. /**
  41030. * Sets Vignette weight or intensity of the vignette effect.
  41031. */
  41032. vignetteWeight: number;
  41033. /**
  41034. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41035. * if vignetteEnabled is set to true.
  41036. */
  41037. /**
  41038. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41039. * if vignetteEnabled is set to true.
  41040. */
  41041. vignetteColor: Color4;
  41042. /**
  41043. * Gets Camera field of view used by the Vignette effect.
  41044. */
  41045. /**
  41046. * Sets Camera field of view used by the Vignette effect.
  41047. */
  41048. vignetteCameraFov: number;
  41049. /**
  41050. * Gets the vignette blend mode allowing different kind of effect.
  41051. */
  41052. /**
  41053. * Sets the vignette blend mode allowing different kind of effect.
  41054. */
  41055. vignetteBlendMode: number;
  41056. /**
  41057. * Gets wether the vignette effect is enabled.
  41058. */
  41059. /**
  41060. * Sets wether the vignette effect is enabled.
  41061. */
  41062. vignetteEnabled: boolean;
  41063. private _fromLinearSpace;
  41064. /**
  41065. * Gets wether the input of the processing is in Gamma or Linear Space.
  41066. */
  41067. /**
  41068. * Sets wether the input of the processing is in Gamma or Linear Space.
  41069. */
  41070. fromLinearSpace: boolean;
  41071. /**
  41072. * Defines cache preventing GC.
  41073. */
  41074. private _defines;
  41075. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41076. /**
  41077. * "ImageProcessingPostProcess"
  41078. * @returns "ImageProcessingPostProcess"
  41079. */
  41080. getClassName(): string;
  41081. protected _updateParameters(): void;
  41082. dispose(camera?: Camera): void;
  41083. }
  41084. }
  41085. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41086. import { Scene } from "babylonjs/scene";
  41087. import { Color3 } from "babylonjs/Maths/math";
  41088. import { Mesh } from "babylonjs/Meshes/mesh";
  41089. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41090. import { Nullable } from "babylonjs/types";
  41091. /**
  41092. * Class containing static functions to help procedurally build meshes
  41093. */
  41094. export class GroundBuilder {
  41095. /**
  41096. * Creates a ground mesh
  41097. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41098. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41100. * @param name defines the name of the mesh
  41101. * @param options defines the options used to create the mesh
  41102. * @param scene defines the hosting scene
  41103. * @returns the ground mesh
  41104. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41105. */
  41106. static CreateGround(name: string, options: {
  41107. width?: number;
  41108. height?: number;
  41109. subdivisions?: number;
  41110. subdivisionsX?: number;
  41111. subdivisionsY?: number;
  41112. updatable?: boolean;
  41113. }, scene: any): Mesh;
  41114. /**
  41115. * Creates a tiled ground mesh
  41116. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41117. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41118. * * 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
  41119. * * 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
  41120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41121. * @param name defines the name of the mesh
  41122. * @param options defines the options used to create the mesh
  41123. * @param scene defines the hosting scene
  41124. * @returns the tiled ground mesh
  41125. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41126. */
  41127. static CreateTiledGround(name: string, options: {
  41128. xmin: number;
  41129. zmin: number;
  41130. xmax: number;
  41131. zmax: number;
  41132. subdivisions?: {
  41133. w: number;
  41134. h: number;
  41135. };
  41136. precision?: {
  41137. w: number;
  41138. h: number;
  41139. };
  41140. updatable?: boolean;
  41141. }, scene?: Nullable<Scene>): Mesh;
  41142. /**
  41143. * Creates a ground mesh from a height map
  41144. * * The parameter `url` sets the URL of the height map image resource.
  41145. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41146. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41147. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41148. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41149. * * 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.
  41150. * * 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).
  41151. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41153. * @param name defines the name of the mesh
  41154. * @param url defines the url to the height map
  41155. * @param options defines the options used to create the mesh
  41156. * @param scene defines the hosting scene
  41157. * @returns the ground mesh
  41158. * @see https://doc.babylonjs.com/babylon101/height_map
  41159. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41160. */
  41161. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41162. width?: number;
  41163. height?: number;
  41164. subdivisions?: number;
  41165. minHeight?: number;
  41166. maxHeight?: number;
  41167. colorFilter?: Color3;
  41168. alphaFilter?: number;
  41169. updatable?: boolean;
  41170. onReady?: (mesh: GroundMesh) => void;
  41171. }, scene?: Nullable<Scene>): GroundMesh;
  41172. }
  41173. }
  41174. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41175. import { Vector4 } from "babylonjs/Maths/math";
  41176. import { Mesh } from "babylonjs/Meshes/mesh";
  41177. /**
  41178. * Class containing static functions to help procedurally build meshes
  41179. */
  41180. export class TorusBuilder {
  41181. /**
  41182. * Creates a torus mesh
  41183. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41184. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41185. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41189. * @param name defines the name of the mesh
  41190. * @param options defines the options used to create the mesh
  41191. * @param scene defines the hosting scene
  41192. * @returns the torus mesh
  41193. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41194. */
  41195. static CreateTorus(name: string, options: {
  41196. diameter?: number;
  41197. thickness?: number;
  41198. tessellation?: number;
  41199. updatable?: boolean;
  41200. sideOrientation?: number;
  41201. frontUVs?: Vector4;
  41202. backUVs?: Vector4;
  41203. }, scene: any): Mesh;
  41204. }
  41205. }
  41206. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41207. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41208. import { Mesh } from "babylonjs/Meshes/mesh";
  41209. /**
  41210. * Class containing static functions to help procedurally build meshes
  41211. */
  41212. export class CylinderBuilder {
  41213. /**
  41214. * Creates a cylinder or a cone mesh
  41215. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41216. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41217. * * 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.
  41218. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41219. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41220. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41221. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41222. * * 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).
  41223. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41224. * * 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).
  41225. * * 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
  41226. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41227. * * 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
  41228. * * 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.
  41229. * * If `enclose` is false, a ring surface is one element.
  41230. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41231. * * 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
  41232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41235. * @param name defines the name of the mesh
  41236. * @param options defines the options used to create the mesh
  41237. * @param scene defines the hosting scene
  41238. * @returns the cylinder mesh
  41239. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41240. */
  41241. static CreateCylinder(name: string, options: {
  41242. height?: number;
  41243. diameterTop?: number;
  41244. diameterBottom?: number;
  41245. diameter?: number;
  41246. tessellation?: number;
  41247. subdivisions?: number;
  41248. arc?: number;
  41249. faceColors?: Color4[];
  41250. faceUV?: Vector4[];
  41251. updatable?: boolean;
  41252. hasRings?: boolean;
  41253. enclose?: boolean;
  41254. cap?: number;
  41255. sideOrientation?: number;
  41256. frontUVs?: Vector4;
  41257. backUVs?: Vector4;
  41258. }, scene: any): Mesh;
  41259. }
  41260. }
  41261. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41262. import { Observable } from "babylonjs/Misc/observable";
  41263. import { Nullable } from "babylonjs/types";
  41264. import { Camera } from "babylonjs/Cameras/camera";
  41265. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41266. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41267. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41268. import { Scene } from "babylonjs/scene";
  41269. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41270. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41272. import { Mesh } from "babylonjs/Meshes/mesh";
  41273. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41274. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41275. import "babylonjs/Meshes/Builders/groundBuilder";
  41276. import "babylonjs/Meshes/Builders/torusBuilder";
  41277. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41278. import "babylonjs/Gamepads/gamepadSceneComponent";
  41279. import "babylonjs/Animations/animatable";
  41280. /**
  41281. * Options to modify the vr teleportation behavior.
  41282. */
  41283. export interface VRTeleportationOptions {
  41284. /**
  41285. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41286. */
  41287. floorMeshName?: string;
  41288. /**
  41289. * A list of meshes to be used as the teleportation floor. (default: empty)
  41290. */
  41291. floorMeshes?: Mesh[];
  41292. }
  41293. /**
  41294. * Options to modify the vr experience helper's behavior.
  41295. */
  41296. export interface VRExperienceHelperOptions extends WebVROptions {
  41297. /**
  41298. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41299. */
  41300. createDeviceOrientationCamera?: boolean;
  41301. /**
  41302. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41303. */
  41304. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41305. /**
  41306. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41307. */
  41308. laserToggle?: boolean;
  41309. /**
  41310. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41311. */
  41312. floorMeshes?: Mesh[];
  41313. /**
  41314. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41315. */
  41316. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41317. }
  41318. /**
  41319. * Event containing information after VR has been entered
  41320. */
  41321. export class OnAfterEnteringVRObservableEvent {
  41322. /**
  41323. * If entering vr was successful
  41324. */
  41325. success: boolean;
  41326. }
  41327. /**
  41328. * Helps to quickly add VR support to an existing scene.
  41329. * See http://doc.babylonjs.com/how_to/webvr_helper
  41330. */
  41331. export class VRExperienceHelper {
  41332. /** Options to modify the vr experience helper's behavior. */
  41333. webVROptions: VRExperienceHelperOptions;
  41334. private _scene;
  41335. private _position;
  41336. private _btnVR;
  41337. private _btnVRDisplayed;
  41338. private _webVRsupported;
  41339. private _webVRready;
  41340. private _webVRrequesting;
  41341. private _webVRpresenting;
  41342. private _hasEnteredVR;
  41343. private _fullscreenVRpresenting;
  41344. private _canvas;
  41345. private _webVRCamera;
  41346. private _vrDeviceOrientationCamera;
  41347. private _deviceOrientationCamera;
  41348. private _existingCamera;
  41349. private _onKeyDown;
  41350. private _onVrDisplayPresentChange;
  41351. private _onVRDisplayChanged;
  41352. private _onVRRequestPresentStart;
  41353. private _onVRRequestPresentComplete;
  41354. /**
  41355. * Observable raised right before entering VR.
  41356. */
  41357. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41358. /**
  41359. * Observable raised when entering VR has completed.
  41360. */
  41361. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41362. /**
  41363. * Observable raised when exiting VR.
  41364. */
  41365. onExitingVRObservable: Observable<VRExperienceHelper>;
  41366. /**
  41367. * Observable raised when controller mesh is loaded.
  41368. */
  41369. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41370. /** Return this.onEnteringVRObservable
  41371. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41372. */
  41373. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41374. /** Return this.onExitingVRObservable
  41375. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41376. */
  41377. readonly onExitingVR: Observable<VRExperienceHelper>;
  41378. /** Return this.onControllerMeshLoadedObservable
  41379. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41380. */
  41381. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41382. private _rayLength;
  41383. private _useCustomVRButton;
  41384. private _teleportationRequested;
  41385. private _teleportActive;
  41386. private _floorMeshName;
  41387. private _floorMeshesCollection;
  41388. private _rotationAllowed;
  41389. private _teleportBackwardsVector;
  41390. private _teleportationTarget;
  41391. private _isDefaultTeleportationTarget;
  41392. private _postProcessMove;
  41393. private _teleportationFillColor;
  41394. private _teleportationBorderColor;
  41395. private _rotationAngle;
  41396. private _haloCenter;
  41397. private _cameraGazer;
  41398. private _padSensibilityUp;
  41399. private _padSensibilityDown;
  41400. private _leftController;
  41401. private _rightController;
  41402. /**
  41403. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41404. */
  41405. onNewMeshSelected: Observable<AbstractMesh>;
  41406. /**
  41407. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41408. */
  41409. onNewMeshPicked: Observable<PickingInfo>;
  41410. private _circleEase;
  41411. /**
  41412. * Observable raised before camera teleportation
  41413. */
  41414. onBeforeCameraTeleport: Observable<Vector3>;
  41415. /**
  41416. * Observable raised after camera teleportation
  41417. */
  41418. onAfterCameraTeleport: Observable<Vector3>;
  41419. /**
  41420. * Observable raised when current selected mesh gets unselected
  41421. */
  41422. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41423. private _raySelectionPredicate;
  41424. /**
  41425. * To be optionaly changed by user to define custom ray selection
  41426. */
  41427. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41428. /**
  41429. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41430. */
  41431. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41432. /**
  41433. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41434. */
  41435. teleportationEnabled: boolean;
  41436. private _defaultHeight;
  41437. private _teleportationInitialized;
  41438. private _interactionsEnabled;
  41439. private _interactionsRequested;
  41440. private _displayGaze;
  41441. private _displayLaserPointer;
  41442. /**
  41443. * The mesh used to display where the user is going to teleport.
  41444. */
  41445. /**
  41446. * Sets the mesh to be used to display where the user is going to teleport.
  41447. */
  41448. teleportationTarget: Mesh;
  41449. /**
  41450. * 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
  41451. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41452. * See http://doc.babylonjs.com/resources/baking_transformations
  41453. */
  41454. gazeTrackerMesh: Mesh;
  41455. /**
  41456. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41457. */
  41458. updateGazeTrackerScale: boolean;
  41459. /**
  41460. * If the gaze trackers color should be updated when selecting meshes
  41461. */
  41462. updateGazeTrackerColor: boolean;
  41463. /**
  41464. * The gaze tracking mesh corresponding to the left controller
  41465. */
  41466. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41467. /**
  41468. * The gaze tracking mesh corresponding to the right controller
  41469. */
  41470. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41471. /**
  41472. * If the ray of the gaze should be displayed.
  41473. */
  41474. /**
  41475. * Sets if the ray of the gaze should be displayed.
  41476. */
  41477. displayGaze: boolean;
  41478. /**
  41479. * If the ray of the LaserPointer should be displayed.
  41480. */
  41481. /**
  41482. * Sets if the ray of the LaserPointer should be displayed.
  41483. */
  41484. displayLaserPointer: boolean;
  41485. /**
  41486. * The deviceOrientationCamera used as the camera when not in VR.
  41487. */
  41488. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41489. /**
  41490. * Based on the current WebVR support, returns the current VR camera used.
  41491. */
  41492. readonly currentVRCamera: Nullable<Camera>;
  41493. /**
  41494. * The webVRCamera which is used when in VR.
  41495. */
  41496. readonly webVRCamera: WebVRFreeCamera;
  41497. /**
  41498. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41499. */
  41500. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41501. private readonly _teleportationRequestInitiated;
  41502. /**
  41503. * Defines wether or not Pointer lock should be requested when switching to
  41504. * full screen.
  41505. */
  41506. requestPointerLockOnFullScreen: boolean;
  41507. /**
  41508. * Instantiates a VRExperienceHelper.
  41509. * Helps to quickly add VR support to an existing scene.
  41510. * @param scene The scene the VRExperienceHelper belongs to.
  41511. * @param webVROptions Options to modify the vr experience helper's behavior.
  41512. */
  41513. constructor(scene: Scene,
  41514. /** Options to modify the vr experience helper's behavior. */
  41515. webVROptions?: VRExperienceHelperOptions);
  41516. private _onDefaultMeshLoaded;
  41517. private _onResize;
  41518. private _onFullscreenChange;
  41519. /**
  41520. * Gets a value indicating if we are currently in VR mode.
  41521. */
  41522. readonly isInVRMode: boolean;
  41523. private onVrDisplayPresentChange;
  41524. private onVRDisplayChanged;
  41525. private moveButtonToBottomRight;
  41526. private displayVRButton;
  41527. private updateButtonVisibility;
  41528. private _cachedAngularSensibility;
  41529. /**
  41530. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41531. * Otherwise, will use the fullscreen API.
  41532. */
  41533. enterVR(): void;
  41534. /**
  41535. * Attempt to exit VR, or fullscreen.
  41536. */
  41537. exitVR(): void;
  41538. /**
  41539. * The position of the vr experience helper.
  41540. */
  41541. /**
  41542. * Sets the position of the vr experience helper.
  41543. */
  41544. position: Vector3;
  41545. /**
  41546. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41547. */
  41548. enableInteractions(): void;
  41549. private readonly _noControllerIsActive;
  41550. private beforeRender;
  41551. private _isTeleportationFloor;
  41552. /**
  41553. * Adds a floor mesh to be used for teleportation.
  41554. * @param floorMesh the mesh to be used for teleportation.
  41555. */
  41556. addFloorMesh(floorMesh: Mesh): void;
  41557. /**
  41558. * Removes a floor mesh from being used for teleportation.
  41559. * @param floorMesh the mesh to be removed.
  41560. */
  41561. removeFloorMesh(floorMesh: Mesh): void;
  41562. /**
  41563. * Enables interactions and teleportation using the VR controllers and gaze.
  41564. * @param vrTeleportationOptions options to modify teleportation behavior.
  41565. */
  41566. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41567. private _onNewGamepadConnected;
  41568. private _tryEnableInteractionOnController;
  41569. private _onNewGamepadDisconnected;
  41570. private _enableInteractionOnController;
  41571. private _checkTeleportWithRay;
  41572. private _checkRotate;
  41573. private _checkTeleportBackwards;
  41574. private _enableTeleportationOnController;
  41575. private _createTeleportationCircles;
  41576. private _displayTeleportationTarget;
  41577. private _hideTeleportationTarget;
  41578. private _rotateCamera;
  41579. private _moveTeleportationSelectorTo;
  41580. private _workingVector;
  41581. private _workingQuaternion;
  41582. private _workingMatrix;
  41583. /**
  41584. * Teleports the users feet to the desired location
  41585. * @param location The location where the user's feet should be placed
  41586. */
  41587. teleportCamera(location: Vector3): void;
  41588. private _convertNormalToDirectionOfRay;
  41589. private _castRayAndSelectObject;
  41590. private _notifySelectedMeshUnselected;
  41591. /**
  41592. * Sets the color of the laser ray from the vr controllers.
  41593. * @param color new color for the ray.
  41594. */
  41595. changeLaserColor(color: Color3): void;
  41596. /**
  41597. * Sets the color of the ray from the vr headsets gaze.
  41598. * @param color new color for the ray.
  41599. */
  41600. changeGazeColor(color: Color3): void;
  41601. /**
  41602. * Exits VR and disposes of the vr experience helper
  41603. */
  41604. dispose(): void;
  41605. /**
  41606. * Gets the name of the VRExperienceHelper class
  41607. * @returns "VRExperienceHelper"
  41608. */
  41609. getClassName(): string;
  41610. }
  41611. }
  41612. declare module "babylonjs/Cameras/VR/index" {
  41613. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41614. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41615. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41616. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41617. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41618. export * from "babylonjs/Cameras/VR/webVRCamera";
  41619. }
  41620. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41621. import { Observable } from "babylonjs/Misc/observable";
  41622. import { Nullable } from "babylonjs/types";
  41623. import { IDisposable, Scene } from "babylonjs/scene";
  41624. import { Vector3 } from "babylonjs/Maths/math";
  41625. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41626. import { Ray } from "babylonjs/Culling/ray";
  41627. /**
  41628. * Manages an XRSession
  41629. * @see https://doc.babylonjs.com/how_to/webxr
  41630. */
  41631. export class WebXRSessionManager implements IDisposable {
  41632. private scene;
  41633. /**
  41634. * Fires every time a new xrFrame arrives which can be used to update the camera
  41635. */
  41636. onXRFrameObservable: Observable<any>;
  41637. /**
  41638. * Fires when the xr session is ended either by the device or manually done
  41639. */
  41640. onXRSessionEnded: Observable<any>;
  41641. /** @hidden */
  41642. _xrSession: XRSession;
  41643. /** @hidden */
  41644. _frameOfReference: XRFrameOfReference;
  41645. /** @hidden */
  41646. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41647. /** @hidden */
  41648. _currentXRFrame: Nullable<XRFrame>;
  41649. private _xrNavigator;
  41650. private _xrDevice;
  41651. private _tmpMatrix;
  41652. /**
  41653. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41654. * @param scene The scene which the session should be created for
  41655. */
  41656. constructor(scene: Scene);
  41657. /**
  41658. * Initializes the manager
  41659. * After initialization enterXR can be called to start an XR session
  41660. * @returns Promise which resolves after it is initialized
  41661. */
  41662. initializeAsync(): Promise<void>;
  41663. /**
  41664. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41665. * @param sessionCreationOptions xr options to create the session with
  41666. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41667. * @returns Promise which resolves after it enters XR
  41668. */
  41669. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41670. /**
  41671. * Stops the xrSession and restores the renderloop
  41672. * @returns Promise which resolves after it exits XR
  41673. */
  41674. exitXRAsync(): Promise<void>;
  41675. /**
  41676. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41677. * @param ray ray to cast into the environment
  41678. * @returns Promise which resolves with a collision point in the environment if it exists
  41679. */
  41680. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41681. /**
  41682. * Checks if a session would be supported for the creation options specified
  41683. * @param options creation options to check if they are supported
  41684. * @returns true if supported
  41685. */
  41686. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41687. /**
  41688. * @hidden
  41689. * Converts the render layer of xrSession to a render target
  41690. * @param session session to create render target for
  41691. * @param scene scene the new render target should be created for
  41692. */
  41693. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41694. /**
  41695. * Disposes of the session manager
  41696. */
  41697. dispose(): void;
  41698. }
  41699. }
  41700. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41701. import { Scene } from "babylonjs/scene";
  41702. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41703. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41704. /**
  41705. * WebXR Camera which holds the views for the xrSession
  41706. * @see https://doc.babylonjs.com/how_to/webxr
  41707. */
  41708. export class WebXRCamera extends FreeCamera {
  41709. private static _TmpMatrix;
  41710. /**
  41711. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41712. * @param name the name of the camera
  41713. * @param scene the scene to add the camera to
  41714. */
  41715. constructor(name: string, scene: Scene);
  41716. private _updateNumberOfRigCameras;
  41717. /** @hidden */
  41718. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41719. /**
  41720. * Updates the cameras position from the current pose information of the XR session
  41721. * @param xrSessionManager the session containing pose information
  41722. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41723. */
  41724. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41725. }
  41726. }
  41727. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41728. import { Nullable } from "babylonjs/types";
  41729. import { Observable } from "babylonjs/Misc/observable";
  41730. import { IDisposable, Scene } from "babylonjs/scene";
  41731. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41733. import { Ray } from "babylonjs/Culling/ray";
  41734. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41735. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41736. /**
  41737. * States of the webXR experience
  41738. */
  41739. export enum WebXRState {
  41740. /**
  41741. * Transitioning to being in XR mode
  41742. */
  41743. ENTERING_XR = 0,
  41744. /**
  41745. * Transitioning to non XR mode
  41746. */
  41747. EXITING_XR = 1,
  41748. /**
  41749. * In XR mode and presenting
  41750. */
  41751. IN_XR = 2,
  41752. /**
  41753. * Not entered XR mode
  41754. */
  41755. NOT_IN_XR = 3
  41756. }
  41757. /**
  41758. * Helper class used to enable XR
  41759. * @see https://doc.babylonjs.com/how_to/webxr
  41760. */
  41761. export class WebXRExperienceHelper implements IDisposable {
  41762. private scene;
  41763. /**
  41764. * 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
  41765. */
  41766. container: AbstractMesh;
  41767. /**
  41768. * Camera used to render xr content
  41769. */
  41770. camera: WebXRCamera;
  41771. /**
  41772. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41773. */
  41774. state: WebXRState;
  41775. private _setState;
  41776. private static _TmpVector;
  41777. /**
  41778. * Fires when the state of the experience helper has changed
  41779. */
  41780. onStateChangedObservable: Observable<WebXRState>;
  41781. /** @hidden */
  41782. _sessionManager: WebXRSessionManager;
  41783. private _nonVRCamera;
  41784. private _originalSceneAutoClear;
  41785. private _supported;
  41786. /**
  41787. * Creates the experience helper
  41788. * @param scene the scene to attach the experience helper to
  41789. * @returns a promise for the experience helper
  41790. */
  41791. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41792. /**
  41793. * Creates a WebXRExperienceHelper
  41794. * @param scene The scene the helper should be created in
  41795. */
  41796. private constructor();
  41797. /**
  41798. * Exits XR mode and returns the scene to its original state
  41799. * @returns promise that resolves after xr mode has exited
  41800. */
  41801. exitXRAsync(): Promise<void>;
  41802. /**
  41803. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41804. * @param sessionCreationOptions options for the XR session
  41805. * @param frameOfReference frame of reference of the XR session
  41806. * @returns promise that resolves after xr mode has entered
  41807. */
  41808. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41809. /**
  41810. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41811. * @param ray ray to cast into the environment
  41812. * @returns Promise which resolves with a collision point in the environment if it exists
  41813. */
  41814. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41815. /**
  41816. * Updates the global position of the camera by moving the camera's container
  41817. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41818. * @param position The desired global position of the camera
  41819. */
  41820. setPositionOfCameraUsingContainer(position: Vector3): void;
  41821. /**
  41822. * Rotates the xr camera by rotating the camera's container around the camera's position
  41823. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41824. * @param rotation the desired quaternion rotation to apply to the camera
  41825. */
  41826. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41827. /**
  41828. * Checks if the creation options are supported by the xr session
  41829. * @param options creation options
  41830. * @returns true if supported
  41831. */
  41832. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41833. /**
  41834. * Disposes of the experience helper
  41835. */
  41836. dispose(): void;
  41837. }
  41838. }
  41839. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41840. import { Nullable } from "babylonjs/types";
  41841. import { Observable } from "babylonjs/Misc/observable";
  41842. import { IDisposable, Scene } from "babylonjs/scene";
  41843. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41844. /**
  41845. * Button which can be used to enter a different mode of XR
  41846. */
  41847. export class WebXREnterExitUIButton {
  41848. /** button element */
  41849. element: HTMLElement;
  41850. /** XR initialization options for the button */
  41851. initializationOptions: XRSessionCreationOptions;
  41852. /**
  41853. * Creates a WebXREnterExitUIButton
  41854. * @param element button element
  41855. * @param initializationOptions XR initialization options for the button
  41856. */
  41857. constructor(
  41858. /** button element */
  41859. element: HTMLElement,
  41860. /** XR initialization options for the button */
  41861. initializationOptions: XRSessionCreationOptions);
  41862. /**
  41863. * Overwritable function which can be used to update the button's visuals when the state changes
  41864. * @param activeButton the current active button in the UI
  41865. */
  41866. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41867. }
  41868. /**
  41869. * Options to create the webXR UI
  41870. */
  41871. export class WebXREnterExitUIOptions {
  41872. /**
  41873. * Context to enter xr with
  41874. */
  41875. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41876. /**
  41877. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41878. */
  41879. customButtons?: Array<WebXREnterExitUIButton>;
  41880. }
  41881. /**
  41882. * UI to allow the user to enter/exit XR mode
  41883. */
  41884. export class WebXREnterExitUI implements IDisposable {
  41885. private scene;
  41886. private _overlay;
  41887. private _buttons;
  41888. private _activeButton;
  41889. /**
  41890. * Fired every time the active button is changed.
  41891. *
  41892. * When xr is entered via a button that launches xr that button will be the callback parameter
  41893. *
  41894. * When exiting xr the callback parameter will be null)
  41895. */
  41896. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41897. /**
  41898. * Creates UI to allow the user to enter/exit XR mode
  41899. * @param scene the scene to add the ui to
  41900. * @param helper the xr experience helper to enter/exit xr with
  41901. * @param options options to configure the UI
  41902. * @returns the created ui
  41903. */
  41904. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41905. private constructor();
  41906. private _updateButtons;
  41907. /**
  41908. * Disposes of the object
  41909. */
  41910. dispose(): void;
  41911. }
  41912. }
  41913. declare module "babylonjs/Cameras/XR/webXRInput" {
  41914. import { IDisposable, Scene } from "babylonjs/scene";
  41915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41916. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41917. /**
  41918. * Represents an XR input
  41919. */
  41920. export class WebXRController {
  41921. /**
  41922. * 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
  41923. */
  41924. grip?: AbstractMesh;
  41925. /**
  41926. * Pointer which can be used to select objects or attach a visible laser to
  41927. */
  41928. pointer: AbstractMesh;
  41929. /**
  41930. * Creates the controller
  41931. * @see https://doc.babylonjs.com/how_to/webxr
  41932. * @param scene the scene which the controller should be associated to
  41933. */
  41934. constructor(scene: Scene);
  41935. /**
  41936. * Disposes of the object
  41937. */
  41938. dispose(): void;
  41939. }
  41940. /**
  41941. * XR input used to track XR inputs such as controllers/rays
  41942. */
  41943. export class WebXRInput implements IDisposable {
  41944. private helper;
  41945. /**
  41946. * XR controllers being tracked
  41947. */
  41948. controllers: Array<WebXRController>;
  41949. private _tmpMatrix;
  41950. private _frameObserver;
  41951. /**
  41952. * Initializes the WebXRInput
  41953. * @param helper experience helper which the input should be created for
  41954. */
  41955. constructor(helper: WebXRExperienceHelper);
  41956. /**
  41957. * Disposes of the object
  41958. */
  41959. dispose(): void;
  41960. }
  41961. }
  41962. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41963. import { Nullable } from "babylonjs/types";
  41964. import { IDisposable } from "babylonjs/scene";
  41965. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41966. /**
  41967. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41968. */
  41969. export class WebXRManagedOutputCanvas implements IDisposable {
  41970. private _canvas;
  41971. /**
  41972. * xrpresent context of the canvas which can be used to display/mirror xr content
  41973. */
  41974. canvasContext: Nullable<WebGLRenderingContext>;
  41975. /**
  41976. * Initializes the canvas to be added/removed upon entering/exiting xr
  41977. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41978. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41979. */
  41980. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41981. /**
  41982. * Disposes of the object
  41983. */
  41984. dispose(): void;
  41985. private _setManagedOutputCanvas;
  41986. private _addCanvas;
  41987. private _removeCanvas;
  41988. }
  41989. }
  41990. declare module "babylonjs/Cameras/XR/index" {
  41991. export * from "babylonjs/Cameras/XR/webXRCamera";
  41992. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41993. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41994. export * from "babylonjs/Cameras/XR/webXRInput";
  41995. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41996. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41997. }
  41998. declare module "babylonjs/Cameras/RigModes/index" {
  41999. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42000. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42001. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42002. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42003. }
  42004. declare module "babylonjs/Cameras/index" {
  42005. export * from "babylonjs/Cameras/Inputs/index";
  42006. export * from "babylonjs/Cameras/cameraInputsManager";
  42007. export * from "babylonjs/Cameras/camera";
  42008. export * from "babylonjs/Cameras/targetCamera";
  42009. export * from "babylonjs/Cameras/freeCamera";
  42010. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42011. export * from "babylonjs/Cameras/touchCamera";
  42012. export * from "babylonjs/Cameras/arcRotateCamera";
  42013. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42014. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42015. export * from "babylonjs/Cameras/flyCamera";
  42016. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42017. export * from "babylonjs/Cameras/followCamera";
  42018. export * from "babylonjs/Cameras/gamepadCamera";
  42019. export * from "babylonjs/Cameras/Stereoscopic/index";
  42020. export * from "babylonjs/Cameras/universalCamera";
  42021. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42022. export * from "babylonjs/Cameras/VR/index";
  42023. export * from "babylonjs/Cameras/XR/index";
  42024. export * from "babylonjs/Cameras/RigModes/index";
  42025. }
  42026. declare module "babylonjs/Collisions/index" {
  42027. export * from "babylonjs/Collisions/collider";
  42028. export * from "babylonjs/Collisions/collisionCoordinator";
  42029. export * from "babylonjs/Collisions/pickingInfo";
  42030. export * from "babylonjs/Collisions/intersectionInfo";
  42031. export * from "babylonjs/Collisions/meshCollisionData";
  42032. }
  42033. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42034. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42035. import { Vector3, Plane } from "babylonjs/Maths/math";
  42036. import { Ray } from "babylonjs/Culling/ray";
  42037. /**
  42038. * Contains an array of blocks representing the octree
  42039. */
  42040. export interface IOctreeContainer<T> {
  42041. /**
  42042. * Blocks within the octree
  42043. */
  42044. blocks: Array<OctreeBlock<T>>;
  42045. }
  42046. /**
  42047. * Class used to store a cell in an octree
  42048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42049. */
  42050. export class OctreeBlock<T> {
  42051. /**
  42052. * Gets the content of the current block
  42053. */
  42054. entries: T[];
  42055. /**
  42056. * Gets the list of block children
  42057. */
  42058. blocks: Array<OctreeBlock<T>>;
  42059. private _depth;
  42060. private _maxDepth;
  42061. private _capacity;
  42062. private _minPoint;
  42063. private _maxPoint;
  42064. private _boundingVectors;
  42065. private _creationFunc;
  42066. /**
  42067. * Creates a new block
  42068. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42069. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42070. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42071. * @param depth defines the current depth of this block in the octree
  42072. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42073. * @param creationFunc defines a callback to call when an element is added to the block
  42074. */
  42075. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42076. /**
  42077. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42078. */
  42079. readonly capacity: number;
  42080. /**
  42081. * Gets the minimum vector (in world space) of the block's bounding box
  42082. */
  42083. readonly minPoint: Vector3;
  42084. /**
  42085. * Gets the maximum vector (in world space) of the block's bounding box
  42086. */
  42087. readonly maxPoint: Vector3;
  42088. /**
  42089. * Add a new element to this block
  42090. * @param entry defines the element to add
  42091. */
  42092. addEntry(entry: T): void;
  42093. /**
  42094. * Remove an element from this block
  42095. * @param entry defines the element to remove
  42096. */
  42097. removeEntry(entry: T): void;
  42098. /**
  42099. * Add an array of elements to this block
  42100. * @param entries defines the array of elements to add
  42101. */
  42102. addEntries(entries: T[]): void;
  42103. /**
  42104. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42105. * @param frustumPlanes defines the frustum planes to test
  42106. * @param selection defines the array to store current content if selection is positive
  42107. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42108. */
  42109. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42110. /**
  42111. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42112. * @param sphereCenter defines the bounding sphere center
  42113. * @param sphereRadius defines the bounding sphere radius
  42114. * @param selection defines the array to store current content if selection is positive
  42115. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42116. */
  42117. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42118. /**
  42119. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42120. * @param ray defines the ray to test with
  42121. * @param selection defines the array to store current content if selection is positive
  42122. */
  42123. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42124. /**
  42125. * Subdivide the content into child blocks (this block will then be empty)
  42126. */
  42127. createInnerBlocks(): void;
  42128. /**
  42129. * @hidden
  42130. */
  42131. 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;
  42132. }
  42133. }
  42134. declare module "babylonjs/Culling/Octrees/octree" {
  42135. import { SmartArray } from "babylonjs/Misc/smartArray";
  42136. import { Vector3, Plane } from "babylonjs/Maths/math";
  42137. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42139. import { Ray } from "babylonjs/Culling/ray";
  42140. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42141. /**
  42142. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42143. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42144. */
  42145. export class Octree<T> {
  42146. /** 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.) */
  42147. maxDepth: number;
  42148. /**
  42149. * Blocks within the octree containing objects
  42150. */
  42151. blocks: Array<OctreeBlock<T>>;
  42152. /**
  42153. * Content stored in the octree
  42154. */
  42155. dynamicContent: T[];
  42156. private _maxBlockCapacity;
  42157. private _selectionContent;
  42158. private _creationFunc;
  42159. /**
  42160. * Creates a octree
  42161. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42162. * @param creationFunc function to be used to instatiate the octree
  42163. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42164. * @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.)
  42165. */
  42166. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42167. /** 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.) */
  42168. maxDepth?: number);
  42169. /**
  42170. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42171. * @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);
  42172. * @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);
  42173. * @param entries meshes to be added to the octree blocks
  42174. */
  42175. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42176. /**
  42177. * Adds a mesh to the octree
  42178. * @param entry Mesh to add to the octree
  42179. */
  42180. addMesh(entry: T): void;
  42181. /**
  42182. * Remove an element from the octree
  42183. * @param entry defines the element to remove
  42184. */
  42185. removeMesh(entry: T): void;
  42186. /**
  42187. * Selects an array of meshes within the frustum
  42188. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42189. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42190. * @returns array of meshes within the frustum
  42191. */
  42192. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42193. /**
  42194. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42195. * @param sphereCenter defines the bounding sphere center
  42196. * @param sphereRadius defines the bounding sphere radius
  42197. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42198. * @returns an array of objects that intersect the sphere
  42199. */
  42200. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42201. /**
  42202. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42203. * @param ray defines the ray to test with
  42204. * @returns array of intersected objects
  42205. */
  42206. intersectsRay(ray: Ray): SmartArray<T>;
  42207. /**
  42208. * Adds a mesh into the octree block if it intersects the block
  42209. */
  42210. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42211. /**
  42212. * Adds a submesh into the octree block if it intersects the block
  42213. */
  42214. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42215. }
  42216. }
  42217. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42218. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42219. import { Scene } from "babylonjs/scene";
  42220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42222. import { Ray } from "babylonjs/Culling/ray";
  42223. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42224. import { Collider } from "babylonjs/Collisions/collider";
  42225. module "babylonjs/scene" {
  42226. interface Scene {
  42227. /**
  42228. * @hidden
  42229. * Backing Filed
  42230. */
  42231. _selectionOctree: Octree<AbstractMesh>;
  42232. /**
  42233. * Gets the octree used to boost mesh selection (picking)
  42234. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42235. */
  42236. selectionOctree: Octree<AbstractMesh>;
  42237. /**
  42238. * Creates or updates the octree used to boost selection (picking)
  42239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42240. * @param maxCapacity defines the maximum capacity per leaf
  42241. * @param maxDepth defines the maximum depth of the octree
  42242. * @returns an octree of AbstractMesh
  42243. */
  42244. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42245. }
  42246. }
  42247. module "babylonjs/Meshes/abstractMesh" {
  42248. interface AbstractMesh {
  42249. /**
  42250. * @hidden
  42251. * Backing Field
  42252. */
  42253. _submeshesOctree: Octree<SubMesh>;
  42254. /**
  42255. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42256. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42257. * @param maxCapacity defines the maximum size of each block (64 by default)
  42258. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42259. * @returns the new octree
  42260. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42262. */
  42263. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42264. }
  42265. }
  42266. /**
  42267. * Defines the octree scene component responsible to manage any octrees
  42268. * in a given scene.
  42269. */
  42270. export class OctreeSceneComponent {
  42271. /**
  42272. * The component name help to identify the component in the list of scene components.
  42273. */
  42274. readonly name: string;
  42275. /**
  42276. * The scene the component belongs to.
  42277. */
  42278. scene: Scene;
  42279. /**
  42280. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42281. */
  42282. readonly checksIsEnabled: boolean;
  42283. /**
  42284. * Creates a new instance of the component for the given scene
  42285. * @param scene Defines the scene to register the component in
  42286. */
  42287. constructor(scene: Scene);
  42288. /**
  42289. * Registers the component in a given scene
  42290. */
  42291. register(): void;
  42292. /**
  42293. * Return the list of active meshes
  42294. * @returns the list of active meshes
  42295. */
  42296. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42297. /**
  42298. * Return the list of active sub meshes
  42299. * @param mesh The mesh to get the candidates sub meshes from
  42300. * @returns the list of active sub meshes
  42301. */
  42302. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42303. private _tempRay;
  42304. /**
  42305. * Return the list of sub meshes intersecting with a given local ray
  42306. * @param mesh defines the mesh to find the submesh for
  42307. * @param localRay defines the ray in local space
  42308. * @returns the list of intersecting sub meshes
  42309. */
  42310. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42311. /**
  42312. * Return the list of sub meshes colliding with a collider
  42313. * @param mesh defines the mesh to find the submesh for
  42314. * @param collider defines the collider to evaluate the collision against
  42315. * @returns the list of colliding sub meshes
  42316. */
  42317. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42318. /**
  42319. * Rebuilds the elements related to this component in case of
  42320. * context lost for instance.
  42321. */
  42322. rebuild(): void;
  42323. /**
  42324. * Disposes the component and the associated ressources.
  42325. */
  42326. dispose(): void;
  42327. }
  42328. }
  42329. declare module "babylonjs/Culling/Octrees/index" {
  42330. export * from "babylonjs/Culling/Octrees/octree";
  42331. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42332. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42333. }
  42334. declare module "babylonjs/Culling/index" {
  42335. export * from "babylonjs/Culling/boundingBox";
  42336. export * from "babylonjs/Culling/boundingInfo";
  42337. export * from "babylonjs/Culling/boundingSphere";
  42338. export * from "babylonjs/Culling/Octrees/index";
  42339. export * from "babylonjs/Culling/ray";
  42340. }
  42341. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42342. import { IDisposable, Scene } from "babylonjs/scene";
  42343. import { Nullable } from "babylonjs/types";
  42344. import { Observable } from "babylonjs/Misc/observable";
  42345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42346. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42347. import { Camera } from "babylonjs/Cameras/camera";
  42348. /**
  42349. * Renders a layer on top of an existing scene
  42350. */
  42351. export class UtilityLayerRenderer implements IDisposable {
  42352. /** the original scene that will be rendered on top of */
  42353. originalScene: Scene;
  42354. private _pointerCaptures;
  42355. private _lastPointerEvents;
  42356. private static _DefaultUtilityLayer;
  42357. private static _DefaultKeepDepthUtilityLayer;
  42358. private _sharedGizmoLight;
  42359. private _renderCamera;
  42360. /**
  42361. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42362. * @returns the camera that is used when rendering the utility layer
  42363. */
  42364. getRenderCamera(): Nullable<Camera>;
  42365. /**
  42366. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42367. * @param cam the camera that should be used when rendering the utility layer
  42368. */
  42369. setRenderCamera(cam: Nullable<Camera>): void;
  42370. /**
  42371. * @hidden
  42372. * Light which used by gizmos to get light shading
  42373. */
  42374. _getSharedGizmoLight(): HemisphericLight;
  42375. /**
  42376. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42377. */
  42378. pickUtilitySceneFirst: boolean;
  42379. /**
  42380. * 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)
  42381. */
  42382. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42383. /**
  42384. * 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)
  42385. */
  42386. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42387. /**
  42388. * The scene that is rendered on top of the original scene
  42389. */
  42390. utilityLayerScene: Scene;
  42391. /**
  42392. * If the utility layer should automatically be rendered on top of existing scene
  42393. */
  42394. shouldRender: boolean;
  42395. /**
  42396. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42397. */
  42398. onlyCheckPointerDownEvents: boolean;
  42399. /**
  42400. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42401. */
  42402. processAllEvents: boolean;
  42403. /**
  42404. * Observable raised when the pointer move from the utility layer scene to the main scene
  42405. */
  42406. onPointerOutObservable: Observable<number>;
  42407. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42408. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42409. private _afterRenderObserver;
  42410. private _sceneDisposeObserver;
  42411. private _originalPointerObserver;
  42412. /**
  42413. * Instantiates a UtilityLayerRenderer
  42414. * @param originalScene the original scene that will be rendered on top of
  42415. * @param handleEvents boolean indicating if the utility layer should handle events
  42416. */
  42417. constructor(
  42418. /** the original scene that will be rendered on top of */
  42419. originalScene: Scene, handleEvents?: boolean);
  42420. private _notifyObservers;
  42421. /**
  42422. * Renders the utility layers scene on top of the original scene
  42423. */
  42424. render(): void;
  42425. /**
  42426. * Disposes of the renderer
  42427. */
  42428. dispose(): void;
  42429. private _updateCamera;
  42430. }
  42431. }
  42432. declare module "babylonjs/Gizmos/gizmo" {
  42433. import { Nullable } from "babylonjs/types";
  42434. import { IDisposable } from "babylonjs/scene";
  42435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42436. import { Mesh } from "babylonjs/Meshes/mesh";
  42437. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42438. /**
  42439. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42440. */
  42441. export class Gizmo implements IDisposable {
  42442. /** The utility layer the gizmo will be added to */
  42443. gizmoLayer: UtilityLayerRenderer;
  42444. /**
  42445. * The root mesh of the gizmo
  42446. */
  42447. _rootMesh: Mesh;
  42448. private _attachedMesh;
  42449. /**
  42450. * Ratio for the scale of the gizmo (Default: 1)
  42451. */
  42452. scaleRatio: number;
  42453. /**
  42454. * If a custom mesh has been set (Default: false)
  42455. */
  42456. protected _customMeshSet: boolean;
  42457. /**
  42458. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42459. * * When set, interactions will be enabled
  42460. */
  42461. attachedMesh: Nullable<AbstractMesh>;
  42462. /**
  42463. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42464. * @param mesh The mesh to replace the default mesh of the gizmo
  42465. */
  42466. setCustomMesh(mesh: Mesh): void;
  42467. /**
  42468. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42469. */
  42470. updateGizmoRotationToMatchAttachedMesh: boolean;
  42471. /**
  42472. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42473. */
  42474. updateGizmoPositionToMatchAttachedMesh: boolean;
  42475. /**
  42476. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42477. */
  42478. protected _updateScale: boolean;
  42479. protected _interactionsEnabled: boolean;
  42480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42481. private _beforeRenderObserver;
  42482. private _tempVector;
  42483. /**
  42484. * Creates a gizmo
  42485. * @param gizmoLayer The utility layer the gizmo will be added to
  42486. */
  42487. constructor(
  42488. /** The utility layer the gizmo will be added to */
  42489. gizmoLayer?: UtilityLayerRenderer);
  42490. /**
  42491. * Updates the gizmo to match the attached mesh's position/rotation
  42492. */
  42493. protected _update(): void;
  42494. /**
  42495. * Disposes of the gizmo
  42496. */
  42497. dispose(): void;
  42498. }
  42499. }
  42500. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42501. import { Observable } from "babylonjs/Misc/observable";
  42502. import { Nullable } from "babylonjs/types";
  42503. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42504. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42506. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42507. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42508. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42509. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42510. import { Scene } from "babylonjs/scene";
  42511. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42512. /**
  42513. * Single plane drag gizmo
  42514. */
  42515. export class PlaneDragGizmo extends Gizmo {
  42516. /**
  42517. * Drag behavior responsible for the gizmos dragging interactions
  42518. */
  42519. dragBehavior: PointerDragBehavior;
  42520. private _pointerObserver;
  42521. /**
  42522. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42523. */
  42524. snapDistance: number;
  42525. /**
  42526. * Event that fires each time the gizmo snaps to a new location.
  42527. * * snapDistance is the the change in distance
  42528. */
  42529. onSnapObservable: Observable<{
  42530. snapDistance: number;
  42531. }>;
  42532. private _plane;
  42533. private _coloredMaterial;
  42534. private _hoverMaterial;
  42535. private _isEnabled;
  42536. private _parent;
  42537. /** @hidden */
  42538. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42539. /** @hidden */
  42540. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42541. /**
  42542. * Creates a PlaneDragGizmo
  42543. * @param gizmoLayer The utility layer the gizmo will be added to
  42544. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42545. * @param color The color of the gizmo
  42546. */
  42547. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42548. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42549. /**
  42550. * If the gizmo is enabled
  42551. */
  42552. isEnabled: boolean;
  42553. /**
  42554. * Disposes of the gizmo
  42555. */
  42556. dispose(): void;
  42557. }
  42558. }
  42559. declare module "babylonjs/Gizmos/positionGizmo" {
  42560. import { Observable } from "babylonjs/Misc/observable";
  42561. import { Nullable } from "babylonjs/types";
  42562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42563. import { Mesh } from "babylonjs/Meshes/mesh";
  42564. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42565. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42566. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42567. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42568. /**
  42569. * Gizmo that enables dragging a mesh along 3 axis
  42570. */
  42571. export class PositionGizmo extends Gizmo {
  42572. /**
  42573. * Internal gizmo used for interactions on the x axis
  42574. */
  42575. xGizmo: AxisDragGizmo;
  42576. /**
  42577. * Internal gizmo used for interactions on the y axis
  42578. */
  42579. yGizmo: AxisDragGizmo;
  42580. /**
  42581. * Internal gizmo used for interactions on the z axis
  42582. */
  42583. zGizmo: AxisDragGizmo;
  42584. /**
  42585. * Internal gizmo used for interactions on the yz plane
  42586. */
  42587. xPlaneGizmo: PlaneDragGizmo;
  42588. /**
  42589. * Internal gizmo used for interactions on the xz plane
  42590. */
  42591. yPlaneGizmo: PlaneDragGizmo;
  42592. /**
  42593. * Internal gizmo used for interactions on the xy plane
  42594. */
  42595. zPlaneGizmo: PlaneDragGizmo;
  42596. /**
  42597. * private variables
  42598. */
  42599. private _meshAttached;
  42600. private _updateGizmoRotationToMatchAttachedMesh;
  42601. private _snapDistance;
  42602. private _scaleRatio;
  42603. /** Fires an event when any of it's sub gizmos are dragged */
  42604. onDragStartObservable: Observable<{}>;
  42605. /** Fires an event when any of it's sub gizmos are released from dragging */
  42606. onDragEndObservable: Observable<{}>;
  42607. /**
  42608. * If set to true, planar drag is enabled
  42609. */
  42610. private _planarGizmoEnabled;
  42611. attachedMesh: Nullable<AbstractMesh>;
  42612. /**
  42613. * Creates a PositionGizmo
  42614. * @param gizmoLayer The utility layer the gizmo will be added to
  42615. */
  42616. constructor(gizmoLayer?: UtilityLayerRenderer);
  42617. /**
  42618. * If the planar drag gizmo is enabled
  42619. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42620. */
  42621. planarGizmoEnabled: boolean;
  42622. updateGizmoRotationToMatchAttachedMesh: boolean;
  42623. /**
  42624. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42625. */
  42626. snapDistance: number;
  42627. /**
  42628. * Ratio for the scale of the gizmo (Default: 1)
  42629. */
  42630. scaleRatio: number;
  42631. /**
  42632. * Disposes of the gizmo
  42633. */
  42634. dispose(): void;
  42635. /**
  42636. * CustomMeshes are not supported by this gizmo
  42637. * @param mesh The mesh to replace the default mesh of the gizmo
  42638. */
  42639. setCustomMesh(mesh: Mesh): void;
  42640. }
  42641. }
  42642. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42643. import { Observable } from "babylonjs/Misc/observable";
  42644. import { Nullable } from "babylonjs/types";
  42645. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42646. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42648. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42649. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42650. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42651. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42652. import { Scene } from "babylonjs/scene";
  42653. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42654. /**
  42655. * Single axis drag gizmo
  42656. */
  42657. export class AxisDragGizmo extends Gizmo {
  42658. /**
  42659. * Drag behavior responsible for the gizmos dragging interactions
  42660. */
  42661. dragBehavior: PointerDragBehavior;
  42662. private _pointerObserver;
  42663. /**
  42664. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42665. */
  42666. snapDistance: number;
  42667. /**
  42668. * Event that fires each time the gizmo snaps to a new location.
  42669. * * snapDistance is the the change in distance
  42670. */
  42671. onSnapObservable: Observable<{
  42672. snapDistance: number;
  42673. }>;
  42674. private _isEnabled;
  42675. private _parent;
  42676. private _arrow;
  42677. private _coloredMaterial;
  42678. private _hoverMaterial;
  42679. /** @hidden */
  42680. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42681. /** @hidden */
  42682. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42683. /**
  42684. * Creates an AxisDragGizmo
  42685. * @param gizmoLayer The utility layer the gizmo will be added to
  42686. * @param dragAxis The axis which the gizmo will be able to drag on
  42687. * @param color The color of the gizmo
  42688. */
  42689. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42690. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42691. /**
  42692. * If the gizmo is enabled
  42693. */
  42694. isEnabled: boolean;
  42695. /**
  42696. * Disposes of the gizmo
  42697. */
  42698. dispose(): void;
  42699. }
  42700. }
  42701. declare module "babylonjs/Debug/axesViewer" {
  42702. import { Vector3 } from "babylonjs/Maths/math";
  42703. import { Nullable } from "babylonjs/types";
  42704. import { Scene } from "babylonjs/scene";
  42705. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42706. /**
  42707. * The Axes viewer will show 3 axes in a specific point in space
  42708. */
  42709. export class AxesViewer {
  42710. private _xAxis;
  42711. private _yAxis;
  42712. private _zAxis;
  42713. private _scaleLinesFactor;
  42714. private _instanced;
  42715. /**
  42716. * Gets the hosting scene
  42717. */
  42718. scene: Scene;
  42719. /**
  42720. * Gets or sets a number used to scale line length
  42721. */
  42722. scaleLines: number;
  42723. /** Gets the node hierarchy used to render x-axis */
  42724. readonly xAxis: TransformNode;
  42725. /** Gets the node hierarchy used to render y-axis */
  42726. readonly yAxis: TransformNode;
  42727. /** Gets the node hierarchy used to render z-axis */
  42728. readonly zAxis: TransformNode;
  42729. /**
  42730. * Creates a new AxesViewer
  42731. * @param scene defines the hosting scene
  42732. * @param scaleLines defines a number used to scale line length (1 by default)
  42733. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42734. * @param xAxis defines the node hierarchy used to render the x-axis
  42735. * @param yAxis defines the node hierarchy used to render the y-axis
  42736. * @param zAxis defines the node hierarchy used to render the z-axis
  42737. */
  42738. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42739. /**
  42740. * Force the viewer to update
  42741. * @param position defines the position of the viewer
  42742. * @param xaxis defines the x axis of the viewer
  42743. * @param yaxis defines the y axis of the viewer
  42744. * @param zaxis defines the z axis of the viewer
  42745. */
  42746. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42747. /**
  42748. * Creates an instance of this axes viewer.
  42749. * @returns a new axes viewer with instanced meshes
  42750. */
  42751. createInstance(): AxesViewer;
  42752. /** Releases resources */
  42753. dispose(): void;
  42754. private static _SetRenderingGroupId;
  42755. }
  42756. }
  42757. declare module "babylonjs/Debug/boneAxesViewer" {
  42758. import { Nullable } from "babylonjs/types";
  42759. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42760. import { Vector3 } from "babylonjs/Maths/math";
  42761. import { Mesh } from "babylonjs/Meshes/mesh";
  42762. import { Bone } from "babylonjs/Bones/bone";
  42763. import { Scene } from "babylonjs/scene";
  42764. /**
  42765. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42766. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42767. */
  42768. export class BoneAxesViewer extends AxesViewer {
  42769. /**
  42770. * Gets or sets the target mesh where to display the axes viewer
  42771. */
  42772. mesh: Nullable<Mesh>;
  42773. /**
  42774. * Gets or sets the target bone where to display the axes viewer
  42775. */
  42776. bone: Nullable<Bone>;
  42777. /** Gets current position */
  42778. pos: Vector3;
  42779. /** Gets direction of X axis */
  42780. xaxis: Vector3;
  42781. /** Gets direction of Y axis */
  42782. yaxis: Vector3;
  42783. /** Gets direction of Z axis */
  42784. zaxis: Vector3;
  42785. /**
  42786. * Creates a new BoneAxesViewer
  42787. * @param scene defines the hosting scene
  42788. * @param bone defines the target bone
  42789. * @param mesh defines the target mesh
  42790. * @param scaleLines defines a scaling factor for line length (1 by default)
  42791. */
  42792. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42793. /**
  42794. * Force the viewer to update
  42795. */
  42796. update(): void;
  42797. /** Releases resources */
  42798. dispose(): void;
  42799. }
  42800. }
  42801. declare module "babylonjs/Debug/debugLayer" {
  42802. import { Observable } from "babylonjs/Misc/observable";
  42803. import { Scene } from "babylonjs/scene";
  42804. /**
  42805. * Interface used to define scene explorer extensibility option
  42806. */
  42807. export interface IExplorerExtensibilityOption {
  42808. /**
  42809. * Define the option label
  42810. */
  42811. label: string;
  42812. /**
  42813. * Defines the action to execute on click
  42814. */
  42815. action: (entity: any) => void;
  42816. }
  42817. /**
  42818. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42819. */
  42820. export interface IExplorerExtensibilityGroup {
  42821. /**
  42822. * Defines a predicate to test if a given type mut be extended
  42823. */
  42824. predicate: (entity: any) => boolean;
  42825. /**
  42826. * Gets the list of options added to a type
  42827. */
  42828. entries: IExplorerExtensibilityOption[];
  42829. }
  42830. /**
  42831. * Interface used to define the options to use to create the Inspector
  42832. */
  42833. export interface IInspectorOptions {
  42834. /**
  42835. * Display in overlay mode (default: false)
  42836. */
  42837. overlay?: boolean;
  42838. /**
  42839. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42840. */
  42841. globalRoot?: HTMLElement;
  42842. /**
  42843. * Display the Scene explorer
  42844. */
  42845. showExplorer?: boolean;
  42846. /**
  42847. * Display the property inspector
  42848. */
  42849. showInspector?: boolean;
  42850. /**
  42851. * Display in embed mode (both panes on the right)
  42852. */
  42853. embedMode?: boolean;
  42854. /**
  42855. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42856. */
  42857. handleResize?: boolean;
  42858. /**
  42859. * Allow the panes to popup (default: true)
  42860. */
  42861. enablePopup?: boolean;
  42862. /**
  42863. * Allow the panes to be closed by users (default: true)
  42864. */
  42865. enableClose?: boolean;
  42866. /**
  42867. * Optional list of extensibility entries
  42868. */
  42869. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42870. /**
  42871. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42872. */
  42873. inspectorURL?: string;
  42874. }
  42875. module "babylonjs/scene" {
  42876. interface Scene {
  42877. /**
  42878. * @hidden
  42879. * Backing field
  42880. */
  42881. _debugLayer: DebugLayer;
  42882. /**
  42883. * Gets the debug layer (aka Inspector) associated with the scene
  42884. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42885. */
  42886. debugLayer: DebugLayer;
  42887. }
  42888. }
  42889. /**
  42890. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42891. * what is happening in your scene
  42892. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42893. */
  42894. export class DebugLayer {
  42895. /**
  42896. * Define the url to get the inspector script from.
  42897. * By default it uses the babylonjs CDN.
  42898. * @ignoreNaming
  42899. */
  42900. static InspectorURL: string;
  42901. private _scene;
  42902. private BJSINSPECTOR;
  42903. /**
  42904. * Observable triggered when a property is changed through the inspector.
  42905. */
  42906. onPropertyChangedObservable: Observable<{
  42907. object: any;
  42908. property: string;
  42909. value: any;
  42910. initialValue: any;
  42911. }>;
  42912. /**
  42913. * Instantiates a new debug layer.
  42914. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42915. * what is happening in your scene
  42916. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42917. * @param scene Defines the scene to inspect
  42918. */
  42919. constructor(scene: Scene);
  42920. /** Creates the inspector window. */
  42921. private _createInspector;
  42922. /**
  42923. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42924. * @param entity defines the entity to select
  42925. * @param lineContainerTitle defines the specific block to highlight
  42926. */
  42927. select(entity: any, lineContainerTitle?: string): void;
  42928. /** Get the inspector from bundle or global */
  42929. private _getGlobalInspector;
  42930. /**
  42931. * Get if the inspector is visible or not.
  42932. * @returns true if visible otherwise, false
  42933. */
  42934. isVisible(): boolean;
  42935. /**
  42936. * Hide the inspector and close its window.
  42937. */
  42938. hide(): void;
  42939. /**
  42940. * Launch the debugLayer.
  42941. * @param config Define the configuration of the inspector
  42942. * @return a promise fulfilled when the debug layer is visible
  42943. */
  42944. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42945. }
  42946. }
  42947. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42948. import { Nullable } from "babylonjs/types";
  42949. import { Scene } from "babylonjs/scene";
  42950. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42951. import { Mesh } from "babylonjs/Meshes/mesh";
  42952. /**
  42953. * Class containing static functions to help procedurally build meshes
  42954. */
  42955. export class BoxBuilder {
  42956. /**
  42957. * Creates a box mesh
  42958. * * The parameter `size` sets the size (float) of each box side (default 1)
  42959. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42960. * * 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)
  42961. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42965. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42966. * @param name defines the name of the mesh
  42967. * @param options defines the options used to create the mesh
  42968. * @param scene defines the hosting scene
  42969. * @returns the box mesh
  42970. */
  42971. static CreateBox(name: string, options: {
  42972. size?: number;
  42973. width?: number;
  42974. height?: number;
  42975. depth?: number;
  42976. faceUV?: Vector4[];
  42977. faceColors?: Color4[];
  42978. sideOrientation?: number;
  42979. frontUVs?: Vector4;
  42980. backUVs?: Vector4;
  42981. wrap?: boolean;
  42982. topBaseAt?: number;
  42983. bottomBaseAt?: number;
  42984. updatable?: boolean;
  42985. }, scene?: Nullable<Scene>): Mesh;
  42986. }
  42987. }
  42988. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42989. import { Vector4 } from "babylonjs/Maths/math";
  42990. import { Mesh } from "babylonjs/Meshes/mesh";
  42991. /**
  42992. * Class containing static functions to help procedurally build meshes
  42993. */
  42994. export class SphereBuilder {
  42995. /**
  42996. * Creates a sphere mesh
  42997. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42998. * * 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`)
  42999. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43000. * * 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
  43001. * * 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)
  43002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43005. * @param name defines the name of the mesh
  43006. * @param options defines the options used to create the mesh
  43007. * @param scene defines the hosting scene
  43008. * @returns the sphere mesh
  43009. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43010. */
  43011. static CreateSphere(name: string, options: {
  43012. segments?: number;
  43013. diameter?: number;
  43014. diameterX?: number;
  43015. diameterY?: number;
  43016. diameterZ?: number;
  43017. arc?: number;
  43018. slice?: number;
  43019. sideOrientation?: number;
  43020. frontUVs?: Vector4;
  43021. backUVs?: Vector4;
  43022. updatable?: boolean;
  43023. }, scene: any): Mesh;
  43024. }
  43025. }
  43026. declare module "babylonjs/Debug/physicsViewer" {
  43027. import { Nullable } from "babylonjs/types";
  43028. import { Scene } from "babylonjs/scene";
  43029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43030. import { Mesh } from "babylonjs/Meshes/mesh";
  43031. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43032. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43033. /**
  43034. * Used to show the physics impostor around the specific mesh
  43035. */
  43036. export class PhysicsViewer {
  43037. /** @hidden */
  43038. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43039. /** @hidden */
  43040. protected _meshes: Array<Nullable<AbstractMesh>>;
  43041. /** @hidden */
  43042. protected _scene: Nullable<Scene>;
  43043. /** @hidden */
  43044. protected _numMeshes: number;
  43045. /** @hidden */
  43046. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43047. private _renderFunction;
  43048. private _utilityLayer;
  43049. private _debugBoxMesh;
  43050. private _debugSphereMesh;
  43051. private _debugCylinderMesh;
  43052. private _debugMaterial;
  43053. private _debugMeshMeshes;
  43054. /**
  43055. * Creates a new PhysicsViewer
  43056. * @param scene defines the hosting scene
  43057. */
  43058. constructor(scene: Scene);
  43059. /** @hidden */
  43060. protected _updateDebugMeshes(): void;
  43061. /**
  43062. * Renders a specified physic impostor
  43063. * @param impostor defines the impostor to render
  43064. * @param targetMesh defines the mesh represented by the impostor
  43065. * @returns the new debug mesh used to render the impostor
  43066. */
  43067. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43068. /**
  43069. * Hides a specified physic impostor
  43070. * @param impostor defines the impostor to hide
  43071. */
  43072. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43073. private _getDebugMaterial;
  43074. private _getDebugBoxMesh;
  43075. private _getDebugSphereMesh;
  43076. private _getDebugCylinderMesh;
  43077. private _getDebugMeshMesh;
  43078. private _getDebugMesh;
  43079. /** Releases all resources */
  43080. dispose(): void;
  43081. }
  43082. }
  43083. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43084. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43085. import { Nullable } from "babylonjs/types";
  43086. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43087. import { Scene } from "babylonjs/scene";
  43088. /**
  43089. * Class containing static functions to help procedurally build meshes
  43090. */
  43091. export class LinesBuilder {
  43092. /**
  43093. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43094. * * 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
  43095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43096. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43097. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43098. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43099. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43100. * * 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
  43101. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43104. * @param name defines the name of the new line system
  43105. * @param options defines the options used to create the line system
  43106. * @param scene defines the hosting scene
  43107. * @returns a new line system mesh
  43108. */
  43109. static CreateLineSystem(name: string, options: {
  43110. lines: Vector3[][];
  43111. updatable?: boolean;
  43112. instance?: Nullable<LinesMesh>;
  43113. colors?: Nullable<Color4[][]>;
  43114. useVertexAlpha?: boolean;
  43115. }, scene: Nullable<Scene>): LinesMesh;
  43116. /**
  43117. * Creates a line mesh
  43118. * 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
  43119. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43120. * * The parameter `points` is an array successive Vector3
  43121. * * 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
  43122. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43123. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43124. * * When updating an instance, remember that only point positions can change, not the number of points
  43125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43127. * @param name defines the name of the new line system
  43128. * @param options defines the options used to create the line system
  43129. * @param scene defines the hosting scene
  43130. * @returns a new line mesh
  43131. */
  43132. static CreateLines(name: string, options: {
  43133. points: Vector3[];
  43134. updatable?: boolean;
  43135. instance?: Nullable<LinesMesh>;
  43136. colors?: Color4[];
  43137. useVertexAlpha?: boolean;
  43138. }, scene?: Nullable<Scene>): LinesMesh;
  43139. /**
  43140. * Creates a dashed line mesh
  43141. * * 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
  43142. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43143. * * The parameter `points` is an array successive Vector3
  43144. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43145. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43146. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43147. * * 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
  43148. * * When updating an instance, remember that only point positions can change, not the number of points
  43149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43150. * @param name defines the name of the mesh
  43151. * @param options defines the options used to create the mesh
  43152. * @param scene defines the hosting scene
  43153. * @returns the dashed line mesh
  43154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43155. */
  43156. static CreateDashedLines(name: string, options: {
  43157. points: Vector3[];
  43158. dashSize?: number;
  43159. gapSize?: number;
  43160. dashNb?: number;
  43161. updatable?: boolean;
  43162. instance?: LinesMesh;
  43163. }, scene?: Nullable<Scene>): LinesMesh;
  43164. }
  43165. }
  43166. declare module "babylonjs/Debug/rayHelper" {
  43167. import { Nullable } from "babylonjs/types";
  43168. import { Ray } from "babylonjs/Culling/ray";
  43169. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43170. import { Scene } from "babylonjs/scene";
  43171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43172. import "babylonjs/Meshes/Builders/linesBuilder";
  43173. /**
  43174. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43175. * in order to better appreciate the issue one might have.
  43176. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43177. */
  43178. export class RayHelper {
  43179. /**
  43180. * Defines the ray we are currently tryin to visualize.
  43181. */
  43182. ray: Nullable<Ray>;
  43183. private _renderPoints;
  43184. private _renderLine;
  43185. private _renderFunction;
  43186. private _scene;
  43187. private _updateToMeshFunction;
  43188. private _attachedToMesh;
  43189. private _meshSpaceDirection;
  43190. private _meshSpaceOrigin;
  43191. /**
  43192. * Helper function to create a colored helper in a scene in one line.
  43193. * @param ray Defines the ray we are currently tryin to visualize
  43194. * @param scene Defines the scene the ray is used in
  43195. * @param color Defines the color we want to see the ray in
  43196. * @returns The newly created ray helper.
  43197. */
  43198. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43199. /**
  43200. * Instantiate a new ray helper.
  43201. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43202. * in order to better appreciate the issue one might have.
  43203. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43204. * @param ray Defines the ray we are currently tryin to visualize
  43205. */
  43206. constructor(ray: Ray);
  43207. /**
  43208. * Shows the ray we are willing to debug.
  43209. * @param scene Defines the scene the ray needs to be rendered in
  43210. * @param color Defines the color the ray needs to be rendered in
  43211. */
  43212. show(scene: Scene, color?: Color3): void;
  43213. /**
  43214. * Hides the ray we are debugging.
  43215. */
  43216. hide(): void;
  43217. private _render;
  43218. /**
  43219. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43220. * @param mesh Defines the mesh we want the helper attached to
  43221. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43222. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43223. * @param length Defines the length of the ray
  43224. */
  43225. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43226. /**
  43227. * Detach the ray helper from the mesh it has previously been attached to.
  43228. */
  43229. detachFromMesh(): void;
  43230. private _updateToMesh;
  43231. /**
  43232. * Dispose the helper and release its associated resources.
  43233. */
  43234. dispose(): void;
  43235. }
  43236. }
  43237. declare module "babylonjs/Debug/skeletonViewer" {
  43238. import { Color3 } from "babylonjs/Maths/math";
  43239. import { Scene } from "babylonjs/scene";
  43240. import { Nullable } from "babylonjs/types";
  43241. import { Skeleton } from "babylonjs/Bones/skeleton";
  43242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43243. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43244. /**
  43245. * Class used to render a debug view of a given skeleton
  43246. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43247. */
  43248. export class SkeletonViewer {
  43249. /** defines the skeleton to render */
  43250. skeleton: Skeleton;
  43251. /** defines the mesh attached to the skeleton */
  43252. mesh: AbstractMesh;
  43253. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43254. autoUpdateBonesMatrices: boolean;
  43255. /** defines the rendering group id to use with the viewer */
  43256. renderingGroupId: number;
  43257. /** Gets or sets the color used to render the skeleton */
  43258. color: Color3;
  43259. private _scene;
  43260. private _debugLines;
  43261. private _debugMesh;
  43262. private _isEnabled;
  43263. private _renderFunction;
  43264. private _utilityLayer;
  43265. /**
  43266. * Returns the mesh used to render the bones
  43267. */
  43268. readonly debugMesh: Nullable<LinesMesh>;
  43269. /**
  43270. * Creates a new SkeletonViewer
  43271. * @param skeleton defines the skeleton to render
  43272. * @param mesh defines the mesh attached to the skeleton
  43273. * @param scene defines the hosting scene
  43274. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43275. * @param renderingGroupId defines the rendering group id to use with the viewer
  43276. */
  43277. constructor(
  43278. /** defines the skeleton to render */
  43279. skeleton: Skeleton,
  43280. /** defines the mesh attached to the skeleton */
  43281. mesh: AbstractMesh, scene: Scene,
  43282. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43283. autoUpdateBonesMatrices?: boolean,
  43284. /** defines the rendering group id to use with the viewer */
  43285. renderingGroupId?: number);
  43286. /** Gets or sets a boolean indicating if the viewer is enabled */
  43287. isEnabled: boolean;
  43288. private _getBonePosition;
  43289. private _getLinesForBonesWithLength;
  43290. private _getLinesForBonesNoLength;
  43291. /** Update the viewer to sync with current skeleton state */
  43292. update(): void;
  43293. /** Release associated resources */
  43294. dispose(): void;
  43295. }
  43296. }
  43297. declare module "babylonjs/Debug/index" {
  43298. export * from "babylonjs/Debug/axesViewer";
  43299. export * from "babylonjs/Debug/boneAxesViewer";
  43300. export * from "babylonjs/Debug/debugLayer";
  43301. export * from "babylonjs/Debug/physicsViewer";
  43302. export * from "babylonjs/Debug/rayHelper";
  43303. export * from "babylonjs/Debug/skeletonViewer";
  43304. }
  43305. declare module "babylonjs/Engines/nullEngine" {
  43306. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43307. import { Scene } from "babylonjs/scene";
  43308. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43309. import { Engine } from "babylonjs/Engines/engine";
  43310. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43311. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43312. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43313. import { Effect } from "babylonjs/Materials/effect";
  43314. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43315. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43316. /**
  43317. * Options to create the null engine
  43318. */
  43319. export class NullEngineOptions {
  43320. /**
  43321. * Render width (Default: 512)
  43322. */
  43323. renderWidth: number;
  43324. /**
  43325. * Render height (Default: 256)
  43326. */
  43327. renderHeight: number;
  43328. /**
  43329. * Texture size (Default: 512)
  43330. */
  43331. textureSize: number;
  43332. /**
  43333. * If delta time between frames should be constant
  43334. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43335. */
  43336. deterministicLockstep: boolean;
  43337. /**
  43338. * Maximum about of steps between frames (Default: 4)
  43339. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43340. */
  43341. lockstepMaxSteps: number;
  43342. }
  43343. /**
  43344. * The null engine class provides support for headless version of babylon.js.
  43345. * This can be used in server side scenario or for testing purposes
  43346. */
  43347. export class NullEngine extends Engine {
  43348. private _options;
  43349. /**
  43350. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43351. */
  43352. isDeterministicLockStep(): boolean;
  43353. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43354. getLockstepMaxSteps(): number;
  43355. /**
  43356. * Sets hardware scaling, used to save performance if needed
  43357. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43358. */
  43359. getHardwareScalingLevel(): number;
  43360. constructor(options?: NullEngineOptions);
  43361. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43362. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43363. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43364. getRenderWidth(useScreen?: boolean): number;
  43365. getRenderHeight(useScreen?: boolean): number;
  43366. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43367. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43368. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43369. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43370. bindSamplers(effect: Effect): void;
  43371. enableEffect(effect: Effect): void;
  43372. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43373. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43374. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43375. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43376. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43377. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43378. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43379. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43380. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43381. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43382. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43383. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43384. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43385. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43386. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43387. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43388. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43389. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43390. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43391. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43392. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43393. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43394. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43395. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43396. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43397. bindBuffers(vertexBuffers: {
  43398. [key: string]: VertexBuffer;
  43399. }, indexBuffer: DataBuffer, effect: Effect): void;
  43400. wipeCaches(bruteForce?: boolean): void;
  43401. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43402. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43403. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43404. /** @hidden */
  43405. _createTexture(): WebGLTexture;
  43406. /** @hidden */
  43407. _releaseTexture(texture: InternalTexture): void;
  43408. 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;
  43409. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43410. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43411. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43412. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43413. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43414. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43415. areAllEffectsReady(): boolean;
  43416. /**
  43417. * @hidden
  43418. * Get the current error code of the webGL context
  43419. * @returns the error code
  43420. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43421. */
  43422. getError(): number;
  43423. /** @hidden */
  43424. _getUnpackAlignement(): number;
  43425. /** @hidden */
  43426. _unpackFlipY(value: boolean): void;
  43427. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43428. /**
  43429. * Updates a dynamic vertex buffer.
  43430. * @param vertexBuffer the vertex buffer to update
  43431. * @param data the data used to update the vertex buffer
  43432. * @param byteOffset the byte offset of the data (optional)
  43433. * @param byteLength the byte length of the data (optional)
  43434. */
  43435. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43436. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43437. /** @hidden */
  43438. _bindTexture(channel: number, texture: InternalTexture): void;
  43439. /** @hidden */
  43440. _releaseBuffer(buffer: DataBuffer): boolean;
  43441. releaseEffects(): void;
  43442. displayLoadingUI(): void;
  43443. hideLoadingUI(): void;
  43444. /** @hidden */
  43445. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43446. /** @hidden */
  43447. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43448. /** @hidden */
  43449. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43450. /** @hidden */
  43451. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43452. }
  43453. }
  43454. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43455. import { Nullable, int } from "babylonjs/types";
  43456. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43457. /** @hidden */
  43458. export class _OcclusionDataStorage {
  43459. /** @hidden */
  43460. occlusionInternalRetryCounter: number;
  43461. /** @hidden */
  43462. isOcclusionQueryInProgress: boolean;
  43463. /** @hidden */
  43464. isOccluded: boolean;
  43465. /** @hidden */
  43466. occlusionRetryCount: number;
  43467. /** @hidden */
  43468. occlusionType: number;
  43469. /** @hidden */
  43470. occlusionQueryAlgorithmType: number;
  43471. }
  43472. module "babylonjs/Engines/engine" {
  43473. interface Engine {
  43474. /**
  43475. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43476. * @return the new query
  43477. */
  43478. createQuery(): WebGLQuery;
  43479. /**
  43480. * Delete and release a webGL query
  43481. * @param query defines the query to delete
  43482. * @return the current engine
  43483. */
  43484. deleteQuery(query: WebGLQuery): Engine;
  43485. /**
  43486. * Check if a given query has resolved and got its value
  43487. * @param query defines the query to check
  43488. * @returns true if the query got its value
  43489. */
  43490. isQueryResultAvailable(query: WebGLQuery): boolean;
  43491. /**
  43492. * Gets the value of a given query
  43493. * @param query defines the query to check
  43494. * @returns the value of the query
  43495. */
  43496. getQueryResult(query: WebGLQuery): number;
  43497. /**
  43498. * Initiates an occlusion query
  43499. * @param algorithmType defines the algorithm to use
  43500. * @param query defines the query to use
  43501. * @returns the current engine
  43502. * @see http://doc.babylonjs.com/features/occlusionquery
  43503. */
  43504. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43505. /**
  43506. * Ends an occlusion query
  43507. * @see http://doc.babylonjs.com/features/occlusionquery
  43508. * @param algorithmType defines the algorithm to use
  43509. * @returns the current engine
  43510. */
  43511. endOcclusionQuery(algorithmType: number): Engine;
  43512. /**
  43513. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43514. * Please note that only one query can be issued at a time
  43515. * @returns a time token used to track the time span
  43516. */
  43517. startTimeQuery(): Nullable<_TimeToken>;
  43518. /**
  43519. * Ends a time query
  43520. * @param token defines the token used to measure the time span
  43521. * @returns the time spent (in ns)
  43522. */
  43523. endTimeQuery(token: _TimeToken): int;
  43524. /** @hidden */
  43525. _currentNonTimestampToken: Nullable<_TimeToken>;
  43526. /** @hidden */
  43527. _createTimeQuery(): WebGLQuery;
  43528. /** @hidden */
  43529. _deleteTimeQuery(query: WebGLQuery): void;
  43530. /** @hidden */
  43531. _getGlAlgorithmType(algorithmType: number): number;
  43532. /** @hidden */
  43533. _getTimeQueryResult(query: WebGLQuery): any;
  43534. /** @hidden */
  43535. _getTimeQueryAvailability(query: WebGLQuery): any;
  43536. }
  43537. }
  43538. module "babylonjs/Meshes/abstractMesh" {
  43539. interface AbstractMesh {
  43540. /**
  43541. * Backing filed
  43542. * @hidden
  43543. */
  43544. __occlusionDataStorage: _OcclusionDataStorage;
  43545. /**
  43546. * Access property
  43547. * @hidden
  43548. */
  43549. _occlusionDataStorage: _OcclusionDataStorage;
  43550. /**
  43551. * 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.
  43552. * The default value is -1 which means don't break the query and wait till the result
  43553. * @see http://doc.babylonjs.com/features/occlusionquery
  43554. */
  43555. occlusionRetryCount: number;
  43556. /**
  43557. * 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:
  43558. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43559. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43560. * * 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.
  43561. * @see http://doc.babylonjs.com/features/occlusionquery
  43562. */
  43563. occlusionType: number;
  43564. /**
  43565. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43566. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43567. * * 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.
  43568. * @see http://doc.babylonjs.com/features/occlusionquery
  43569. */
  43570. occlusionQueryAlgorithmType: number;
  43571. /**
  43572. * 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
  43573. * @see http://doc.babylonjs.com/features/occlusionquery
  43574. */
  43575. isOccluded: boolean;
  43576. /**
  43577. * Flag to check the progress status of the query
  43578. * @see http://doc.babylonjs.com/features/occlusionquery
  43579. */
  43580. isOcclusionQueryInProgress: boolean;
  43581. }
  43582. }
  43583. }
  43584. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43585. import { Nullable } from "babylonjs/types";
  43586. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43587. /** @hidden */
  43588. export var _forceTransformFeedbackToBundle: boolean;
  43589. module "babylonjs/Engines/engine" {
  43590. interface Engine {
  43591. /**
  43592. * Creates a webGL transform feedback object
  43593. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43594. * @returns the webGL transform feedback object
  43595. */
  43596. createTransformFeedback(): WebGLTransformFeedback;
  43597. /**
  43598. * Delete a webGL transform feedback object
  43599. * @param value defines the webGL transform feedback object to delete
  43600. */
  43601. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43602. /**
  43603. * Bind a webGL transform feedback object to the webgl context
  43604. * @param value defines the webGL transform feedback object to bind
  43605. */
  43606. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43607. /**
  43608. * Begins a transform feedback operation
  43609. * @param usePoints defines if points or triangles must be used
  43610. */
  43611. beginTransformFeedback(usePoints: boolean): void;
  43612. /**
  43613. * Ends a transform feedback operation
  43614. */
  43615. endTransformFeedback(): void;
  43616. /**
  43617. * Specify the varyings to use with transform feedback
  43618. * @param program defines the associated webGL program
  43619. * @param value defines the list of strings representing the varying names
  43620. */
  43621. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43622. /**
  43623. * Bind a webGL buffer for a transform feedback operation
  43624. * @param value defines the webGL buffer to bind
  43625. */
  43626. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43627. }
  43628. }
  43629. }
  43630. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43631. import { Scene } from "babylonjs/scene";
  43632. import { Engine } from "babylonjs/Engines/engine";
  43633. import { Texture } from "babylonjs/Materials/Textures/texture";
  43634. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43635. import "babylonjs/Engines/Extensions/engine.multiRender";
  43636. /**
  43637. * Creation options of the multi render target texture.
  43638. */
  43639. export interface IMultiRenderTargetOptions {
  43640. /**
  43641. * Define if the texture needs to create mip maps after render.
  43642. */
  43643. generateMipMaps?: boolean;
  43644. /**
  43645. * Define the types of all the draw buffers we want to create
  43646. */
  43647. types?: number[];
  43648. /**
  43649. * Define the sampling modes of all the draw buffers we want to create
  43650. */
  43651. samplingModes?: number[];
  43652. /**
  43653. * Define if a depth buffer is required
  43654. */
  43655. generateDepthBuffer?: boolean;
  43656. /**
  43657. * Define if a stencil buffer is required
  43658. */
  43659. generateStencilBuffer?: boolean;
  43660. /**
  43661. * Define if a depth texture is required instead of a depth buffer
  43662. */
  43663. generateDepthTexture?: boolean;
  43664. /**
  43665. * Define the number of desired draw buffers
  43666. */
  43667. textureCount?: number;
  43668. /**
  43669. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43670. */
  43671. doNotChangeAspectRatio?: boolean;
  43672. /**
  43673. * Define the default type of the buffers we are creating
  43674. */
  43675. defaultType?: number;
  43676. }
  43677. /**
  43678. * A multi render target, like a render target provides the ability to render to a texture.
  43679. * Unlike the render target, it can render to several draw buffers in one draw.
  43680. * This is specially interesting in deferred rendering or for any effects requiring more than
  43681. * just one color from a single pass.
  43682. */
  43683. export class MultiRenderTarget extends RenderTargetTexture {
  43684. private _internalTextures;
  43685. private _textures;
  43686. private _multiRenderTargetOptions;
  43687. /**
  43688. * Get if draw buffers are currently supported by the used hardware and browser.
  43689. */
  43690. readonly isSupported: boolean;
  43691. /**
  43692. * Get the list of textures generated by the multi render target.
  43693. */
  43694. readonly textures: Texture[];
  43695. /**
  43696. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43697. */
  43698. readonly depthTexture: Texture;
  43699. /**
  43700. * Set the wrapping mode on U of all the textures we are rendering to.
  43701. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43702. */
  43703. wrapU: number;
  43704. /**
  43705. * Set the wrapping mode on V of all the textures we are rendering to.
  43706. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43707. */
  43708. wrapV: number;
  43709. /**
  43710. * Instantiate a new multi render target texture.
  43711. * A multi render target, like a render target provides the ability to render to a texture.
  43712. * Unlike the render target, it can render to several draw buffers in one draw.
  43713. * This is specially interesting in deferred rendering or for any effects requiring more than
  43714. * just one color from a single pass.
  43715. * @param name Define the name of the texture
  43716. * @param size Define the size of the buffers to render to
  43717. * @param count Define the number of target we are rendering into
  43718. * @param scene Define the scene the texture belongs to
  43719. * @param options Define the options used to create the multi render target
  43720. */
  43721. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43722. /** @hidden */
  43723. _rebuild(): void;
  43724. private _createInternalTextures;
  43725. private _createTextures;
  43726. /**
  43727. * Define the number of samples used if MSAA is enabled.
  43728. */
  43729. samples: number;
  43730. /**
  43731. * Resize all the textures in the multi render target.
  43732. * Be carrefull as it will recreate all the data in the new texture.
  43733. * @param size Define the new size
  43734. */
  43735. resize(size: any): void;
  43736. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43737. /**
  43738. * Dispose the render targets and their associated resources
  43739. */
  43740. dispose(): void;
  43741. /**
  43742. * Release all the underlying texture used as draw buffers.
  43743. */
  43744. releaseInternalTextures(): void;
  43745. }
  43746. }
  43747. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43749. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43750. import { Nullable } from "babylonjs/types";
  43751. module "babylonjs/Engines/engine" {
  43752. interface Engine {
  43753. /**
  43754. * Unbind a list of render target textures from the webGL context
  43755. * This is used only when drawBuffer extension or webGL2 are active
  43756. * @param textures defines the render target textures to unbind
  43757. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43758. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43759. */
  43760. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43761. /**
  43762. * Create a multi render target texture
  43763. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43764. * @param size defines the size of the texture
  43765. * @param options defines the creation options
  43766. * @returns the cube texture as an InternalTexture
  43767. */
  43768. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43769. /**
  43770. * Update the sample count for a given multiple render target texture
  43771. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43772. * @param textures defines the textures to update
  43773. * @param samples defines the sample count to set
  43774. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43775. */
  43776. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43777. }
  43778. }
  43779. }
  43780. declare module "babylonjs/Engines/Extensions/index" {
  43781. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43782. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43783. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43784. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43785. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43786. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43787. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43788. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43789. }
  43790. declare module "babylonjs/Engines/index" {
  43791. export * from "babylonjs/Engines/constants";
  43792. export * from "babylonjs/Engines/engine";
  43793. export * from "babylonjs/Engines/engineStore";
  43794. export * from "babylonjs/Engines/nullEngine";
  43795. export * from "babylonjs/Engines/Extensions/index";
  43796. export * from "babylonjs/Engines/IPipelineContext";
  43797. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43798. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43799. }
  43800. declare module "babylonjs/Events/clipboardEvents" {
  43801. /**
  43802. * Gather the list of clipboard event types as constants.
  43803. */
  43804. export class ClipboardEventTypes {
  43805. /**
  43806. * The clipboard event is fired when a copy command is active (pressed).
  43807. */
  43808. static readonly COPY: number;
  43809. /**
  43810. * The clipboard event is fired when a cut command is active (pressed).
  43811. */
  43812. static readonly CUT: number;
  43813. /**
  43814. * The clipboard event is fired when a paste command is active (pressed).
  43815. */
  43816. static readonly PASTE: number;
  43817. }
  43818. /**
  43819. * This class is used to store clipboard related info for the onClipboardObservable event.
  43820. */
  43821. export class ClipboardInfo {
  43822. /**
  43823. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43824. */
  43825. type: number;
  43826. /**
  43827. * Defines the related dom event
  43828. */
  43829. event: ClipboardEvent;
  43830. /**
  43831. *Creates an instance of ClipboardInfo.
  43832. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43833. * @param event Defines the related dom event
  43834. */
  43835. constructor(
  43836. /**
  43837. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43838. */
  43839. type: number,
  43840. /**
  43841. * Defines the related dom event
  43842. */
  43843. event: ClipboardEvent);
  43844. /**
  43845. * Get the clipboard event's type from the keycode.
  43846. * @param keyCode Defines the keyCode for the current keyboard event.
  43847. * @return {number}
  43848. */
  43849. static GetTypeFromCharacter(keyCode: number): number;
  43850. }
  43851. }
  43852. declare module "babylonjs/Events/index" {
  43853. export * from "babylonjs/Events/keyboardEvents";
  43854. export * from "babylonjs/Events/pointerEvents";
  43855. export * from "babylonjs/Events/clipboardEvents";
  43856. }
  43857. declare module "babylonjs/Loading/sceneLoader" {
  43858. import { Observable } from "babylonjs/Misc/observable";
  43859. import { Nullable } from "babylonjs/types";
  43860. import { Scene } from "babylonjs/scene";
  43861. import { Engine } from "babylonjs/Engines/engine";
  43862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43863. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43864. import { AssetContainer } from "babylonjs/assetContainer";
  43865. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43866. import { Skeleton } from "babylonjs/Bones/skeleton";
  43867. /**
  43868. * Class used to represent data loading progression
  43869. */
  43870. export class SceneLoaderProgressEvent {
  43871. /** defines if data length to load can be evaluated */
  43872. readonly lengthComputable: boolean;
  43873. /** defines the loaded data length */
  43874. readonly loaded: number;
  43875. /** defines the data length to load */
  43876. readonly total: number;
  43877. /**
  43878. * Create a new progress event
  43879. * @param lengthComputable defines if data length to load can be evaluated
  43880. * @param loaded defines the loaded data length
  43881. * @param total defines the data length to load
  43882. */
  43883. constructor(
  43884. /** defines if data length to load can be evaluated */
  43885. lengthComputable: boolean,
  43886. /** defines the loaded data length */
  43887. loaded: number,
  43888. /** defines the data length to load */
  43889. total: number);
  43890. /**
  43891. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43892. * @param event defines the source event
  43893. * @returns a new SceneLoaderProgressEvent
  43894. */
  43895. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43896. }
  43897. /**
  43898. * Interface used by SceneLoader plugins to define supported file extensions
  43899. */
  43900. export interface ISceneLoaderPluginExtensions {
  43901. /**
  43902. * Defines the list of supported extensions
  43903. */
  43904. [extension: string]: {
  43905. isBinary: boolean;
  43906. };
  43907. }
  43908. /**
  43909. * Interface used by SceneLoader plugin factory
  43910. */
  43911. export interface ISceneLoaderPluginFactory {
  43912. /**
  43913. * Defines the name of the factory
  43914. */
  43915. name: string;
  43916. /**
  43917. * Function called to create a new plugin
  43918. * @return the new plugin
  43919. */
  43920. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43921. /**
  43922. * Boolean indicating if the plugin can direct load specific data
  43923. */
  43924. canDirectLoad?: (data: string) => boolean;
  43925. }
  43926. /**
  43927. * Interface used to define a SceneLoader plugin
  43928. */
  43929. export interface ISceneLoaderPlugin {
  43930. /**
  43931. * The friendly name of this plugin.
  43932. */
  43933. name: string;
  43934. /**
  43935. * The file extensions supported by this plugin.
  43936. */
  43937. extensions: string | ISceneLoaderPluginExtensions;
  43938. /**
  43939. * Import meshes into a scene.
  43940. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43941. * @param scene The scene to import into
  43942. * @param data The data to import
  43943. * @param rootUrl The root url for scene and resources
  43944. * @param meshes The meshes array to import into
  43945. * @param particleSystems The particle systems array to import into
  43946. * @param skeletons The skeletons array to import into
  43947. * @param onError The callback when import fails
  43948. * @returns True if successful or false otherwise
  43949. */
  43950. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43951. /**
  43952. * Load into a scene.
  43953. * @param scene The scene to load into
  43954. * @param data The data to import
  43955. * @param rootUrl The root url for scene and resources
  43956. * @param onError The callback when import fails
  43957. * @returns true if successful or false otherwise
  43958. */
  43959. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43960. /**
  43961. * The callback that returns true if the data can be directly loaded.
  43962. */
  43963. canDirectLoad?: (data: string) => boolean;
  43964. /**
  43965. * The callback that allows custom handling of the root url based on the response url.
  43966. */
  43967. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43968. /**
  43969. * Load into an asset container.
  43970. * @param scene The scene to load into
  43971. * @param data The data to import
  43972. * @param rootUrl The root url for scene and resources
  43973. * @param onError The callback when import fails
  43974. * @returns The loaded asset container
  43975. */
  43976. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43977. }
  43978. /**
  43979. * Interface used to define an async SceneLoader plugin
  43980. */
  43981. export interface ISceneLoaderPluginAsync {
  43982. /**
  43983. * The friendly name of this plugin.
  43984. */
  43985. name: string;
  43986. /**
  43987. * The file extensions supported by this plugin.
  43988. */
  43989. extensions: string | ISceneLoaderPluginExtensions;
  43990. /**
  43991. * Import meshes into a scene.
  43992. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43993. * @param scene The scene to import into
  43994. * @param data The data to import
  43995. * @param rootUrl The root url for scene and resources
  43996. * @param onProgress The callback when the load progresses
  43997. * @param fileName Defines the name of the file to load
  43998. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43999. */
  44000. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44001. meshes: AbstractMesh[];
  44002. particleSystems: IParticleSystem[];
  44003. skeletons: Skeleton[];
  44004. animationGroups: AnimationGroup[];
  44005. }>;
  44006. /**
  44007. * Load into a scene.
  44008. * @param scene The scene to load into
  44009. * @param data The data to import
  44010. * @param rootUrl The root url for scene and resources
  44011. * @param onProgress The callback when the load progresses
  44012. * @param fileName Defines the name of the file to load
  44013. * @returns Nothing
  44014. */
  44015. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44016. /**
  44017. * The callback that returns true if the data can be directly loaded.
  44018. */
  44019. canDirectLoad?: (data: string) => boolean;
  44020. /**
  44021. * The callback that allows custom handling of the root url based on the response url.
  44022. */
  44023. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44024. /**
  44025. * Load into an asset container.
  44026. * @param scene The scene to load into
  44027. * @param data The data to import
  44028. * @param rootUrl The root url for scene and resources
  44029. * @param onProgress The callback when the load progresses
  44030. * @param fileName Defines the name of the file to load
  44031. * @returns The loaded asset container
  44032. */
  44033. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44034. }
  44035. /**
  44036. * Class used to load scene from various file formats using registered plugins
  44037. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44038. */
  44039. export class SceneLoader {
  44040. /**
  44041. * No logging while loading
  44042. */
  44043. static readonly NO_LOGGING: number;
  44044. /**
  44045. * Minimal logging while loading
  44046. */
  44047. static readonly MINIMAL_LOGGING: number;
  44048. /**
  44049. * Summary logging while loading
  44050. */
  44051. static readonly SUMMARY_LOGGING: number;
  44052. /**
  44053. * Detailled logging while loading
  44054. */
  44055. static readonly DETAILED_LOGGING: number;
  44056. /**
  44057. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44058. */
  44059. static ForceFullSceneLoadingForIncremental: boolean;
  44060. /**
  44061. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44062. */
  44063. static ShowLoadingScreen: boolean;
  44064. /**
  44065. * Defines the current logging level (while loading the scene)
  44066. * @ignorenaming
  44067. */
  44068. static loggingLevel: number;
  44069. /**
  44070. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44071. */
  44072. static CleanBoneMatrixWeights: boolean;
  44073. /**
  44074. * Event raised when a plugin is used to load a scene
  44075. */
  44076. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44077. private static _registeredPlugins;
  44078. private static _getDefaultPlugin;
  44079. private static _getPluginForExtension;
  44080. private static _getPluginForDirectLoad;
  44081. private static _getPluginForFilename;
  44082. private static _getDirectLoad;
  44083. private static _loadData;
  44084. private static _getFileInfo;
  44085. /**
  44086. * Gets a plugin that can load the given extension
  44087. * @param extension defines the extension to load
  44088. * @returns a plugin or null if none works
  44089. */
  44090. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44091. /**
  44092. * Gets a boolean indicating that the given extension can be loaded
  44093. * @param extension defines the extension to load
  44094. * @returns true if the extension is supported
  44095. */
  44096. static IsPluginForExtensionAvailable(extension: string): boolean;
  44097. /**
  44098. * Adds a new plugin to the list of registered plugins
  44099. * @param plugin defines the plugin to add
  44100. */
  44101. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44102. /**
  44103. * Import meshes into a scene
  44104. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44105. * @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)
  44106. * @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)
  44107. * @param scene the instance of BABYLON.Scene to append to
  44108. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44109. * @param onProgress a callback with a progress event for each file being loaded
  44110. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44111. * @param pluginExtension the extension used to determine the plugin
  44112. * @returns The loaded plugin
  44113. */
  44114. 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>;
  44115. /**
  44116. * Import meshes into a scene
  44117. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44118. * @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)
  44119. * @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)
  44120. * @param scene the instance of BABYLON.Scene to append to
  44121. * @param onProgress a callback with a progress event for each file being loaded
  44122. * @param pluginExtension the extension used to determine the plugin
  44123. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44124. */
  44125. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44126. meshes: AbstractMesh[];
  44127. particleSystems: IParticleSystem[];
  44128. skeletons: Skeleton[];
  44129. animationGroups: AnimationGroup[];
  44130. }>;
  44131. /**
  44132. * Load a scene
  44133. * @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)
  44134. * @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)
  44135. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44136. * @param onSuccess a callback with the scene when import succeeds
  44137. * @param onProgress a callback with a progress event for each file being loaded
  44138. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44139. * @param pluginExtension the extension used to determine the plugin
  44140. * @returns The loaded plugin
  44141. */
  44142. 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>;
  44143. /**
  44144. * Load a scene
  44145. * @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)
  44146. * @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)
  44147. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44148. * @param onProgress a callback with a progress event for each file being loaded
  44149. * @param pluginExtension the extension used to determine the plugin
  44150. * @returns The loaded scene
  44151. */
  44152. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44153. /**
  44154. * Append a scene
  44155. * @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)
  44156. * @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)
  44157. * @param scene is the instance of BABYLON.Scene to append to
  44158. * @param onSuccess a callback with the scene when import succeeds
  44159. * @param onProgress a callback with a progress event for each file being loaded
  44160. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44161. * @param pluginExtension the extension used to determine the plugin
  44162. * @returns The loaded plugin
  44163. */
  44164. 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>;
  44165. /**
  44166. * Append a scene
  44167. * @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)
  44168. * @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)
  44169. * @param scene is the instance of BABYLON.Scene to append to
  44170. * @param onProgress a callback with a progress event for each file being loaded
  44171. * @param pluginExtension the extension used to determine the plugin
  44172. * @returns The given scene
  44173. */
  44174. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44175. /**
  44176. * Load a scene into an asset container
  44177. * @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)
  44178. * @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)
  44179. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44180. * @param onSuccess a callback with the scene when import succeeds
  44181. * @param onProgress a callback with a progress event for each file being loaded
  44182. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44183. * @param pluginExtension the extension used to determine the plugin
  44184. * @returns The loaded plugin
  44185. */
  44186. 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>;
  44187. /**
  44188. * Load a scene into an asset container
  44189. * @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)
  44190. * @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)
  44191. * @param scene is the instance of Scene to append to
  44192. * @param onProgress a callback with a progress event for each file being loaded
  44193. * @param pluginExtension the extension used to determine the plugin
  44194. * @returns The loaded asset container
  44195. */
  44196. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44197. }
  44198. }
  44199. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44200. import { Scene } from "babylonjs/scene";
  44201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44202. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44203. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44204. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44205. /**
  44206. * Google Daydream controller
  44207. */
  44208. export class DaydreamController extends WebVRController {
  44209. /**
  44210. * Base Url for the controller model.
  44211. */
  44212. static MODEL_BASE_URL: string;
  44213. /**
  44214. * File name for the controller model.
  44215. */
  44216. static MODEL_FILENAME: string;
  44217. /**
  44218. * Gamepad Id prefix used to identify Daydream Controller.
  44219. */
  44220. static readonly GAMEPAD_ID_PREFIX: string;
  44221. /**
  44222. * Creates a new DaydreamController from a gamepad
  44223. * @param vrGamepad the gamepad that the controller should be created from
  44224. */
  44225. constructor(vrGamepad: any);
  44226. /**
  44227. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44228. * @param scene scene in which to add meshes
  44229. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44230. */
  44231. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44232. /**
  44233. * Called once for each button that changed state since the last frame
  44234. * @param buttonIdx Which button index changed
  44235. * @param state New state of the button
  44236. * @param changes Which properties on the state changed since last frame
  44237. */
  44238. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44239. }
  44240. }
  44241. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44242. import { Scene } from "babylonjs/scene";
  44243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44244. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44245. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44246. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44247. /**
  44248. * Gear VR Controller
  44249. */
  44250. export class GearVRController extends WebVRController {
  44251. /**
  44252. * Base Url for the controller model.
  44253. */
  44254. static MODEL_BASE_URL: string;
  44255. /**
  44256. * File name for the controller model.
  44257. */
  44258. static MODEL_FILENAME: string;
  44259. /**
  44260. * Gamepad Id prefix used to identify this controller.
  44261. */
  44262. static readonly GAMEPAD_ID_PREFIX: string;
  44263. private readonly _buttonIndexToObservableNameMap;
  44264. /**
  44265. * Creates a new GearVRController from a gamepad
  44266. * @param vrGamepad the gamepad that the controller should be created from
  44267. */
  44268. constructor(vrGamepad: any);
  44269. /**
  44270. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44271. * @param scene scene in which to add meshes
  44272. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44273. */
  44274. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44275. /**
  44276. * Called once for each button that changed state since the last frame
  44277. * @param buttonIdx Which button index changed
  44278. * @param state New state of the button
  44279. * @param changes Which properties on the state changed since last frame
  44280. */
  44281. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44282. }
  44283. }
  44284. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44285. import { Scene } from "babylonjs/scene";
  44286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44287. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44288. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44289. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44290. /**
  44291. * Generic Controller
  44292. */
  44293. export class GenericController extends WebVRController {
  44294. /**
  44295. * Base Url for the controller model.
  44296. */
  44297. static readonly MODEL_BASE_URL: string;
  44298. /**
  44299. * File name for the controller model.
  44300. */
  44301. static readonly MODEL_FILENAME: string;
  44302. /**
  44303. * Creates a new GenericController from a gamepad
  44304. * @param vrGamepad the gamepad that the controller should be created from
  44305. */
  44306. constructor(vrGamepad: any);
  44307. /**
  44308. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44309. * @param scene scene in which to add meshes
  44310. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44311. */
  44312. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44313. /**
  44314. * Called once for each button that changed state since the last frame
  44315. * @param buttonIdx Which button index changed
  44316. * @param state New state of the button
  44317. * @param changes Which properties on the state changed since last frame
  44318. */
  44319. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44320. }
  44321. }
  44322. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44323. import { Observable } from "babylonjs/Misc/observable";
  44324. import { Scene } from "babylonjs/scene";
  44325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44326. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44327. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44328. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44329. /**
  44330. * Oculus Touch Controller
  44331. */
  44332. export class OculusTouchController extends WebVRController {
  44333. /**
  44334. * Base Url for the controller model.
  44335. */
  44336. static MODEL_BASE_URL: string;
  44337. /**
  44338. * File name for the left controller model.
  44339. */
  44340. static MODEL_LEFT_FILENAME: string;
  44341. /**
  44342. * File name for the right controller model.
  44343. */
  44344. static MODEL_RIGHT_FILENAME: string;
  44345. /**
  44346. * Fired when the secondary trigger on this controller is modified
  44347. */
  44348. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44349. /**
  44350. * Fired when the thumb rest on this controller is modified
  44351. */
  44352. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44353. /**
  44354. * Creates a new OculusTouchController from a gamepad
  44355. * @param vrGamepad the gamepad that the controller should be created from
  44356. */
  44357. constructor(vrGamepad: any);
  44358. /**
  44359. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44360. * @param scene scene in which to add meshes
  44361. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44362. */
  44363. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44364. /**
  44365. * Fired when the A button on this controller is modified
  44366. */
  44367. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44368. /**
  44369. * Fired when the B button on this controller is modified
  44370. */
  44371. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44372. /**
  44373. * Fired when the X button on this controller is modified
  44374. */
  44375. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44376. /**
  44377. * Fired when the Y button on this controller is modified
  44378. */
  44379. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44380. /**
  44381. * Called once for each button that changed state since the last frame
  44382. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44383. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44384. * 2) secondary trigger (same)
  44385. * 3) A (right) X (left), touch, pressed = value
  44386. * 4) B / Y
  44387. * 5) thumb rest
  44388. * @param buttonIdx Which button index changed
  44389. * @param state New state of the button
  44390. * @param changes Which properties on the state changed since last frame
  44391. */
  44392. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44393. }
  44394. }
  44395. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44396. import { Scene } from "babylonjs/scene";
  44397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44398. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44399. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44400. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44401. import { Observable } from "babylonjs/Misc/observable";
  44402. /**
  44403. * Vive Controller
  44404. */
  44405. export class ViveController extends WebVRController {
  44406. /**
  44407. * Base Url for the controller model.
  44408. */
  44409. static MODEL_BASE_URL: string;
  44410. /**
  44411. * File name for the controller model.
  44412. */
  44413. static MODEL_FILENAME: string;
  44414. /**
  44415. * Creates a new ViveController from a gamepad
  44416. * @param vrGamepad the gamepad that the controller should be created from
  44417. */
  44418. constructor(vrGamepad: any);
  44419. /**
  44420. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44421. * @param scene scene in which to add meshes
  44422. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44423. */
  44424. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44425. /**
  44426. * Fired when the left button on this controller is modified
  44427. */
  44428. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44429. /**
  44430. * Fired when the right button on this controller is modified
  44431. */
  44432. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44433. /**
  44434. * Fired when the menu button on this controller is modified
  44435. */
  44436. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44437. /**
  44438. * Called once for each button that changed state since the last frame
  44439. * Vive mapping:
  44440. * 0: touchpad
  44441. * 1: trigger
  44442. * 2: left AND right buttons
  44443. * 3: menu button
  44444. * @param buttonIdx Which button index changed
  44445. * @param state New state of the button
  44446. * @param changes Which properties on the state changed since last frame
  44447. */
  44448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44449. }
  44450. }
  44451. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44452. import { Observable } from "babylonjs/Misc/observable";
  44453. import { Scene } from "babylonjs/scene";
  44454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44455. import { Ray } from "babylonjs/Culling/ray";
  44456. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44457. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44458. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44459. /**
  44460. * Defines the WindowsMotionController object that the state of the windows motion controller
  44461. */
  44462. export class WindowsMotionController extends WebVRController {
  44463. /**
  44464. * The base url used to load the left and right controller models
  44465. */
  44466. static MODEL_BASE_URL: string;
  44467. /**
  44468. * The name of the left controller model file
  44469. */
  44470. static MODEL_LEFT_FILENAME: string;
  44471. /**
  44472. * The name of the right controller model file
  44473. */
  44474. static MODEL_RIGHT_FILENAME: string;
  44475. /**
  44476. * The controller name prefix for this controller type
  44477. */
  44478. static readonly GAMEPAD_ID_PREFIX: string;
  44479. /**
  44480. * The controller id pattern for this controller type
  44481. */
  44482. private static readonly GAMEPAD_ID_PATTERN;
  44483. private _loadedMeshInfo;
  44484. private readonly _mapping;
  44485. /**
  44486. * Fired when the trackpad on this controller is clicked
  44487. */
  44488. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44489. /**
  44490. * Fired when the trackpad on this controller is modified
  44491. */
  44492. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44493. /**
  44494. * The current x and y values of this controller's trackpad
  44495. */
  44496. trackpad: StickValues;
  44497. /**
  44498. * Creates a new WindowsMotionController from a gamepad
  44499. * @param vrGamepad the gamepad that the controller should be created from
  44500. */
  44501. constructor(vrGamepad: any);
  44502. /**
  44503. * Fired when the trigger on this controller is modified
  44504. */
  44505. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44506. /**
  44507. * Fired when the menu button on this controller is modified
  44508. */
  44509. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44510. /**
  44511. * Fired when the grip button on this controller is modified
  44512. */
  44513. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44514. /**
  44515. * Fired when the thumbstick button on this controller is modified
  44516. */
  44517. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44518. /**
  44519. * Fired when the touchpad button on this controller is modified
  44520. */
  44521. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44522. /**
  44523. * Fired when the touchpad values on this controller are modified
  44524. */
  44525. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44526. private _updateTrackpad;
  44527. /**
  44528. * Called once per frame by the engine.
  44529. */
  44530. update(): void;
  44531. /**
  44532. * Called once for each button that changed state since the last frame
  44533. * @param buttonIdx Which button index changed
  44534. * @param state New state of the button
  44535. * @param changes Which properties on the state changed since last frame
  44536. */
  44537. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44538. /**
  44539. * Moves the buttons on the controller mesh based on their current state
  44540. * @param buttonName the name of the button to move
  44541. * @param buttonValue the value of the button which determines the buttons new position
  44542. */
  44543. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44544. /**
  44545. * Moves the axis on the controller mesh based on its current state
  44546. * @param axis the index of the axis
  44547. * @param axisValue the value of the axis which determines the meshes new position
  44548. * @hidden
  44549. */
  44550. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44551. /**
  44552. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44553. * @param scene scene in which to add meshes
  44554. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44555. */
  44556. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44557. /**
  44558. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44559. * can be transformed by button presses and axes values, based on this._mapping.
  44560. *
  44561. * @param scene scene in which the meshes exist
  44562. * @param meshes list of meshes that make up the controller model to process
  44563. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44564. */
  44565. private processModel;
  44566. private createMeshInfo;
  44567. /**
  44568. * Gets the ray of the controller in the direction the controller is pointing
  44569. * @param length the length the resulting ray should be
  44570. * @returns a ray in the direction the controller is pointing
  44571. */
  44572. getForwardRay(length?: number): Ray;
  44573. /**
  44574. * Disposes of the controller
  44575. */
  44576. dispose(): void;
  44577. }
  44578. }
  44579. declare module "babylonjs/Gamepads/Controllers/index" {
  44580. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44581. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44582. export * from "babylonjs/Gamepads/Controllers/genericController";
  44583. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44584. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44585. export * from "babylonjs/Gamepads/Controllers/viveController";
  44586. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44587. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44588. }
  44589. declare module "babylonjs/Gamepads/index" {
  44590. export * from "babylonjs/Gamepads/Controllers/index";
  44591. export * from "babylonjs/Gamepads/gamepad";
  44592. export * from "babylonjs/Gamepads/gamepadManager";
  44593. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44594. export * from "babylonjs/Gamepads/xboxGamepad";
  44595. }
  44596. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44597. import { Scene } from "babylonjs/scene";
  44598. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44599. import { Mesh } from "babylonjs/Meshes/mesh";
  44600. import { Nullable } from "babylonjs/types";
  44601. /**
  44602. * Class containing static functions to help procedurally build meshes
  44603. */
  44604. export class PolyhedronBuilder {
  44605. /**
  44606. * Creates a polyhedron mesh
  44607. * * 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
  44608. * * The parameter `size` (positive float, default 1) sets the polygon size
  44609. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44610. * * 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`
  44611. * * 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
  44612. * * 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)`)
  44613. * * 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
  44614. * * 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
  44615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44618. * @param name defines the name of the mesh
  44619. * @param options defines the options used to create the mesh
  44620. * @param scene defines the hosting scene
  44621. * @returns the polyhedron mesh
  44622. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44623. */
  44624. static CreatePolyhedron(name: string, options: {
  44625. type?: number;
  44626. size?: number;
  44627. sizeX?: number;
  44628. sizeY?: number;
  44629. sizeZ?: number;
  44630. custom?: any;
  44631. faceUV?: Vector4[];
  44632. faceColors?: Color4[];
  44633. flat?: boolean;
  44634. updatable?: boolean;
  44635. sideOrientation?: number;
  44636. frontUVs?: Vector4;
  44637. backUVs?: Vector4;
  44638. }, scene?: Nullable<Scene>): Mesh;
  44639. }
  44640. }
  44641. declare module "babylonjs/Gizmos/scaleGizmo" {
  44642. import { Observable } from "babylonjs/Misc/observable";
  44643. import { Nullable } from "babylonjs/types";
  44644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44645. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44646. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44647. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44648. /**
  44649. * Gizmo that enables scaling a mesh along 3 axis
  44650. */
  44651. export class ScaleGizmo extends Gizmo {
  44652. /**
  44653. * Internal gizmo used for interactions on the x axis
  44654. */
  44655. xGizmo: AxisScaleGizmo;
  44656. /**
  44657. * Internal gizmo used for interactions on the y axis
  44658. */
  44659. yGizmo: AxisScaleGizmo;
  44660. /**
  44661. * Internal gizmo used for interactions on the z axis
  44662. */
  44663. zGizmo: AxisScaleGizmo;
  44664. /**
  44665. * Internal gizmo used to scale all axis equally
  44666. */
  44667. uniformScaleGizmo: AxisScaleGizmo;
  44668. private _meshAttached;
  44669. private _updateGizmoRotationToMatchAttachedMesh;
  44670. private _snapDistance;
  44671. private _scaleRatio;
  44672. private _uniformScalingMesh;
  44673. private _octahedron;
  44674. /** Fires an event when any of it's sub gizmos are dragged */
  44675. onDragStartObservable: Observable<{}>;
  44676. /** Fires an event when any of it's sub gizmos are released from dragging */
  44677. onDragEndObservable: Observable<{}>;
  44678. attachedMesh: Nullable<AbstractMesh>;
  44679. /**
  44680. * Creates a ScaleGizmo
  44681. * @param gizmoLayer The utility layer the gizmo will be added to
  44682. */
  44683. constructor(gizmoLayer?: UtilityLayerRenderer);
  44684. updateGizmoRotationToMatchAttachedMesh: boolean;
  44685. /**
  44686. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44687. */
  44688. snapDistance: number;
  44689. /**
  44690. * Ratio for the scale of the gizmo (Default: 1)
  44691. */
  44692. scaleRatio: number;
  44693. /**
  44694. * Disposes of the gizmo
  44695. */
  44696. dispose(): void;
  44697. }
  44698. }
  44699. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44700. import { Observable } from "babylonjs/Misc/observable";
  44701. import { Nullable } from "babylonjs/types";
  44702. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44704. import { Mesh } from "babylonjs/Meshes/mesh";
  44705. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44706. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44707. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44708. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44709. /**
  44710. * Single axis scale gizmo
  44711. */
  44712. export class AxisScaleGizmo extends Gizmo {
  44713. /**
  44714. * Drag behavior responsible for the gizmos dragging interactions
  44715. */
  44716. dragBehavior: PointerDragBehavior;
  44717. private _pointerObserver;
  44718. /**
  44719. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44720. */
  44721. snapDistance: number;
  44722. /**
  44723. * Event that fires each time the gizmo snaps to a new location.
  44724. * * snapDistance is the the change in distance
  44725. */
  44726. onSnapObservable: Observable<{
  44727. snapDistance: number;
  44728. }>;
  44729. /**
  44730. * If the scaling operation should be done on all axis (default: false)
  44731. */
  44732. uniformScaling: boolean;
  44733. private _isEnabled;
  44734. private _parent;
  44735. private _arrow;
  44736. private _coloredMaterial;
  44737. private _hoverMaterial;
  44738. /**
  44739. * Creates an AxisScaleGizmo
  44740. * @param gizmoLayer The utility layer the gizmo will be added to
  44741. * @param dragAxis The axis which the gizmo will be able to scale on
  44742. * @param color The color of the gizmo
  44743. */
  44744. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44745. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44746. /**
  44747. * If the gizmo is enabled
  44748. */
  44749. isEnabled: boolean;
  44750. /**
  44751. * Disposes of the gizmo
  44752. */
  44753. dispose(): void;
  44754. /**
  44755. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44756. * @param mesh The mesh to replace the default mesh of the gizmo
  44757. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44758. */
  44759. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44760. }
  44761. }
  44762. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44763. import { Observable } from "babylonjs/Misc/observable";
  44764. import { Nullable } from "babylonjs/types";
  44765. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44767. import { Mesh } from "babylonjs/Meshes/mesh";
  44768. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44769. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44770. import "babylonjs/Meshes/Builders/boxBuilder";
  44771. /**
  44772. * Bounding box gizmo
  44773. */
  44774. export class BoundingBoxGizmo extends Gizmo {
  44775. private _lineBoundingBox;
  44776. private _rotateSpheresParent;
  44777. private _scaleBoxesParent;
  44778. private _boundingDimensions;
  44779. private _renderObserver;
  44780. private _pointerObserver;
  44781. private _scaleDragSpeed;
  44782. private _tmpQuaternion;
  44783. private _tmpVector;
  44784. private _tmpRotationMatrix;
  44785. /**
  44786. * 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)
  44787. */
  44788. ignoreChildren: boolean;
  44789. /**
  44790. * 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)
  44791. */
  44792. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44793. /**
  44794. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44795. */
  44796. rotationSphereSize: number;
  44797. /**
  44798. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44799. */
  44800. scaleBoxSize: number;
  44801. /**
  44802. * 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)
  44803. */
  44804. fixedDragMeshScreenSize: boolean;
  44805. /**
  44806. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44807. */
  44808. fixedDragMeshScreenSizeDistanceFactor: number;
  44809. /**
  44810. * Fired when a rotation sphere or scale box is dragged
  44811. */
  44812. onDragStartObservable: Observable<{}>;
  44813. /**
  44814. * Fired when a scale box is dragged
  44815. */
  44816. onScaleBoxDragObservable: Observable<{}>;
  44817. /**
  44818. * Fired when a scale box drag is ended
  44819. */
  44820. onScaleBoxDragEndObservable: Observable<{}>;
  44821. /**
  44822. * Fired when a rotation sphere is dragged
  44823. */
  44824. onRotationSphereDragObservable: Observable<{}>;
  44825. /**
  44826. * Fired when a rotation sphere drag is ended
  44827. */
  44828. onRotationSphereDragEndObservable: Observable<{}>;
  44829. /**
  44830. * 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)
  44831. */
  44832. scalePivot: Nullable<Vector3>;
  44833. /**
  44834. * Mesh used as a pivot to rotate the attached mesh
  44835. */
  44836. private _anchorMesh;
  44837. private _existingMeshScale;
  44838. private _dragMesh;
  44839. private pointerDragBehavior;
  44840. private coloredMaterial;
  44841. private hoverColoredMaterial;
  44842. /**
  44843. * Sets the color of the bounding box gizmo
  44844. * @param color the color to set
  44845. */
  44846. setColor(color: Color3): void;
  44847. /**
  44848. * Creates an BoundingBoxGizmo
  44849. * @param gizmoLayer The utility layer the gizmo will be added to
  44850. * @param color The color of the gizmo
  44851. */
  44852. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44854. private _selectNode;
  44855. /**
  44856. * Updates the bounding box information for the Gizmo
  44857. */
  44858. updateBoundingBox(): void;
  44859. private _updateRotationSpheres;
  44860. private _updateScaleBoxes;
  44861. /**
  44862. * Enables rotation on the specified axis and disables rotation on the others
  44863. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44864. */
  44865. setEnabledRotationAxis(axis: string): void;
  44866. /**
  44867. * Enables/disables scaling
  44868. * @param enable if scaling should be enabled
  44869. */
  44870. setEnabledScaling(enable: boolean): void;
  44871. private _updateDummy;
  44872. /**
  44873. * Enables a pointer drag behavior on the bounding box of the gizmo
  44874. */
  44875. enableDragBehavior(): void;
  44876. /**
  44877. * Disposes of the gizmo
  44878. */
  44879. dispose(): void;
  44880. /**
  44881. * 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)
  44882. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44883. * @returns the bounding box mesh with the passed in mesh as a child
  44884. */
  44885. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44886. /**
  44887. * CustomMeshes are not supported by this gizmo
  44888. * @param mesh The mesh to replace the default mesh of the gizmo
  44889. */
  44890. setCustomMesh(mesh: Mesh): void;
  44891. }
  44892. }
  44893. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44894. import { Observable } from "babylonjs/Misc/observable";
  44895. import { Nullable } from "babylonjs/types";
  44896. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44898. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44899. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44900. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44901. import "babylonjs/Meshes/Builders/linesBuilder";
  44902. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44903. /**
  44904. * Single plane rotation gizmo
  44905. */
  44906. export class PlaneRotationGizmo extends Gizmo {
  44907. /**
  44908. * Drag behavior responsible for the gizmos dragging interactions
  44909. */
  44910. dragBehavior: PointerDragBehavior;
  44911. private _pointerObserver;
  44912. /**
  44913. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44914. */
  44915. snapDistance: number;
  44916. /**
  44917. * Event that fires each time the gizmo snaps to a new location.
  44918. * * snapDistance is the the change in distance
  44919. */
  44920. onSnapObservable: Observable<{
  44921. snapDistance: number;
  44922. }>;
  44923. private _isEnabled;
  44924. private _parent;
  44925. /**
  44926. * Creates a PlaneRotationGizmo
  44927. * @param gizmoLayer The utility layer the gizmo will be added to
  44928. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44929. * @param color The color of the gizmo
  44930. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44931. */
  44932. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  44933. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44934. /**
  44935. * If the gizmo is enabled
  44936. */
  44937. isEnabled: boolean;
  44938. /**
  44939. * Disposes of the gizmo
  44940. */
  44941. dispose(): void;
  44942. }
  44943. }
  44944. declare module "babylonjs/Gizmos/rotationGizmo" {
  44945. import { Observable } from "babylonjs/Misc/observable";
  44946. import { Nullable } from "babylonjs/types";
  44947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44948. import { Mesh } from "babylonjs/Meshes/mesh";
  44949. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44950. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44951. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44952. /**
  44953. * Gizmo that enables rotating a mesh along 3 axis
  44954. */
  44955. export class RotationGizmo extends Gizmo {
  44956. /**
  44957. * Internal gizmo used for interactions on the x axis
  44958. */
  44959. xGizmo: PlaneRotationGizmo;
  44960. /**
  44961. * Internal gizmo used for interactions on the y axis
  44962. */
  44963. yGizmo: PlaneRotationGizmo;
  44964. /**
  44965. * Internal gizmo used for interactions on the z axis
  44966. */
  44967. zGizmo: PlaneRotationGizmo;
  44968. /** Fires an event when any of it's sub gizmos are dragged */
  44969. onDragStartObservable: Observable<{}>;
  44970. /** Fires an event when any of it's sub gizmos are released from dragging */
  44971. onDragEndObservable: Observable<{}>;
  44972. private _meshAttached;
  44973. attachedMesh: Nullable<AbstractMesh>;
  44974. /**
  44975. * Creates a RotationGizmo
  44976. * @param gizmoLayer The utility layer the gizmo will be added to
  44977. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44978. */
  44979. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44980. updateGizmoRotationToMatchAttachedMesh: boolean;
  44981. /**
  44982. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44983. */
  44984. snapDistance: number;
  44985. /**
  44986. * Ratio for the scale of the gizmo (Default: 1)
  44987. */
  44988. scaleRatio: number;
  44989. /**
  44990. * Disposes of the gizmo
  44991. */
  44992. dispose(): void;
  44993. /**
  44994. * CustomMeshes are not supported by this gizmo
  44995. * @param mesh The mesh to replace the default mesh of the gizmo
  44996. */
  44997. setCustomMesh(mesh: Mesh): void;
  44998. }
  44999. }
  45000. declare module "babylonjs/Gizmos/gizmoManager" {
  45001. import { Observable } from "babylonjs/Misc/observable";
  45002. import { Nullable } from "babylonjs/types";
  45003. import { Scene, IDisposable } from "babylonjs/scene";
  45004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45005. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45006. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45007. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45008. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45009. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45010. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45011. /**
  45012. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45013. */
  45014. export class GizmoManager implements IDisposable {
  45015. private scene;
  45016. /**
  45017. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45018. */
  45019. gizmos: {
  45020. positionGizmo: Nullable<PositionGizmo>;
  45021. rotationGizmo: Nullable<RotationGizmo>;
  45022. scaleGizmo: Nullable<ScaleGizmo>;
  45023. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45024. };
  45025. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45026. clearGizmoOnEmptyPointerEvent: boolean;
  45027. /** Fires an event when the manager is attached to a mesh */
  45028. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45029. private _gizmosEnabled;
  45030. private _pointerObserver;
  45031. private _attachedMesh;
  45032. private _boundingBoxColor;
  45033. private _defaultUtilityLayer;
  45034. private _defaultKeepDepthUtilityLayer;
  45035. /**
  45036. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45037. */
  45038. boundingBoxDragBehavior: SixDofDragBehavior;
  45039. /**
  45040. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45041. */
  45042. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45043. /**
  45044. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45045. */
  45046. usePointerToAttachGizmos: boolean;
  45047. /**
  45048. * Utility layer that the bounding box gizmo belongs to
  45049. */
  45050. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45051. /**
  45052. * Utility layer that all gizmos besides bounding box belong to
  45053. */
  45054. readonly utilityLayer: UtilityLayerRenderer;
  45055. /**
  45056. * Instatiates a gizmo manager
  45057. * @param scene the scene to overlay the gizmos on top of
  45058. */
  45059. constructor(scene: Scene);
  45060. /**
  45061. * Attaches a set of gizmos to the specified mesh
  45062. * @param mesh The mesh the gizmo's should be attached to
  45063. */
  45064. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45065. /**
  45066. * If the position gizmo is enabled
  45067. */
  45068. positionGizmoEnabled: boolean;
  45069. /**
  45070. * If the rotation gizmo is enabled
  45071. */
  45072. rotationGizmoEnabled: boolean;
  45073. /**
  45074. * If the scale gizmo is enabled
  45075. */
  45076. scaleGizmoEnabled: boolean;
  45077. /**
  45078. * If the boundingBox gizmo is enabled
  45079. */
  45080. boundingBoxGizmoEnabled: boolean;
  45081. /**
  45082. * Disposes of the gizmo manager
  45083. */
  45084. dispose(): void;
  45085. }
  45086. }
  45087. declare module "babylonjs/Lights/directionalLight" {
  45088. import { Camera } from "babylonjs/Cameras/camera";
  45089. import { Scene } from "babylonjs/scene";
  45090. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45092. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45093. import { Effect } from "babylonjs/Materials/effect";
  45094. /**
  45095. * A directional light is defined by a direction (what a surprise!).
  45096. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45097. * 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.
  45098. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45099. */
  45100. export class DirectionalLight extends ShadowLight {
  45101. private _shadowFrustumSize;
  45102. /**
  45103. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45104. */
  45105. /**
  45106. * Specifies a fix frustum size for the shadow generation.
  45107. */
  45108. shadowFrustumSize: number;
  45109. private _shadowOrthoScale;
  45110. /**
  45111. * Gets the shadow projection scale against the optimal computed one.
  45112. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45113. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45114. */
  45115. /**
  45116. * Sets the shadow projection scale against the optimal computed one.
  45117. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45118. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45119. */
  45120. shadowOrthoScale: number;
  45121. /**
  45122. * Automatically compute the projection matrix to best fit (including all the casters)
  45123. * on each frame.
  45124. */
  45125. autoUpdateExtends: boolean;
  45126. private _orthoLeft;
  45127. private _orthoRight;
  45128. private _orthoTop;
  45129. private _orthoBottom;
  45130. /**
  45131. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45132. * The directional light is emitted from everywhere in the given direction.
  45133. * It can cast shadows.
  45134. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45135. * @param name The friendly name of the light
  45136. * @param direction The direction of the light
  45137. * @param scene The scene the light belongs to
  45138. */
  45139. constructor(name: string, direction: Vector3, scene: Scene);
  45140. /**
  45141. * Returns the string "DirectionalLight".
  45142. * @return The class name
  45143. */
  45144. getClassName(): string;
  45145. /**
  45146. * Returns the integer 1.
  45147. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45148. */
  45149. getTypeID(): number;
  45150. /**
  45151. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45152. * Returns the DirectionalLight Shadow projection matrix.
  45153. */
  45154. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45155. /**
  45156. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45157. * Returns the DirectionalLight Shadow projection matrix.
  45158. */
  45159. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45160. /**
  45161. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45162. * Returns the DirectionalLight Shadow projection matrix.
  45163. */
  45164. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45165. protected _buildUniformLayout(): void;
  45166. /**
  45167. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45168. * @param effect The effect to update
  45169. * @param lightIndex The index of the light in the effect to update
  45170. * @returns The directional light
  45171. */
  45172. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45173. /**
  45174. * Gets the minZ used for shadow according to both the scene and the light.
  45175. *
  45176. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45177. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45178. * @param activeCamera The camera we are returning the min for
  45179. * @returns the depth min z
  45180. */
  45181. getDepthMinZ(activeCamera: Camera): number;
  45182. /**
  45183. * Gets the maxZ used for shadow according to both the scene and the light.
  45184. *
  45185. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45186. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45187. * @param activeCamera The camera we are returning the max for
  45188. * @returns the depth max z
  45189. */
  45190. getDepthMaxZ(activeCamera: Camera): number;
  45191. /**
  45192. * Prepares the list of defines specific to the light type.
  45193. * @param defines the list of defines
  45194. * @param lightIndex defines the index of the light for the effect
  45195. */
  45196. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45197. }
  45198. }
  45199. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45200. import { Mesh } from "babylonjs/Meshes/mesh";
  45201. /**
  45202. * Class containing static functions to help procedurally build meshes
  45203. */
  45204. export class HemisphereBuilder {
  45205. /**
  45206. * Creates a hemisphere mesh
  45207. * @param name defines the name of the mesh
  45208. * @param options defines the options used to create the mesh
  45209. * @param scene defines the hosting scene
  45210. * @returns the hemisphere mesh
  45211. */
  45212. static CreateHemisphere(name: string, options: {
  45213. segments?: number;
  45214. diameter?: number;
  45215. sideOrientation?: number;
  45216. }, scene: any): Mesh;
  45217. }
  45218. }
  45219. declare module "babylonjs/Lights/spotLight" {
  45220. import { Nullable } from "babylonjs/types";
  45221. import { Scene } from "babylonjs/scene";
  45222. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45224. import { Effect } from "babylonjs/Materials/effect";
  45225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45226. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45227. /**
  45228. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45229. * These values define a cone of light starting from the position, emitting toward the direction.
  45230. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45231. * and the exponent defines the speed of the decay of the light with distance (reach).
  45232. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45233. */
  45234. export class SpotLight extends ShadowLight {
  45235. private _angle;
  45236. private _innerAngle;
  45237. private _cosHalfAngle;
  45238. private _lightAngleScale;
  45239. private _lightAngleOffset;
  45240. /**
  45241. * Gets the cone angle of the spot light in Radians.
  45242. */
  45243. /**
  45244. * Sets the cone angle of the spot light in Radians.
  45245. */
  45246. angle: number;
  45247. /**
  45248. * Only used in gltf falloff mode, this defines the angle where
  45249. * the directional falloff will start before cutting at angle which could be seen
  45250. * as outer angle.
  45251. */
  45252. /**
  45253. * Only used in gltf falloff mode, this defines the angle where
  45254. * the directional falloff will start before cutting at angle which could be seen
  45255. * as outer angle.
  45256. */
  45257. innerAngle: number;
  45258. private _shadowAngleScale;
  45259. /**
  45260. * Allows scaling the angle of the light for shadow generation only.
  45261. */
  45262. /**
  45263. * Allows scaling the angle of the light for shadow generation only.
  45264. */
  45265. shadowAngleScale: number;
  45266. /**
  45267. * The light decay speed with the distance from the emission spot.
  45268. */
  45269. exponent: number;
  45270. private _projectionTextureMatrix;
  45271. /**
  45272. * Allows reading the projecton texture
  45273. */
  45274. readonly projectionTextureMatrix: Matrix;
  45275. protected _projectionTextureLightNear: number;
  45276. /**
  45277. * Gets the near clip of the Spotlight for texture projection.
  45278. */
  45279. /**
  45280. * Sets the near clip of the Spotlight for texture projection.
  45281. */
  45282. projectionTextureLightNear: number;
  45283. protected _projectionTextureLightFar: number;
  45284. /**
  45285. * Gets the far clip of the Spotlight for texture projection.
  45286. */
  45287. /**
  45288. * Sets the far clip of the Spotlight for texture projection.
  45289. */
  45290. projectionTextureLightFar: number;
  45291. protected _projectionTextureUpDirection: Vector3;
  45292. /**
  45293. * Gets the Up vector of the Spotlight for texture projection.
  45294. */
  45295. /**
  45296. * Sets the Up vector of the Spotlight for texture projection.
  45297. */
  45298. projectionTextureUpDirection: Vector3;
  45299. private _projectionTexture;
  45300. /**
  45301. * Gets the projection texture of the light.
  45302. */
  45303. /**
  45304. * Sets the projection texture of the light.
  45305. */
  45306. projectionTexture: Nullable<BaseTexture>;
  45307. private _projectionTextureViewLightDirty;
  45308. private _projectionTextureProjectionLightDirty;
  45309. private _projectionTextureDirty;
  45310. private _projectionTextureViewTargetVector;
  45311. private _projectionTextureViewLightMatrix;
  45312. private _projectionTextureProjectionLightMatrix;
  45313. private _projectionTextureScalingMatrix;
  45314. /**
  45315. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45316. * It can cast shadows.
  45317. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45318. * @param name The light friendly name
  45319. * @param position The position of the spot light in the scene
  45320. * @param direction The direction of the light in the scene
  45321. * @param angle The cone angle of the light in Radians
  45322. * @param exponent The light decay speed with the distance from the emission spot
  45323. * @param scene The scene the lights belongs to
  45324. */
  45325. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45326. /**
  45327. * Returns the string "SpotLight".
  45328. * @returns the class name
  45329. */
  45330. getClassName(): string;
  45331. /**
  45332. * Returns the integer 2.
  45333. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45334. */
  45335. getTypeID(): number;
  45336. /**
  45337. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45338. */
  45339. protected _setDirection(value: Vector3): void;
  45340. /**
  45341. * Overrides the position setter to recompute the projection texture view light Matrix.
  45342. */
  45343. protected _setPosition(value: Vector3): void;
  45344. /**
  45345. * 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.
  45346. * Returns the SpotLight.
  45347. */
  45348. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45349. protected _computeProjectionTextureViewLightMatrix(): void;
  45350. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45351. /**
  45352. * Main function for light texture projection matrix computing.
  45353. */
  45354. protected _computeProjectionTextureMatrix(): void;
  45355. protected _buildUniformLayout(): void;
  45356. private _computeAngleValues;
  45357. /**
  45358. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45359. * @param effect The effect to update
  45360. * @param lightIndex The index of the light in the effect to update
  45361. * @returns The spot light
  45362. */
  45363. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45364. /**
  45365. * Disposes the light and the associated resources.
  45366. */
  45367. dispose(): void;
  45368. /**
  45369. * Prepares the list of defines specific to the light type.
  45370. * @param defines the list of defines
  45371. * @param lightIndex defines the index of the light for the effect
  45372. */
  45373. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45374. }
  45375. }
  45376. declare module "babylonjs/Gizmos/lightGizmo" {
  45377. import { Nullable } from "babylonjs/types";
  45378. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45379. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45380. import { Light } from "babylonjs/Lights/light";
  45381. /**
  45382. * Gizmo that enables viewing a light
  45383. */
  45384. export class LightGizmo extends Gizmo {
  45385. private _lightMesh;
  45386. private _material;
  45387. private cachedPosition;
  45388. private cachedForward;
  45389. /**
  45390. * Creates a LightGizmo
  45391. * @param gizmoLayer The utility layer the gizmo will be added to
  45392. */
  45393. constructor(gizmoLayer?: UtilityLayerRenderer);
  45394. private _light;
  45395. /**
  45396. * The light that the gizmo is attached to
  45397. */
  45398. light: Nullable<Light>;
  45399. /**
  45400. * @hidden
  45401. * Updates the gizmo to match the attached mesh's position/rotation
  45402. */
  45403. protected _update(): void;
  45404. private static _Scale;
  45405. /**
  45406. * Creates the lines for a light mesh
  45407. */
  45408. private static _createLightLines;
  45409. /**
  45410. * Disposes of the light gizmo
  45411. */
  45412. dispose(): void;
  45413. private static _CreateHemisphericLightMesh;
  45414. private static _CreatePointLightMesh;
  45415. private static _CreateSpotLightMesh;
  45416. private static _CreateDirectionalLightMesh;
  45417. }
  45418. }
  45419. declare module "babylonjs/Gizmos/index" {
  45420. export * from "babylonjs/Gizmos/axisDragGizmo";
  45421. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45422. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45423. export * from "babylonjs/Gizmos/gizmo";
  45424. export * from "babylonjs/Gizmos/gizmoManager";
  45425. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45426. export * from "babylonjs/Gizmos/positionGizmo";
  45427. export * from "babylonjs/Gizmos/rotationGizmo";
  45428. export * from "babylonjs/Gizmos/scaleGizmo";
  45429. export * from "babylonjs/Gizmos/lightGizmo";
  45430. }
  45431. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45432. /** @hidden */
  45433. export var backgroundFragmentDeclaration: {
  45434. name: string;
  45435. shader: string;
  45436. };
  45437. }
  45438. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45439. /** @hidden */
  45440. export var backgroundUboDeclaration: {
  45441. name: string;
  45442. shader: string;
  45443. };
  45444. }
  45445. declare module "babylonjs/Shaders/background.fragment" {
  45446. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45447. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45448. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45449. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45450. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45451. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45453. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45454. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45455. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45456. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45457. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45458. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45459. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45460. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45461. /** @hidden */
  45462. export var backgroundPixelShader: {
  45463. name: string;
  45464. shader: string;
  45465. };
  45466. }
  45467. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45468. /** @hidden */
  45469. export var backgroundVertexDeclaration: {
  45470. name: string;
  45471. shader: string;
  45472. };
  45473. }
  45474. declare module "babylonjs/Shaders/background.vertex" {
  45475. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45476. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45477. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45478. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45479. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45480. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45481. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45482. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45483. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45484. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45485. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45486. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45487. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45488. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45489. /** @hidden */
  45490. export var backgroundVertexShader: {
  45491. name: string;
  45492. shader: string;
  45493. };
  45494. }
  45495. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45496. import { Nullable, int, float } from "babylonjs/types";
  45497. import { Scene } from "babylonjs/scene";
  45498. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45499. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45501. import { Mesh } from "babylonjs/Meshes/mesh";
  45502. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45503. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45504. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45506. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45507. import "babylonjs/Shaders/background.fragment";
  45508. import "babylonjs/Shaders/background.vertex";
  45509. /**
  45510. * Background material used to create an efficient environement around your scene.
  45511. */
  45512. export class BackgroundMaterial extends PushMaterial {
  45513. /**
  45514. * Standard reflectance value at parallel view angle.
  45515. */
  45516. static StandardReflectance0: number;
  45517. /**
  45518. * Standard reflectance value at grazing angle.
  45519. */
  45520. static StandardReflectance90: number;
  45521. protected _primaryColor: Color3;
  45522. /**
  45523. * Key light Color (multiply against the environement texture)
  45524. */
  45525. primaryColor: Color3;
  45526. protected __perceptualColor: Nullable<Color3>;
  45527. /**
  45528. * Experimental Internal Use Only.
  45529. *
  45530. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45531. * This acts as a helper to set the primary color to a more "human friendly" value.
  45532. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45533. * output color as close as possible from the chosen value.
  45534. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45535. * part of lighting setup.)
  45536. */
  45537. _perceptualColor: Nullable<Color3>;
  45538. protected _primaryColorShadowLevel: float;
  45539. /**
  45540. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45541. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45542. */
  45543. primaryColorShadowLevel: float;
  45544. protected _primaryColorHighlightLevel: float;
  45545. /**
  45546. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45547. * The primary color is used at the level chosen to define what the white area would look.
  45548. */
  45549. primaryColorHighlightLevel: float;
  45550. protected _reflectionTexture: Nullable<BaseTexture>;
  45551. /**
  45552. * Reflection Texture used in the material.
  45553. * Should be author in a specific way for the best result (refer to the documentation).
  45554. */
  45555. reflectionTexture: Nullable<BaseTexture>;
  45556. protected _reflectionBlur: float;
  45557. /**
  45558. * Reflection Texture level of blur.
  45559. *
  45560. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45561. * texture twice.
  45562. */
  45563. reflectionBlur: float;
  45564. protected _diffuseTexture: Nullable<BaseTexture>;
  45565. /**
  45566. * Diffuse Texture used in the material.
  45567. * Should be author in a specific way for the best result (refer to the documentation).
  45568. */
  45569. diffuseTexture: Nullable<BaseTexture>;
  45570. protected _shadowLights: Nullable<IShadowLight[]>;
  45571. /**
  45572. * Specify the list of lights casting shadow on the material.
  45573. * All scene shadow lights will be included if null.
  45574. */
  45575. shadowLights: Nullable<IShadowLight[]>;
  45576. protected _shadowLevel: float;
  45577. /**
  45578. * Helps adjusting the shadow to a softer level if required.
  45579. * 0 means black shadows and 1 means no shadows.
  45580. */
  45581. shadowLevel: float;
  45582. protected _sceneCenter: Vector3;
  45583. /**
  45584. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45585. * It is usually zero but might be interesting to modify according to your setup.
  45586. */
  45587. sceneCenter: Vector3;
  45588. protected _opacityFresnel: boolean;
  45589. /**
  45590. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45591. * This helps ensuring a nice transition when the camera goes under the ground.
  45592. */
  45593. opacityFresnel: boolean;
  45594. protected _reflectionFresnel: boolean;
  45595. /**
  45596. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45597. * This helps adding a mirror texture on the ground.
  45598. */
  45599. reflectionFresnel: boolean;
  45600. protected _reflectionFalloffDistance: number;
  45601. /**
  45602. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45603. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45604. */
  45605. reflectionFalloffDistance: number;
  45606. protected _reflectionAmount: number;
  45607. /**
  45608. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45609. */
  45610. reflectionAmount: number;
  45611. protected _reflectionReflectance0: number;
  45612. /**
  45613. * This specifies the weight of the reflection at grazing angle.
  45614. */
  45615. reflectionReflectance0: number;
  45616. protected _reflectionReflectance90: number;
  45617. /**
  45618. * This specifies the weight of the reflection at a perpendicular point of view.
  45619. */
  45620. reflectionReflectance90: number;
  45621. /**
  45622. * Sets the reflection reflectance fresnel values according to the default standard
  45623. * empirically know to work well :-)
  45624. */
  45625. reflectionStandardFresnelWeight: number;
  45626. protected _useRGBColor: boolean;
  45627. /**
  45628. * Helps to directly use the maps channels instead of their level.
  45629. */
  45630. useRGBColor: boolean;
  45631. protected _enableNoise: boolean;
  45632. /**
  45633. * This helps reducing the banding effect that could occur on the background.
  45634. */
  45635. enableNoise: boolean;
  45636. /**
  45637. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45638. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45639. * Recommended to be keep at 1.0 except for special cases.
  45640. */
  45641. fovMultiplier: number;
  45642. private _fovMultiplier;
  45643. /**
  45644. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45645. */
  45646. useEquirectangularFOV: boolean;
  45647. private _maxSimultaneousLights;
  45648. /**
  45649. * Number of Simultaneous lights allowed on the material.
  45650. */
  45651. maxSimultaneousLights: int;
  45652. /**
  45653. * Default configuration related to image processing available in the Background Material.
  45654. */
  45655. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45656. /**
  45657. * Keep track of the image processing observer to allow dispose and replace.
  45658. */
  45659. private _imageProcessingObserver;
  45660. /**
  45661. * Attaches a new image processing configuration to the PBR Material.
  45662. * @param configuration (if null the scene configuration will be use)
  45663. */
  45664. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45665. /**
  45666. * Gets the image processing configuration used either in this material.
  45667. */
  45668. /**
  45669. * Sets the Default image processing configuration used either in the this material.
  45670. *
  45671. * If sets to null, the scene one is in use.
  45672. */
  45673. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45674. /**
  45675. * Gets wether the color curves effect is enabled.
  45676. */
  45677. /**
  45678. * Sets wether the color curves effect is enabled.
  45679. */
  45680. cameraColorCurvesEnabled: boolean;
  45681. /**
  45682. * Gets wether the color grading effect is enabled.
  45683. */
  45684. /**
  45685. * Gets wether the color grading effect is enabled.
  45686. */
  45687. cameraColorGradingEnabled: boolean;
  45688. /**
  45689. * Gets wether tonemapping is enabled or not.
  45690. */
  45691. /**
  45692. * Sets wether tonemapping is enabled or not
  45693. */
  45694. cameraToneMappingEnabled: boolean;
  45695. /**
  45696. * The camera exposure used on this material.
  45697. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45698. * This corresponds to a photographic exposure.
  45699. */
  45700. /**
  45701. * The camera exposure used on this material.
  45702. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45703. * This corresponds to a photographic exposure.
  45704. */
  45705. cameraExposure: float;
  45706. /**
  45707. * Gets The camera contrast used on this material.
  45708. */
  45709. /**
  45710. * Sets The camera contrast used on this material.
  45711. */
  45712. cameraContrast: float;
  45713. /**
  45714. * Gets the Color Grading 2D Lookup Texture.
  45715. */
  45716. /**
  45717. * Sets the Color Grading 2D Lookup Texture.
  45718. */
  45719. cameraColorGradingTexture: Nullable<BaseTexture>;
  45720. /**
  45721. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45722. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45723. * 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;
  45724. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45725. */
  45726. /**
  45727. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45728. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45729. * 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;
  45730. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45731. */
  45732. cameraColorCurves: Nullable<ColorCurves>;
  45733. /**
  45734. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45735. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45736. */
  45737. switchToBGR: boolean;
  45738. private _renderTargets;
  45739. private _reflectionControls;
  45740. private _white;
  45741. private _primaryShadowColor;
  45742. private _primaryHighlightColor;
  45743. /**
  45744. * Instantiates a Background Material in the given scene
  45745. * @param name The friendly name of the material
  45746. * @param scene The scene to add the material to
  45747. */
  45748. constructor(name: string, scene: Scene);
  45749. /**
  45750. * Gets a boolean indicating that current material needs to register RTT
  45751. */
  45752. readonly hasRenderTargetTextures: boolean;
  45753. /**
  45754. * The entire material has been created in order to prevent overdraw.
  45755. * @returns false
  45756. */
  45757. needAlphaTesting(): boolean;
  45758. /**
  45759. * The entire material has been created in order to prevent overdraw.
  45760. * @returns true if blending is enable
  45761. */
  45762. needAlphaBlending(): boolean;
  45763. /**
  45764. * Checks wether the material is ready to be rendered for a given mesh.
  45765. * @param mesh The mesh to render
  45766. * @param subMesh The submesh to check against
  45767. * @param useInstances Specify wether or not the material is used with instances
  45768. * @returns true if all the dependencies are ready (Textures, Effects...)
  45769. */
  45770. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45771. /**
  45772. * Compute the primary color according to the chosen perceptual color.
  45773. */
  45774. private _computePrimaryColorFromPerceptualColor;
  45775. /**
  45776. * Compute the highlights and shadow colors according to their chosen levels.
  45777. */
  45778. private _computePrimaryColors;
  45779. /**
  45780. * Build the uniform buffer used in the material.
  45781. */
  45782. buildUniformLayout(): void;
  45783. /**
  45784. * Unbind the material.
  45785. */
  45786. unbind(): void;
  45787. /**
  45788. * Bind only the world matrix to the material.
  45789. * @param world The world matrix to bind.
  45790. */
  45791. bindOnlyWorldMatrix(world: Matrix): void;
  45792. /**
  45793. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45794. * @param world The world matrix to bind.
  45795. * @param subMesh The submesh to bind for.
  45796. */
  45797. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45798. /**
  45799. * Dispose the material.
  45800. * @param forceDisposeEffect Force disposal of the associated effect.
  45801. * @param forceDisposeTextures Force disposal of the associated textures.
  45802. */
  45803. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45804. /**
  45805. * Clones the material.
  45806. * @param name The cloned name.
  45807. * @returns The cloned material.
  45808. */
  45809. clone(name: string): BackgroundMaterial;
  45810. /**
  45811. * Serializes the current material to its JSON representation.
  45812. * @returns The JSON representation.
  45813. */
  45814. serialize(): any;
  45815. /**
  45816. * Gets the class name of the material
  45817. * @returns "BackgroundMaterial"
  45818. */
  45819. getClassName(): string;
  45820. /**
  45821. * Parse a JSON input to create back a background material.
  45822. * @param source The JSON data to parse
  45823. * @param scene The scene to create the parsed material in
  45824. * @param rootUrl The root url of the assets the material depends upon
  45825. * @returns the instantiated BackgroundMaterial.
  45826. */
  45827. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45828. }
  45829. }
  45830. declare module "babylonjs/Helpers/environmentHelper" {
  45831. import { Observable } from "babylonjs/Misc/observable";
  45832. import { Nullable } from "babylonjs/types";
  45833. import { Scene } from "babylonjs/scene";
  45834. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45836. import { Mesh } from "babylonjs/Meshes/mesh";
  45837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45838. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45839. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45840. import "babylonjs/Meshes/Builders/planeBuilder";
  45841. import "babylonjs/Meshes/Builders/boxBuilder";
  45842. /**
  45843. * Represents the different options available during the creation of
  45844. * a Environment helper.
  45845. *
  45846. * This can control the default ground, skybox and image processing setup of your scene.
  45847. */
  45848. export interface IEnvironmentHelperOptions {
  45849. /**
  45850. * Specifies wether or not to create a ground.
  45851. * True by default.
  45852. */
  45853. createGround: boolean;
  45854. /**
  45855. * Specifies the ground size.
  45856. * 15 by default.
  45857. */
  45858. groundSize: number;
  45859. /**
  45860. * The texture used on the ground for the main color.
  45861. * Comes from the BabylonJS CDN by default.
  45862. *
  45863. * Remarks: Can be either a texture or a url.
  45864. */
  45865. groundTexture: string | BaseTexture;
  45866. /**
  45867. * The color mixed in the ground texture by default.
  45868. * BabylonJS clearColor by default.
  45869. */
  45870. groundColor: Color3;
  45871. /**
  45872. * Specifies the ground opacity.
  45873. * 1 by default.
  45874. */
  45875. groundOpacity: number;
  45876. /**
  45877. * Enables the ground to receive shadows.
  45878. * True by default.
  45879. */
  45880. enableGroundShadow: boolean;
  45881. /**
  45882. * Helps preventing the shadow to be fully black on the ground.
  45883. * 0.5 by default.
  45884. */
  45885. groundShadowLevel: number;
  45886. /**
  45887. * Creates a mirror texture attach to the ground.
  45888. * false by default.
  45889. */
  45890. enableGroundMirror: boolean;
  45891. /**
  45892. * Specifies the ground mirror size ratio.
  45893. * 0.3 by default as the default kernel is 64.
  45894. */
  45895. groundMirrorSizeRatio: number;
  45896. /**
  45897. * Specifies the ground mirror blur kernel size.
  45898. * 64 by default.
  45899. */
  45900. groundMirrorBlurKernel: number;
  45901. /**
  45902. * Specifies the ground mirror visibility amount.
  45903. * 1 by default
  45904. */
  45905. groundMirrorAmount: number;
  45906. /**
  45907. * Specifies the ground mirror reflectance weight.
  45908. * This uses the standard weight of the background material to setup the fresnel effect
  45909. * of the mirror.
  45910. * 1 by default.
  45911. */
  45912. groundMirrorFresnelWeight: number;
  45913. /**
  45914. * Specifies the ground mirror Falloff distance.
  45915. * This can helps reducing the size of the reflection.
  45916. * 0 by Default.
  45917. */
  45918. groundMirrorFallOffDistance: number;
  45919. /**
  45920. * Specifies the ground mirror texture type.
  45921. * Unsigned Int by Default.
  45922. */
  45923. groundMirrorTextureType: number;
  45924. /**
  45925. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45926. * the shown objects.
  45927. */
  45928. groundYBias: number;
  45929. /**
  45930. * Specifies wether or not to create a skybox.
  45931. * True by default.
  45932. */
  45933. createSkybox: boolean;
  45934. /**
  45935. * Specifies the skybox size.
  45936. * 20 by default.
  45937. */
  45938. skyboxSize: number;
  45939. /**
  45940. * The texture used on the skybox for the main color.
  45941. * Comes from the BabylonJS CDN by default.
  45942. *
  45943. * Remarks: Can be either a texture or a url.
  45944. */
  45945. skyboxTexture: string | BaseTexture;
  45946. /**
  45947. * The color mixed in the skybox texture by default.
  45948. * BabylonJS clearColor by default.
  45949. */
  45950. skyboxColor: Color3;
  45951. /**
  45952. * The background rotation around the Y axis of the scene.
  45953. * This helps aligning the key lights of your scene with the background.
  45954. * 0 by default.
  45955. */
  45956. backgroundYRotation: number;
  45957. /**
  45958. * Compute automatically the size of the elements to best fit with the scene.
  45959. */
  45960. sizeAuto: boolean;
  45961. /**
  45962. * Default position of the rootMesh if autoSize is not true.
  45963. */
  45964. rootPosition: Vector3;
  45965. /**
  45966. * Sets up the image processing in the scene.
  45967. * true by default.
  45968. */
  45969. setupImageProcessing: boolean;
  45970. /**
  45971. * The texture used as your environment texture in the scene.
  45972. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45973. *
  45974. * Remarks: Can be either a texture or a url.
  45975. */
  45976. environmentTexture: string | BaseTexture;
  45977. /**
  45978. * The value of the exposure to apply to the scene.
  45979. * 0.6 by default if setupImageProcessing is true.
  45980. */
  45981. cameraExposure: number;
  45982. /**
  45983. * The value of the contrast to apply to the scene.
  45984. * 1.6 by default if setupImageProcessing is true.
  45985. */
  45986. cameraContrast: number;
  45987. /**
  45988. * Specifies wether or not tonemapping should be enabled in the scene.
  45989. * true by default if setupImageProcessing is true.
  45990. */
  45991. toneMappingEnabled: boolean;
  45992. }
  45993. /**
  45994. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45995. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45996. * It also helps with the default setup of your imageProcessing configuration.
  45997. */
  45998. export class EnvironmentHelper {
  45999. /**
  46000. * Default ground texture URL.
  46001. */
  46002. private static _groundTextureCDNUrl;
  46003. /**
  46004. * Default skybox texture URL.
  46005. */
  46006. private static _skyboxTextureCDNUrl;
  46007. /**
  46008. * Default environment texture URL.
  46009. */
  46010. private static _environmentTextureCDNUrl;
  46011. /**
  46012. * Creates the default options for the helper.
  46013. */
  46014. private static _getDefaultOptions;
  46015. private _rootMesh;
  46016. /**
  46017. * Gets the root mesh created by the helper.
  46018. */
  46019. readonly rootMesh: Mesh;
  46020. private _skybox;
  46021. /**
  46022. * Gets the skybox created by the helper.
  46023. */
  46024. readonly skybox: Nullable<Mesh>;
  46025. private _skyboxTexture;
  46026. /**
  46027. * Gets the skybox texture created by the helper.
  46028. */
  46029. readonly skyboxTexture: Nullable<BaseTexture>;
  46030. private _skyboxMaterial;
  46031. /**
  46032. * Gets the skybox material created by the helper.
  46033. */
  46034. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46035. private _ground;
  46036. /**
  46037. * Gets the ground mesh created by the helper.
  46038. */
  46039. readonly ground: Nullable<Mesh>;
  46040. private _groundTexture;
  46041. /**
  46042. * Gets the ground texture created by the helper.
  46043. */
  46044. readonly groundTexture: Nullable<BaseTexture>;
  46045. private _groundMirror;
  46046. /**
  46047. * Gets the ground mirror created by the helper.
  46048. */
  46049. readonly groundMirror: Nullable<MirrorTexture>;
  46050. /**
  46051. * Gets the ground mirror render list to helps pushing the meshes
  46052. * you wish in the ground reflection.
  46053. */
  46054. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46055. private _groundMaterial;
  46056. /**
  46057. * Gets the ground material created by the helper.
  46058. */
  46059. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46060. /**
  46061. * Stores the creation options.
  46062. */
  46063. private readonly _scene;
  46064. private _options;
  46065. /**
  46066. * This observable will be notified with any error during the creation of the environment,
  46067. * mainly texture creation errors.
  46068. */
  46069. onErrorObservable: Observable<{
  46070. message?: string;
  46071. exception?: any;
  46072. }>;
  46073. /**
  46074. * constructor
  46075. * @param options Defines the options we want to customize the helper
  46076. * @param scene The scene to add the material to
  46077. */
  46078. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46079. /**
  46080. * Updates the background according to the new options
  46081. * @param options
  46082. */
  46083. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46084. /**
  46085. * Sets the primary color of all the available elements.
  46086. * @param color the main color to affect to the ground and the background
  46087. */
  46088. setMainColor(color: Color3): void;
  46089. /**
  46090. * Setup the image processing according to the specified options.
  46091. */
  46092. private _setupImageProcessing;
  46093. /**
  46094. * Setup the environment texture according to the specified options.
  46095. */
  46096. private _setupEnvironmentTexture;
  46097. /**
  46098. * Setup the background according to the specified options.
  46099. */
  46100. private _setupBackground;
  46101. /**
  46102. * Get the scene sizes according to the setup.
  46103. */
  46104. private _getSceneSize;
  46105. /**
  46106. * Setup the ground according to the specified options.
  46107. */
  46108. private _setupGround;
  46109. /**
  46110. * Setup the ground material according to the specified options.
  46111. */
  46112. private _setupGroundMaterial;
  46113. /**
  46114. * Setup the ground diffuse texture according to the specified options.
  46115. */
  46116. private _setupGroundDiffuseTexture;
  46117. /**
  46118. * Setup the ground mirror texture according to the specified options.
  46119. */
  46120. private _setupGroundMirrorTexture;
  46121. /**
  46122. * Setup the ground to receive the mirror texture.
  46123. */
  46124. private _setupMirrorInGroundMaterial;
  46125. /**
  46126. * Setup the skybox according to the specified options.
  46127. */
  46128. private _setupSkybox;
  46129. /**
  46130. * Setup the skybox material according to the specified options.
  46131. */
  46132. private _setupSkyboxMaterial;
  46133. /**
  46134. * Setup the skybox reflection texture according to the specified options.
  46135. */
  46136. private _setupSkyboxReflectionTexture;
  46137. private _errorHandler;
  46138. /**
  46139. * Dispose all the elements created by the Helper.
  46140. */
  46141. dispose(): void;
  46142. }
  46143. }
  46144. declare module "babylonjs/Helpers/photoDome" {
  46145. import { Observable } from "babylonjs/Misc/observable";
  46146. import { Nullable } from "babylonjs/types";
  46147. import { Scene } from "babylonjs/scene";
  46148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46149. import { Mesh } from "babylonjs/Meshes/mesh";
  46150. import { Texture } from "babylonjs/Materials/Textures/texture";
  46151. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46152. import "babylonjs/Meshes/Builders/sphereBuilder";
  46153. /**
  46154. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46155. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46156. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46157. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46158. */
  46159. export class PhotoDome extends TransformNode {
  46160. /**
  46161. * Define the image as a Monoscopic panoramic 360 image.
  46162. */
  46163. static readonly MODE_MONOSCOPIC: number;
  46164. /**
  46165. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46166. */
  46167. static readonly MODE_TOPBOTTOM: number;
  46168. /**
  46169. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46170. */
  46171. static readonly MODE_SIDEBYSIDE: number;
  46172. private _useDirectMapping;
  46173. /**
  46174. * The texture being displayed on the sphere
  46175. */
  46176. protected _photoTexture: Texture;
  46177. /**
  46178. * Gets or sets the texture being displayed on the sphere
  46179. */
  46180. photoTexture: Texture;
  46181. /**
  46182. * Observable raised when an error occured while loading the 360 image
  46183. */
  46184. onLoadErrorObservable: Observable<string>;
  46185. /**
  46186. * The skybox material
  46187. */
  46188. protected _material: BackgroundMaterial;
  46189. /**
  46190. * The surface used for the skybox
  46191. */
  46192. protected _mesh: Mesh;
  46193. /**
  46194. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46195. * Also see the options.resolution property.
  46196. */
  46197. fovMultiplier: number;
  46198. private _imageMode;
  46199. /**
  46200. * Gets or set the current video mode for the video. It can be:
  46201. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46202. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46203. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46204. */
  46205. imageMode: number;
  46206. /**
  46207. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46208. * @param name Element's name, child elements will append suffixes for their own names.
  46209. * @param urlsOfPhoto defines the url of the photo to display
  46210. * @param options defines an object containing optional or exposed sub element properties
  46211. * @param onError defines a callback called when an error occured while loading the texture
  46212. */
  46213. constructor(name: string, urlOfPhoto: string, options: {
  46214. resolution?: number;
  46215. size?: number;
  46216. useDirectMapping?: boolean;
  46217. faceForward?: boolean;
  46218. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46219. private _onBeforeCameraRenderObserver;
  46220. private _changeImageMode;
  46221. /**
  46222. * Releases resources associated with this node.
  46223. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46224. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46225. */
  46226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46227. }
  46228. }
  46229. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46230. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46231. /** @hidden */
  46232. export var rgbdDecodePixelShader: {
  46233. name: string;
  46234. shader: string;
  46235. };
  46236. }
  46237. declare module "babylonjs/Misc/brdfTextureTools" {
  46238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46239. import { Scene } from "babylonjs/scene";
  46240. import "babylonjs/Shaders/rgbdDecode.fragment";
  46241. /**
  46242. * Class used to host texture specific utilities
  46243. */
  46244. export class BRDFTextureTools {
  46245. /**
  46246. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46247. * @param texture the texture to expand.
  46248. */
  46249. private static _ExpandDefaultBRDFTexture;
  46250. /**
  46251. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46252. * @param scene defines the hosting scene
  46253. * @returns the environment BRDF texture
  46254. */
  46255. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46256. private static _environmentBRDFBase64Texture;
  46257. }
  46258. }
  46259. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46260. import { Nullable } from "babylonjs/types";
  46261. import { IAnimatable } from "babylonjs/Misc/tools";
  46262. import { Color3 } from "babylonjs/Maths/math";
  46263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46264. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46265. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46266. import { Engine } from "babylonjs/Engines/engine";
  46267. import { Scene } from "babylonjs/scene";
  46268. /**
  46269. * @hidden
  46270. */
  46271. export interface IMaterialClearCoatDefines {
  46272. CLEARCOAT: boolean;
  46273. CLEARCOAT_DEFAULTIOR: boolean;
  46274. CLEARCOAT_TEXTURE: boolean;
  46275. CLEARCOAT_TEXTUREDIRECTUV: number;
  46276. CLEARCOAT_BUMP: boolean;
  46277. CLEARCOAT_BUMPDIRECTUV: number;
  46278. CLEARCOAT_TINT: boolean;
  46279. CLEARCOAT_TINT_TEXTURE: boolean;
  46280. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46281. /** @hidden */
  46282. _areTexturesDirty: boolean;
  46283. }
  46284. /**
  46285. * Define the code related to the clear coat parameters of the pbr material.
  46286. */
  46287. export class PBRClearCoatConfiguration {
  46288. /**
  46289. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46290. * The default fits with a polyurethane material.
  46291. */
  46292. private static readonly _DefaultIndexOfRefraction;
  46293. private _isEnabled;
  46294. /**
  46295. * Defines if the clear coat is enabled in the material.
  46296. */
  46297. isEnabled: boolean;
  46298. /**
  46299. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46300. */
  46301. intensity: number;
  46302. /**
  46303. * Defines the clear coat layer roughness.
  46304. */
  46305. roughness: number;
  46306. private _indexOfRefraction;
  46307. /**
  46308. * Defines the index of refraction of the clear coat.
  46309. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46310. * The default fits with a polyurethane material.
  46311. * Changing the default value is more performance intensive.
  46312. */
  46313. indexOfRefraction: number;
  46314. private _texture;
  46315. /**
  46316. * Stores the clear coat values in a texture.
  46317. */
  46318. texture: Nullable<BaseTexture>;
  46319. private _bumpTexture;
  46320. /**
  46321. * Define the clear coat specific bump texture.
  46322. */
  46323. bumpTexture: Nullable<BaseTexture>;
  46324. private _isTintEnabled;
  46325. /**
  46326. * Defines if the clear coat tint is enabled in the material.
  46327. */
  46328. isTintEnabled: boolean;
  46329. /**
  46330. * Defines the clear coat tint of the material.
  46331. * This is only use if tint is enabled
  46332. */
  46333. tintColor: Color3;
  46334. /**
  46335. * Defines the distance at which the tint color should be found in the
  46336. * clear coat media.
  46337. * This is only use if tint is enabled
  46338. */
  46339. tintColorAtDistance: number;
  46340. /**
  46341. * Defines the clear coat layer thickness.
  46342. * This is only use if tint is enabled
  46343. */
  46344. tintThickness: number;
  46345. private _tintTexture;
  46346. /**
  46347. * Stores the clear tint values in a texture.
  46348. * rgb is tint
  46349. * a is a thickness factor
  46350. */
  46351. tintTexture: Nullable<BaseTexture>;
  46352. /** @hidden */
  46353. private _internalMarkAllSubMeshesAsTexturesDirty;
  46354. /** @hidden */
  46355. _markAllSubMeshesAsTexturesDirty(): void;
  46356. /**
  46357. * Instantiate a new istance of clear coat configuration.
  46358. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46359. */
  46360. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46361. /**
  46362. * Gets wehter the submesh is ready to be used or not.
  46363. * @param defines the list of "defines" to update.
  46364. * @param scene defines the scene the material belongs to.
  46365. * @param engine defines the engine the material belongs to.
  46366. * @param disableBumpMap defines wether the material disables bump or not.
  46367. * @returns - boolean indicating that the submesh is ready or not.
  46368. */
  46369. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46370. /**
  46371. * Checks to see if a texture is used in the material.
  46372. * @param defines the list of "defines" to update.
  46373. * @param scene defines the scene to the material belongs to.
  46374. */
  46375. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46376. /**
  46377. * Binds the material data.
  46378. * @param uniformBuffer defines the Uniform buffer to fill in.
  46379. * @param scene defines the scene the material belongs to.
  46380. * @param engine defines the engine the material belongs to.
  46381. * @param disableBumpMap defines wether the material disables bump or not.
  46382. * @param isFrozen defines wether the material is frozen or not.
  46383. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46384. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46385. */
  46386. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46387. /**
  46388. * Checks to see if a texture is used in the material.
  46389. * @param texture - Base texture to use.
  46390. * @returns - Boolean specifying if a texture is used in the material.
  46391. */
  46392. hasTexture(texture: BaseTexture): boolean;
  46393. /**
  46394. * Returns an array of the actively used textures.
  46395. * @param activeTextures Array of BaseTextures
  46396. */
  46397. getActiveTextures(activeTextures: BaseTexture[]): void;
  46398. /**
  46399. * Returns the animatable textures.
  46400. * @param animatables Array of animatable textures.
  46401. */
  46402. getAnimatables(animatables: IAnimatable[]): void;
  46403. /**
  46404. * Disposes the resources of the material.
  46405. * @param forceDisposeTextures - Forces the disposal of all textures.
  46406. */
  46407. dispose(forceDisposeTextures?: boolean): void;
  46408. /**
  46409. * Get the current class name of the texture useful for serialization or dynamic coding.
  46410. * @returns "PBRClearCoatConfiguration"
  46411. */
  46412. getClassName(): string;
  46413. /**
  46414. * Add fallbacks to the effect fallbacks list.
  46415. * @param defines defines the Base texture to use.
  46416. * @param fallbacks defines the current fallback list.
  46417. * @param currentRank defines the current fallback rank.
  46418. * @returns the new fallback rank.
  46419. */
  46420. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46421. /**
  46422. * Add the required uniforms to the current list.
  46423. * @param uniforms defines the current uniform list.
  46424. */
  46425. static AddUniforms(uniforms: string[]): void;
  46426. /**
  46427. * Add the required samplers to the current list.
  46428. * @param samplers defines the current sampler list.
  46429. */
  46430. static AddSamplers(samplers: string[]): void;
  46431. /**
  46432. * Add the required uniforms to the current buffer.
  46433. * @param uniformBuffer defines the current uniform buffer.
  46434. */
  46435. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46436. /**
  46437. * Makes a duplicate of the current configuration into another one.
  46438. * @param clearCoatConfiguration define the config where to copy the info
  46439. */
  46440. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46441. /**
  46442. * Serializes this clear coat configuration.
  46443. * @returns - An object with the serialized config.
  46444. */
  46445. serialize(): any;
  46446. /**
  46447. * Parses a Clear Coat Configuration from a serialized object.
  46448. * @param source - Serialized object.
  46449. */
  46450. parse(source: any): void;
  46451. }
  46452. }
  46453. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46454. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46455. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46457. import { Vector2 } from "babylonjs/Maths/math";
  46458. import { Scene } from "babylonjs/scene";
  46459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46460. import { IAnimatable } from "babylonjs/Misc/tools";
  46461. import { Nullable } from "babylonjs/types";
  46462. /**
  46463. * @hidden
  46464. */
  46465. export interface IMaterialAnisotropicDefines {
  46466. ANISOTROPIC: boolean;
  46467. ANISOTROPIC_TEXTURE: boolean;
  46468. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46469. MAINUV1: boolean;
  46470. _areTexturesDirty: boolean;
  46471. _needUVs: boolean;
  46472. }
  46473. /**
  46474. * Define the code related to the anisotropic parameters of the pbr material.
  46475. */
  46476. export class PBRAnisotropicConfiguration {
  46477. private _isEnabled;
  46478. /**
  46479. * Defines if the anisotropy is enabled in the material.
  46480. */
  46481. isEnabled: boolean;
  46482. /**
  46483. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46484. */
  46485. intensity: number;
  46486. /**
  46487. * Defines if the effect is along the tangents, bitangents or in between.
  46488. * By default, the effect is "strectching" the highlights along the tangents.
  46489. */
  46490. direction: Vector2;
  46491. private _texture;
  46492. /**
  46493. * Stores the anisotropy values in a texture.
  46494. * rg is direction (like normal from -1 to 1)
  46495. * b is a intensity
  46496. */
  46497. texture: Nullable<BaseTexture>;
  46498. /** @hidden */
  46499. private _internalMarkAllSubMeshesAsTexturesDirty;
  46500. /** @hidden */
  46501. _markAllSubMeshesAsTexturesDirty(): void;
  46502. /**
  46503. * Instantiate a new istance of anisotropy configuration.
  46504. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46505. */
  46506. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46507. /**
  46508. * Specifies that the submesh is ready to be used.
  46509. * @param defines the list of "defines" to update.
  46510. * @param scene defines the scene the material belongs to.
  46511. * @returns - boolean indicating that the submesh is ready or not.
  46512. */
  46513. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46514. /**
  46515. * Checks to see if a texture is used in the material.
  46516. * @param defines the list of "defines" to update.
  46517. * @param mesh the mesh we are preparing the defines for.
  46518. * @param scene defines the scene the material belongs to.
  46519. */
  46520. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46521. /**
  46522. * Binds the material data.
  46523. * @param uniformBuffer defines the Uniform buffer to fill in.
  46524. * @param scene defines the scene the material belongs to.
  46525. * @param isFrozen defines wether the material is frozen or not.
  46526. */
  46527. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46528. /**
  46529. * Checks to see if a texture is used in the material.
  46530. * @param texture - Base texture to use.
  46531. * @returns - Boolean specifying if a texture is used in the material.
  46532. */
  46533. hasTexture(texture: BaseTexture): boolean;
  46534. /**
  46535. * Returns an array of the actively used textures.
  46536. * @param activeTextures Array of BaseTextures
  46537. */
  46538. getActiveTextures(activeTextures: BaseTexture[]): void;
  46539. /**
  46540. * Returns the animatable textures.
  46541. * @param animatables Array of animatable textures.
  46542. */
  46543. getAnimatables(animatables: IAnimatable[]): void;
  46544. /**
  46545. * Disposes the resources of the material.
  46546. * @param forceDisposeTextures - Forces the disposal of all textures.
  46547. */
  46548. dispose(forceDisposeTextures?: boolean): void;
  46549. /**
  46550. * Get the current class name of the texture useful for serialization or dynamic coding.
  46551. * @returns "PBRAnisotropicConfiguration"
  46552. */
  46553. getClassName(): string;
  46554. /**
  46555. * Add fallbacks to the effect fallbacks list.
  46556. * @param defines defines the Base texture to use.
  46557. * @param fallbacks defines the current fallback list.
  46558. * @param currentRank defines the current fallback rank.
  46559. * @returns the new fallback rank.
  46560. */
  46561. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46562. /**
  46563. * Add the required uniforms to the current list.
  46564. * @param uniforms defines the current uniform list.
  46565. */
  46566. static AddUniforms(uniforms: string[]): void;
  46567. /**
  46568. * Add the required uniforms to the current buffer.
  46569. * @param uniformBuffer defines the current uniform buffer.
  46570. */
  46571. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46572. /**
  46573. * Add the required samplers to the current list.
  46574. * @param samplers defines the current sampler list.
  46575. */
  46576. static AddSamplers(samplers: string[]): void;
  46577. /**
  46578. * Makes a duplicate of the current configuration into another one.
  46579. * @param anisotropicConfiguration define the config where to copy the info
  46580. */
  46581. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46582. /**
  46583. * Serializes this anisotropy configuration.
  46584. * @returns - An object with the serialized config.
  46585. */
  46586. serialize(): any;
  46587. /**
  46588. * Parses a anisotropy Configuration from a serialized object.
  46589. * @param source - Serialized object.
  46590. */
  46591. parse(source: any): void;
  46592. }
  46593. }
  46594. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46595. /**
  46596. * @hidden
  46597. */
  46598. export interface IMaterialBRDFDefines {
  46599. BRDF_V_HEIGHT_CORRELATED: boolean;
  46600. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46601. SPHERICAL_HARMONICS: boolean;
  46602. /** @hidden */
  46603. _areMiscDirty: boolean;
  46604. }
  46605. /**
  46606. * Define the code related to the BRDF parameters of the pbr material.
  46607. */
  46608. export class PBRBRDFConfiguration {
  46609. /**
  46610. * Default value used for the energy conservation.
  46611. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46612. */
  46613. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46614. /**
  46615. * Default value used for the Smith Visibility Height Correlated mode.
  46616. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46617. */
  46618. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46619. /**
  46620. * Default value used for the IBL diffuse part.
  46621. * This can help switching back to the polynomials mode globally which is a tiny bit
  46622. * less GPU intensive at the drawback of a lower quality.
  46623. */
  46624. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46625. private _useEnergyConservation;
  46626. /**
  46627. * Defines if the material uses energy conservation.
  46628. */
  46629. useEnergyConservation: boolean;
  46630. private _useSmithVisibilityHeightCorrelated;
  46631. /**
  46632. * LEGACY Mode set to false
  46633. * Defines if the material uses height smith correlated visibility term.
  46634. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46635. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46636. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46637. * Not relying on height correlated will also disable energy conservation.
  46638. */
  46639. useSmithVisibilityHeightCorrelated: boolean;
  46640. private _useSphericalHarmonics;
  46641. /**
  46642. * LEGACY Mode set to false
  46643. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46644. * diffuse part of the IBL.
  46645. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46646. * to the ground truth.
  46647. */
  46648. useSphericalHarmonics: boolean;
  46649. /** @hidden */
  46650. private _internalMarkAllSubMeshesAsMiscDirty;
  46651. /** @hidden */
  46652. _markAllSubMeshesAsMiscDirty(): void;
  46653. /**
  46654. * Instantiate a new istance of clear coat configuration.
  46655. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46656. */
  46657. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46658. /**
  46659. * Checks to see if a texture is used in the material.
  46660. * @param defines the list of "defines" to update.
  46661. */
  46662. prepareDefines(defines: IMaterialBRDFDefines): void;
  46663. /**
  46664. * Get the current class name of the texture useful for serialization or dynamic coding.
  46665. * @returns "PBRClearCoatConfiguration"
  46666. */
  46667. getClassName(): string;
  46668. /**
  46669. * Makes a duplicate of the current configuration into another one.
  46670. * @param brdfConfiguration define the config where to copy the info
  46671. */
  46672. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46673. /**
  46674. * Serializes this BRDF configuration.
  46675. * @returns - An object with the serialized config.
  46676. */
  46677. serialize(): any;
  46678. /**
  46679. * Parses a BRDF Configuration from a serialized object.
  46680. * @param source - Serialized object.
  46681. */
  46682. parse(source: any): void;
  46683. }
  46684. }
  46685. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46686. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46687. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46688. import { Color3 } from "babylonjs/Maths/math";
  46689. import { Scene } from "babylonjs/scene";
  46690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46691. import { IAnimatable } from "babylonjs/Misc/tools";
  46692. import { Nullable } from "babylonjs/types";
  46693. /**
  46694. * @hidden
  46695. */
  46696. export interface IMaterialSheenDefines {
  46697. SHEEN: boolean;
  46698. SHEEN_TEXTURE: boolean;
  46699. SHEEN_TEXTUREDIRECTUV: number;
  46700. SHEEN_LINKWITHALBEDO: boolean;
  46701. /** @hidden */
  46702. _areTexturesDirty: boolean;
  46703. }
  46704. /**
  46705. * Define the code related to the Sheen parameters of the pbr material.
  46706. */
  46707. export class PBRSheenConfiguration {
  46708. private _isEnabled;
  46709. /**
  46710. * Defines if the material uses sheen.
  46711. */
  46712. isEnabled: boolean;
  46713. private _linkSheenWithAlbedo;
  46714. /**
  46715. * Defines if the sheen is linked to the sheen color.
  46716. */
  46717. linkSheenWithAlbedo: boolean;
  46718. /**
  46719. * Defines the sheen intensity.
  46720. */
  46721. intensity: number;
  46722. /**
  46723. * Defines the sheen color.
  46724. */
  46725. color: Color3;
  46726. private _texture;
  46727. /**
  46728. * Stores the sheen tint values in a texture.
  46729. * rgb is tint
  46730. * a is a intensity
  46731. */
  46732. texture: Nullable<BaseTexture>;
  46733. /** @hidden */
  46734. private _internalMarkAllSubMeshesAsTexturesDirty;
  46735. /** @hidden */
  46736. _markAllSubMeshesAsTexturesDirty(): void;
  46737. /**
  46738. * Instantiate a new istance of clear coat configuration.
  46739. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46740. */
  46741. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46742. /**
  46743. * Specifies that the submesh is ready to be used.
  46744. * @param defines the list of "defines" to update.
  46745. * @param scene defines the scene the material belongs to.
  46746. * @returns - boolean indicating that the submesh is ready or not.
  46747. */
  46748. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46749. /**
  46750. * Checks to see if a texture is used in the material.
  46751. * @param defines the list of "defines" to update.
  46752. * @param scene defines the scene the material belongs to.
  46753. */
  46754. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46755. /**
  46756. * Binds the material data.
  46757. * @param uniformBuffer defines the Uniform buffer to fill in.
  46758. * @param scene defines the scene the material belongs to.
  46759. * @param isFrozen defines wether the material is frozen or not.
  46760. */
  46761. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46762. /**
  46763. * Checks to see if a texture is used in the material.
  46764. * @param texture - Base texture to use.
  46765. * @returns - Boolean specifying if a texture is used in the material.
  46766. */
  46767. hasTexture(texture: BaseTexture): boolean;
  46768. /**
  46769. * Returns an array of the actively used textures.
  46770. * @param activeTextures Array of BaseTextures
  46771. */
  46772. getActiveTextures(activeTextures: BaseTexture[]): void;
  46773. /**
  46774. * Returns the animatable textures.
  46775. * @param animatables Array of animatable textures.
  46776. */
  46777. getAnimatables(animatables: IAnimatable[]): void;
  46778. /**
  46779. * Disposes the resources of the material.
  46780. * @param forceDisposeTextures - Forces the disposal of all textures.
  46781. */
  46782. dispose(forceDisposeTextures?: boolean): void;
  46783. /**
  46784. * Get the current class name of the texture useful for serialization or dynamic coding.
  46785. * @returns "PBRSheenConfiguration"
  46786. */
  46787. getClassName(): string;
  46788. /**
  46789. * Add fallbacks to the effect fallbacks list.
  46790. * @param defines defines the Base texture to use.
  46791. * @param fallbacks defines the current fallback list.
  46792. * @param currentRank defines the current fallback rank.
  46793. * @returns the new fallback rank.
  46794. */
  46795. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46796. /**
  46797. * Add the required uniforms to the current list.
  46798. * @param uniforms defines the current uniform list.
  46799. */
  46800. static AddUniforms(uniforms: string[]): void;
  46801. /**
  46802. * Add the required uniforms to the current buffer.
  46803. * @param uniformBuffer defines the current uniform buffer.
  46804. */
  46805. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46806. /**
  46807. * Add the required samplers to the current list.
  46808. * @param samplers defines the current sampler list.
  46809. */
  46810. static AddSamplers(samplers: string[]): void;
  46811. /**
  46812. * Makes a duplicate of the current configuration into another one.
  46813. * @param sheenConfiguration define the config where to copy the info
  46814. */
  46815. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46816. /**
  46817. * Serializes this BRDF configuration.
  46818. * @returns - An object with the serialized config.
  46819. */
  46820. serialize(): any;
  46821. /**
  46822. * Parses a Sheen Configuration from a serialized object.
  46823. * @param source - Serialized object.
  46824. */
  46825. parse(source: any): void;
  46826. }
  46827. }
  46828. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46829. import { Nullable } from "babylonjs/types";
  46830. import { IAnimatable } from "babylonjs/Misc/tools";
  46831. import { Color3 } from "babylonjs/Maths/math";
  46832. import { SmartArray } from "babylonjs/Misc/smartArray";
  46833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46834. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46835. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46836. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46837. import { Engine } from "babylonjs/Engines/engine";
  46838. import { Scene } from "babylonjs/scene";
  46839. /**
  46840. * @hidden
  46841. */
  46842. export interface IMaterialSubSurfaceDefines {
  46843. SUBSURFACE: boolean;
  46844. SS_REFRACTION: boolean;
  46845. SS_TRANSLUCENCY: boolean;
  46846. SS_SCATERRING: boolean;
  46847. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46848. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46849. SS_REFRACTIONMAP_3D: boolean;
  46850. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46851. SS_LODINREFRACTIONALPHA: boolean;
  46852. SS_GAMMAREFRACTION: boolean;
  46853. SS_RGBDREFRACTION: boolean;
  46854. SS_LINEARSPECULARREFRACTION: boolean;
  46855. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46856. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46857. /** @hidden */
  46858. _areTexturesDirty: boolean;
  46859. }
  46860. /**
  46861. * Define the code related to the sub surface parameters of the pbr material.
  46862. */
  46863. export class PBRSubSurfaceConfiguration {
  46864. private _isRefractionEnabled;
  46865. /**
  46866. * Defines if the refraction is enabled in the material.
  46867. */
  46868. isRefractionEnabled: boolean;
  46869. private _isTranslucencyEnabled;
  46870. /**
  46871. * Defines if the translucency is enabled in the material.
  46872. */
  46873. isTranslucencyEnabled: boolean;
  46874. private _isScatteringEnabled;
  46875. /**
  46876. * Defines the refraction intensity of the material.
  46877. * The refraction when enabled replaces the Diffuse part of the material.
  46878. * The intensity helps transitionning between diffuse and refraction.
  46879. */
  46880. refractionIntensity: number;
  46881. /**
  46882. * Defines the translucency intensity of the material.
  46883. * When translucency has been enabled, this defines how much of the "translucency"
  46884. * is addded to the diffuse part of the material.
  46885. */
  46886. translucencyIntensity: number;
  46887. /**
  46888. * Defines the scattering intensity of the material.
  46889. * When scattering has been enabled, this defines how much of the "scattered light"
  46890. * is addded to the diffuse part of the material.
  46891. */
  46892. scatteringIntensity: number;
  46893. private _thicknessTexture;
  46894. /**
  46895. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46896. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46897. * 0 would mean minimumThickness
  46898. * 1 would mean maximumThickness
  46899. * The other channels might be use as a mask to vary the different effects intensity.
  46900. */
  46901. thicknessTexture: Nullable<BaseTexture>;
  46902. private _refractionTexture;
  46903. /**
  46904. * Defines the texture to use for refraction.
  46905. */
  46906. refractionTexture: Nullable<BaseTexture>;
  46907. private _indexOfRefraction;
  46908. /**
  46909. * Defines the index of refraction used in the material.
  46910. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46911. */
  46912. indexOfRefraction: number;
  46913. private _invertRefractionY;
  46914. /**
  46915. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46916. */
  46917. invertRefractionY: boolean;
  46918. private _linkRefractionWithTransparency;
  46919. /**
  46920. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46921. * Materials half opaque for instance using refraction could benefit from this control.
  46922. */
  46923. linkRefractionWithTransparency: boolean;
  46924. /**
  46925. * Defines the minimum thickness stored in the thickness map.
  46926. * If no thickness map is defined, this value will be used to simulate thickness.
  46927. */
  46928. minimumThickness: number;
  46929. /**
  46930. * Defines the maximum thickness stored in the thickness map.
  46931. */
  46932. maximumThickness: number;
  46933. /**
  46934. * Defines the volume tint of the material.
  46935. * This is used for both translucency and scattering.
  46936. */
  46937. tintColor: Color3;
  46938. /**
  46939. * Defines the distance at which the tint color should be found in the media.
  46940. * This is used for refraction only.
  46941. */
  46942. tintColorAtDistance: number;
  46943. /**
  46944. * Defines how far each channel transmit through the media.
  46945. * It is defined as a color to simplify it selection.
  46946. */
  46947. diffusionDistance: Color3;
  46948. private _useMaskFromThicknessTexture;
  46949. /**
  46950. * Stores the intensity of the different subsurface effects in the thickness texture.
  46951. * * the green channel is the translucency intensity.
  46952. * * the blue channel is the scattering intensity.
  46953. * * the alpha channel is the refraction intensity.
  46954. */
  46955. useMaskFromThicknessTexture: boolean;
  46956. /** @hidden */
  46957. private _internalMarkAllSubMeshesAsTexturesDirty;
  46958. /** @hidden */
  46959. _markAllSubMeshesAsTexturesDirty(): void;
  46960. /**
  46961. * Instantiate a new istance of sub surface configuration.
  46962. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46963. */
  46964. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46965. /**
  46966. * Gets wehter the submesh is ready to be used or not.
  46967. * @param defines the list of "defines" to update.
  46968. * @param scene defines the scene the material belongs to.
  46969. * @returns - boolean indicating that the submesh is ready or not.
  46970. */
  46971. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46972. /**
  46973. * Checks to see if a texture is used in the material.
  46974. * @param defines the list of "defines" to update.
  46975. * @param scene defines the scene to the material belongs to.
  46976. */
  46977. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46978. /**
  46979. * Binds the material data.
  46980. * @param uniformBuffer defines the Uniform buffer to fill in.
  46981. * @param scene defines the scene the material belongs to.
  46982. * @param engine defines the engine the material belongs to.
  46983. * @param isFrozen defines wether the material is frozen or not.
  46984. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46985. */
  46986. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46987. /**
  46988. * Unbinds the material from the mesh.
  46989. * @param activeEffect defines the effect that should be unbound from.
  46990. * @returns true if unbound, otherwise false
  46991. */
  46992. unbind(activeEffect: Effect): boolean;
  46993. /**
  46994. * Returns the texture used for refraction or null if none is used.
  46995. * @param scene defines the scene the material belongs to.
  46996. * @returns - Refraction texture if present. If no refraction texture and refraction
  46997. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46998. */
  46999. private _getRefractionTexture;
  47000. /**
  47001. * Returns true if alpha blending should be disabled.
  47002. */
  47003. readonly disableAlphaBlending: boolean;
  47004. /**
  47005. * Fills the list of render target textures.
  47006. * @param renderTargets the list of render targets to update
  47007. */
  47008. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47009. /**
  47010. * Checks to see if a texture is used in the material.
  47011. * @param texture - Base texture to use.
  47012. * @returns - Boolean specifying if a texture is used in the material.
  47013. */
  47014. hasTexture(texture: BaseTexture): boolean;
  47015. /**
  47016. * Gets a boolean indicating that current material needs to register RTT
  47017. * @returns true if this uses a render target otherwise false.
  47018. */
  47019. hasRenderTargetTextures(): boolean;
  47020. /**
  47021. * Returns an array of the actively used textures.
  47022. * @param activeTextures Array of BaseTextures
  47023. */
  47024. getActiveTextures(activeTextures: BaseTexture[]): void;
  47025. /**
  47026. * Returns the animatable textures.
  47027. * @param animatables Array of animatable textures.
  47028. */
  47029. getAnimatables(animatables: IAnimatable[]): void;
  47030. /**
  47031. * Disposes the resources of the material.
  47032. * @param forceDisposeTextures - Forces the disposal of all textures.
  47033. */
  47034. dispose(forceDisposeTextures?: boolean): void;
  47035. /**
  47036. * Get the current class name of the texture useful for serialization or dynamic coding.
  47037. * @returns "PBRSubSurfaceConfiguration"
  47038. */
  47039. getClassName(): string;
  47040. /**
  47041. * Add fallbacks to the effect fallbacks list.
  47042. * @param defines defines the Base texture to use.
  47043. * @param fallbacks defines the current fallback list.
  47044. * @param currentRank defines the current fallback rank.
  47045. * @returns the new fallback rank.
  47046. */
  47047. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47048. /**
  47049. * Add the required uniforms to the current list.
  47050. * @param uniforms defines the current uniform list.
  47051. */
  47052. static AddUniforms(uniforms: string[]): void;
  47053. /**
  47054. * Add the required samplers to the current list.
  47055. * @param samplers defines the current sampler list.
  47056. */
  47057. static AddSamplers(samplers: string[]): void;
  47058. /**
  47059. * Add the required uniforms to the current buffer.
  47060. * @param uniformBuffer defines the current uniform buffer.
  47061. */
  47062. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47063. /**
  47064. * Makes a duplicate of the current configuration into another one.
  47065. * @param configuration define the config where to copy the info
  47066. */
  47067. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47068. /**
  47069. * Serializes this Sub Surface configuration.
  47070. * @returns - An object with the serialized config.
  47071. */
  47072. serialize(): any;
  47073. /**
  47074. * Parses a Sub Surface Configuration from a serialized object.
  47075. * @param source - Serialized object.
  47076. */
  47077. parse(source: any): void;
  47078. }
  47079. }
  47080. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47081. /** @hidden */
  47082. export var pbrFragmentDeclaration: {
  47083. name: string;
  47084. shader: string;
  47085. };
  47086. }
  47087. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47088. /** @hidden */
  47089. export var pbrUboDeclaration: {
  47090. name: string;
  47091. shader: string;
  47092. };
  47093. }
  47094. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47095. /** @hidden */
  47096. export var pbrFragmentExtraDeclaration: {
  47097. name: string;
  47098. shader: string;
  47099. };
  47100. }
  47101. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47102. /** @hidden */
  47103. export var pbrFragmentSamplersDeclaration: {
  47104. name: string;
  47105. shader: string;
  47106. };
  47107. }
  47108. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47109. /** @hidden */
  47110. export var pbrHelperFunctions: {
  47111. name: string;
  47112. shader: string;
  47113. };
  47114. }
  47115. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47116. /** @hidden */
  47117. export var harmonicsFunctions: {
  47118. name: string;
  47119. shader: string;
  47120. };
  47121. }
  47122. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47123. /** @hidden */
  47124. export var pbrDirectLightingSetupFunctions: {
  47125. name: string;
  47126. shader: string;
  47127. };
  47128. }
  47129. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47130. /** @hidden */
  47131. export var pbrDirectLightingFalloffFunctions: {
  47132. name: string;
  47133. shader: string;
  47134. };
  47135. }
  47136. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47137. /** @hidden */
  47138. export var pbrBRDFFunctions: {
  47139. name: string;
  47140. shader: string;
  47141. };
  47142. }
  47143. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47144. /** @hidden */
  47145. export var pbrDirectLightingFunctions: {
  47146. name: string;
  47147. shader: string;
  47148. };
  47149. }
  47150. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47151. /** @hidden */
  47152. export var pbrIBLFunctions: {
  47153. name: string;
  47154. shader: string;
  47155. };
  47156. }
  47157. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47158. /** @hidden */
  47159. export var pbrDebug: {
  47160. name: string;
  47161. shader: string;
  47162. };
  47163. }
  47164. declare module "babylonjs/Shaders/pbr.fragment" {
  47165. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47166. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47167. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47168. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47169. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47170. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47171. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47172. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47173. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47174. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47175. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47176. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47177. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47178. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47179. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47180. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47181. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47182. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47183. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47184. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47185. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47186. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47188. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47189. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47190. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47191. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47192. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47193. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47194. /** @hidden */
  47195. export var pbrPixelShader: {
  47196. name: string;
  47197. shader: string;
  47198. };
  47199. }
  47200. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47201. /** @hidden */
  47202. export var pbrVertexDeclaration: {
  47203. name: string;
  47204. shader: string;
  47205. };
  47206. }
  47207. declare module "babylonjs/Shaders/pbr.vertex" {
  47208. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47209. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47210. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47211. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47212. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47213. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47214. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47215. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47216. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47217. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47218. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47220. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47221. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47225. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47226. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47227. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47228. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47229. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47230. /** @hidden */
  47231. export var pbrVertexShader: {
  47232. name: string;
  47233. shader: string;
  47234. };
  47235. }
  47236. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47237. import { IAnimatable } from "babylonjs/Misc/tools";
  47238. import { Nullable } from "babylonjs/types";
  47239. import { Scene } from "babylonjs/scene";
  47240. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47241. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47243. import { Mesh } from "babylonjs/Meshes/mesh";
  47244. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47245. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47246. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47247. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47248. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47249. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47250. import { Material } from "babylonjs/Materials/material";
  47251. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47252. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47253. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47254. import "babylonjs/Shaders/pbr.fragment";
  47255. import "babylonjs/Shaders/pbr.vertex";
  47256. /**
  47257. * Manages the defines for the PBR Material.
  47258. * @hidden
  47259. */
  47260. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47261. PBR: boolean;
  47262. MAINUV1: boolean;
  47263. MAINUV2: boolean;
  47264. UV1: boolean;
  47265. UV2: boolean;
  47266. ALBEDO: boolean;
  47267. ALBEDODIRECTUV: number;
  47268. VERTEXCOLOR: boolean;
  47269. AMBIENT: boolean;
  47270. AMBIENTDIRECTUV: number;
  47271. AMBIENTINGRAYSCALE: boolean;
  47272. OPACITY: boolean;
  47273. VERTEXALPHA: boolean;
  47274. OPACITYDIRECTUV: number;
  47275. OPACITYRGB: boolean;
  47276. ALPHATEST: boolean;
  47277. DEPTHPREPASS: boolean;
  47278. ALPHABLEND: boolean;
  47279. ALPHAFROMALBEDO: boolean;
  47280. ALPHATESTVALUE: string;
  47281. SPECULAROVERALPHA: boolean;
  47282. RADIANCEOVERALPHA: boolean;
  47283. ALPHAFRESNEL: boolean;
  47284. LINEARALPHAFRESNEL: boolean;
  47285. PREMULTIPLYALPHA: boolean;
  47286. EMISSIVE: boolean;
  47287. EMISSIVEDIRECTUV: number;
  47288. REFLECTIVITY: boolean;
  47289. REFLECTIVITYDIRECTUV: number;
  47290. SPECULARTERM: boolean;
  47291. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47292. MICROSURFACEAUTOMATIC: boolean;
  47293. LODBASEDMICROSFURACE: boolean;
  47294. MICROSURFACEMAP: boolean;
  47295. MICROSURFACEMAPDIRECTUV: number;
  47296. METALLICWORKFLOW: boolean;
  47297. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47298. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47299. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47300. AOSTOREINMETALMAPRED: boolean;
  47301. ENVIRONMENTBRDF: boolean;
  47302. ENVIRONMENTBRDF_RGBD: boolean;
  47303. NORMAL: boolean;
  47304. TANGENT: boolean;
  47305. BUMP: boolean;
  47306. BUMPDIRECTUV: number;
  47307. OBJECTSPACE_NORMALMAP: boolean;
  47308. PARALLAX: boolean;
  47309. PARALLAXOCCLUSION: boolean;
  47310. NORMALXYSCALE: boolean;
  47311. LIGHTMAP: boolean;
  47312. LIGHTMAPDIRECTUV: number;
  47313. USELIGHTMAPASSHADOWMAP: boolean;
  47314. GAMMALIGHTMAP: boolean;
  47315. REFLECTION: boolean;
  47316. REFLECTIONMAP_3D: boolean;
  47317. REFLECTIONMAP_SPHERICAL: boolean;
  47318. REFLECTIONMAP_PLANAR: boolean;
  47319. REFLECTIONMAP_CUBIC: boolean;
  47320. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47321. REFLECTIONMAP_PROJECTION: boolean;
  47322. REFLECTIONMAP_SKYBOX: boolean;
  47323. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47324. REFLECTIONMAP_EXPLICIT: boolean;
  47325. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47326. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47327. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47328. INVERTCUBICMAP: boolean;
  47329. USESPHERICALFROMREFLECTIONMAP: boolean;
  47330. USEIRRADIANCEMAP: boolean;
  47331. SPHERICAL_HARMONICS: boolean;
  47332. USESPHERICALINVERTEX: boolean;
  47333. REFLECTIONMAP_OPPOSITEZ: boolean;
  47334. LODINREFLECTIONALPHA: boolean;
  47335. GAMMAREFLECTION: boolean;
  47336. RGBDREFLECTION: boolean;
  47337. LINEARSPECULARREFLECTION: boolean;
  47338. RADIANCEOCCLUSION: boolean;
  47339. HORIZONOCCLUSION: boolean;
  47340. INSTANCES: boolean;
  47341. NUM_BONE_INFLUENCERS: number;
  47342. BonesPerMesh: number;
  47343. BONETEXTURE: boolean;
  47344. NONUNIFORMSCALING: boolean;
  47345. MORPHTARGETS: boolean;
  47346. MORPHTARGETS_NORMAL: boolean;
  47347. MORPHTARGETS_TANGENT: boolean;
  47348. NUM_MORPH_INFLUENCERS: number;
  47349. IMAGEPROCESSING: boolean;
  47350. VIGNETTE: boolean;
  47351. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47352. VIGNETTEBLENDMODEOPAQUE: boolean;
  47353. TONEMAPPING: boolean;
  47354. TONEMAPPING_ACES: boolean;
  47355. CONTRAST: boolean;
  47356. COLORCURVES: boolean;
  47357. COLORGRADING: boolean;
  47358. COLORGRADING3D: boolean;
  47359. SAMPLER3DGREENDEPTH: boolean;
  47360. SAMPLER3DBGRMAP: boolean;
  47361. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47362. EXPOSURE: boolean;
  47363. MULTIVIEW: boolean;
  47364. USEPHYSICALLIGHTFALLOFF: boolean;
  47365. USEGLTFLIGHTFALLOFF: boolean;
  47366. TWOSIDEDLIGHTING: boolean;
  47367. SHADOWFLOAT: boolean;
  47368. CLIPPLANE: boolean;
  47369. CLIPPLANE2: boolean;
  47370. CLIPPLANE3: boolean;
  47371. CLIPPLANE4: boolean;
  47372. POINTSIZE: boolean;
  47373. FOG: boolean;
  47374. LOGARITHMICDEPTH: boolean;
  47375. FORCENORMALFORWARD: boolean;
  47376. SPECULARAA: boolean;
  47377. CLEARCOAT: boolean;
  47378. CLEARCOAT_DEFAULTIOR: boolean;
  47379. CLEARCOAT_TEXTURE: boolean;
  47380. CLEARCOAT_TEXTUREDIRECTUV: number;
  47381. CLEARCOAT_BUMP: boolean;
  47382. CLEARCOAT_BUMPDIRECTUV: number;
  47383. CLEARCOAT_TINT: boolean;
  47384. CLEARCOAT_TINT_TEXTURE: boolean;
  47385. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47386. ANISOTROPIC: boolean;
  47387. ANISOTROPIC_TEXTURE: boolean;
  47388. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47389. BRDF_V_HEIGHT_CORRELATED: boolean;
  47390. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47391. SHEEN: boolean;
  47392. SHEEN_TEXTURE: boolean;
  47393. SHEEN_TEXTUREDIRECTUV: number;
  47394. SHEEN_LINKWITHALBEDO: boolean;
  47395. SUBSURFACE: boolean;
  47396. SS_REFRACTION: boolean;
  47397. SS_TRANSLUCENCY: boolean;
  47398. SS_SCATERRING: boolean;
  47399. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47400. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47401. SS_REFRACTIONMAP_3D: boolean;
  47402. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47403. SS_LODINREFRACTIONALPHA: boolean;
  47404. SS_GAMMAREFRACTION: boolean;
  47405. SS_RGBDREFRACTION: boolean;
  47406. SS_LINEARSPECULARREFRACTION: boolean;
  47407. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47408. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47409. UNLIT: boolean;
  47410. DEBUGMODE: number;
  47411. /**
  47412. * Initializes the PBR Material defines.
  47413. */
  47414. constructor();
  47415. /**
  47416. * Resets the PBR Material defines.
  47417. */
  47418. reset(): void;
  47419. }
  47420. /**
  47421. * The Physically based material base class of BJS.
  47422. *
  47423. * This offers the main features of a standard PBR material.
  47424. * For more information, please refer to the documentation :
  47425. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47426. */
  47427. export abstract class PBRBaseMaterial extends PushMaterial {
  47428. /**
  47429. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47430. */
  47431. static readonly PBRMATERIAL_OPAQUE: number;
  47432. /**
  47433. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47434. */
  47435. static readonly PBRMATERIAL_ALPHATEST: number;
  47436. /**
  47437. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47438. */
  47439. static readonly PBRMATERIAL_ALPHABLEND: number;
  47440. /**
  47441. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47442. * They are also discarded below the alpha cutoff threshold to improve performances.
  47443. */
  47444. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47445. /**
  47446. * Defines the default value of how much AO map is occluding the analytical lights
  47447. * (point spot...).
  47448. */
  47449. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47450. /**
  47451. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47452. */
  47453. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47454. /**
  47455. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47456. * to enhance interoperability with other engines.
  47457. */
  47458. static readonly LIGHTFALLOFF_GLTF: number;
  47459. /**
  47460. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47461. * to enhance interoperability with other materials.
  47462. */
  47463. static readonly LIGHTFALLOFF_STANDARD: number;
  47464. /**
  47465. * Intensity of the direct lights e.g. the four lights available in your scene.
  47466. * This impacts both the direct diffuse and specular highlights.
  47467. */
  47468. protected _directIntensity: number;
  47469. /**
  47470. * Intensity of the emissive part of the material.
  47471. * This helps controlling the emissive effect without modifying the emissive color.
  47472. */
  47473. protected _emissiveIntensity: number;
  47474. /**
  47475. * Intensity of the environment e.g. how much the environment will light the object
  47476. * either through harmonics for rough material or through the refelction for shiny ones.
  47477. */
  47478. protected _environmentIntensity: number;
  47479. /**
  47480. * This is a special control allowing the reduction of the specular highlights coming from the
  47481. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47482. */
  47483. protected _specularIntensity: number;
  47484. /**
  47485. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47486. */
  47487. private _lightingInfos;
  47488. /**
  47489. * Debug Control allowing disabling the bump map on this material.
  47490. */
  47491. protected _disableBumpMap: boolean;
  47492. /**
  47493. * AKA Diffuse Texture in standard nomenclature.
  47494. */
  47495. protected _albedoTexture: Nullable<BaseTexture>;
  47496. /**
  47497. * AKA Occlusion Texture in other nomenclature.
  47498. */
  47499. protected _ambientTexture: Nullable<BaseTexture>;
  47500. /**
  47501. * AKA Occlusion Texture Intensity in other nomenclature.
  47502. */
  47503. protected _ambientTextureStrength: number;
  47504. /**
  47505. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47506. * 1 means it completely occludes it
  47507. * 0 mean it has no impact
  47508. */
  47509. protected _ambientTextureImpactOnAnalyticalLights: number;
  47510. /**
  47511. * Stores the alpha values in a texture.
  47512. */
  47513. protected _opacityTexture: Nullable<BaseTexture>;
  47514. /**
  47515. * Stores the reflection values in a texture.
  47516. */
  47517. protected _reflectionTexture: Nullable<BaseTexture>;
  47518. /**
  47519. * Stores the emissive values in a texture.
  47520. */
  47521. protected _emissiveTexture: Nullable<BaseTexture>;
  47522. /**
  47523. * AKA Specular texture in other nomenclature.
  47524. */
  47525. protected _reflectivityTexture: Nullable<BaseTexture>;
  47526. /**
  47527. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47528. */
  47529. protected _metallicTexture: Nullable<BaseTexture>;
  47530. /**
  47531. * Specifies the metallic scalar of the metallic/roughness workflow.
  47532. * Can also be used to scale the metalness values of the metallic texture.
  47533. */
  47534. protected _metallic: Nullable<number>;
  47535. /**
  47536. * Specifies the roughness scalar of the metallic/roughness workflow.
  47537. * Can also be used to scale the roughness values of the metallic texture.
  47538. */
  47539. protected _roughness: Nullable<number>;
  47540. /**
  47541. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47542. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47543. */
  47544. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47545. /**
  47546. * Stores surface normal data used to displace a mesh in a texture.
  47547. */
  47548. protected _bumpTexture: Nullable<BaseTexture>;
  47549. /**
  47550. * Stores the pre-calculated light information of a mesh in a texture.
  47551. */
  47552. protected _lightmapTexture: Nullable<BaseTexture>;
  47553. /**
  47554. * The color of a material in ambient lighting.
  47555. */
  47556. protected _ambientColor: Color3;
  47557. /**
  47558. * AKA Diffuse Color in other nomenclature.
  47559. */
  47560. protected _albedoColor: Color3;
  47561. /**
  47562. * AKA Specular Color in other nomenclature.
  47563. */
  47564. protected _reflectivityColor: Color3;
  47565. /**
  47566. * The color applied when light is reflected from a material.
  47567. */
  47568. protected _reflectionColor: Color3;
  47569. /**
  47570. * The color applied when light is emitted from a material.
  47571. */
  47572. protected _emissiveColor: Color3;
  47573. /**
  47574. * AKA Glossiness in other nomenclature.
  47575. */
  47576. protected _microSurface: number;
  47577. /**
  47578. * Specifies that the material will use the light map as a show map.
  47579. */
  47580. protected _useLightmapAsShadowmap: boolean;
  47581. /**
  47582. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47583. * makes the reflect vector face the model (under horizon).
  47584. */
  47585. protected _useHorizonOcclusion: boolean;
  47586. /**
  47587. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47588. * too much the area relying on ambient texture to define their ambient occlusion.
  47589. */
  47590. protected _useRadianceOcclusion: boolean;
  47591. /**
  47592. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47593. */
  47594. protected _useAlphaFromAlbedoTexture: boolean;
  47595. /**
  47596. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47597. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47598. */
  47599. protected _useSpecularOverAlpha: boolean;
  47600. /**
  47601. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47602. */
  47603. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47604. /**
  47605. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47606. */
  47607. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47608. /**
  47609. * Specifies if the metallic texture contains the roughness information in its green channel.
  47610. */
  47611. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47612. /**
  47613. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47614. */
  47615. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47616. /**
  47617. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47618. */
  47619. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47620. /**
  47621. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47622. */
  47623. protected _useAmbientInGrayScale: boolean;
  47624. /**
  47625. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47626. * The material will try to infer what glossiness each pixel should be.
  47627. */
  47628. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47629. /**
  47630. * Defines the falloff type used in this material.
  47631. * It by default is Physical.
  47632. */
  47633. protected _lightFalloff: number;
  47634. /**
  47635. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47636. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47637. */
  47638. protected _useRadianceOverAlpha: boolean;
  47639. /**
  47640. * Allows using an object space normal map (instead of tangent space).
  47641. */
  47642. protected _useObjectSpaceNormalMap: boolean;
  47643. /**
  47644. * Allows using the bump map in parallax mode.
  47645. */
  47646. protected _useParallax: boolean;
  47647. /**
  47648. * Allows using the bump map in parallax occlusion mode.
  47649. */
  47650. protected _useParallaxOcclusion: boolean;
  47651. /**
  47652. * Controls the scale bias of the parallax mode.
  47653. */
  47654. protected _parallaxScaleBias: number;
  47655. /**
  47656. * If sets to true, disables all the lights affecting the material.
  47657. */
  47658. protected _disableLighting: boolean;
  47659. /**
  47660. * Number of Simultaneous lights allowed on the material.
  47661. */
  47662. protected _maxSimultaneousLights: number;
  47663. /**
  47664. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47665. */
  47666. protected _invertNormalMapX: boolean;
  47667. /**
  47668. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47669. */
  47670. protected _invertNormalMapY: boolean;
  47671. /**
  47672. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47673. */
  47674. protected _twoSidedLighting: boolean;
  47675. /**
  47676. * Defines the alpha limits in alpha test mode.
  47677. */
  47678. protected _alphaCutOff: number;
  47679. /**
  47680. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47681. */
  47682. protected _forceAlphaTest: boolean;
  47683. /**
  47684. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47685. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47686. */
  47687. protected _useAlphaFresnel: boolean;
  47688. /**
  47689. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47690. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47691. */
  47692. protected _useLinearAlphaFresnel: boolean;
  47693. /**
  47694. * The transparency mode of the material.
  47695. */
  47696. protected _transparencyMode: Nullable<number>;
  47697. /**
  47698. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47699. * from cos thetav and roughness:
  47700. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47701. */
  47702. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47703. /**
  47704. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47705. */
  47706. protected _forceIrradianceInFragment: boolean;
  47707. /**
  47708. * Force normal to face away from face.
  47709. */
  47710. protected _forceNormalForward: boolean;
  47711. /**
  47712. * Enables specular anti aliasing in the PBR shader.
  47713. * It will both interacts on the Geometry for analytical and IBL lighting.
  47714. * It also prefilter the roughness map based on the bump values.
  47715. */
  47716. protected _enableSpecularAntiAliasing: boolean;
  47717. /**
  47718. * Default configuration related to image processing available in the PBR Material.
  47719. */
  47720. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47721. /**
  47722. * Keep track of the image processing observer to allow dispose and replace.
  47723. */
  47724. private _imageProcessingObserver;
  47725. /**
  47726. * Attaches a new image processing configuration to the PBR Material.
  47727. * @param configuration
  47728. */
  47729. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47730. /**
  47731. * Stores the available render targets.
  47732. */
  47733. private _renderTargets;
  47734. /**
  47735. * Sets the global ambient color for the material used in lighting calculations.
  47736. */
  47737. private _globalAmbientColor;
  47738. /**
  47739. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47740. */
  47741. private _useLogarithmicDepth;
  47742. /**
  47743. * If set to true, no lighting calculations will be applied.
  47744. */
  47745. private _unlit;
  47746. private _debugMode;
  47747. /**
  47748. * @hidden
  47749. * This is reserved for the inspector.
  47750. * Defines the material debug mode.
  47751. * It helps seeing only some components of the material while troubleshooting.
  47752. */
  47753. debugMode: number;
  47754. /**
  47755. * @hidden
  47756. * This is reserved for the inspector.
  47757. * Specify from where on screen the debug mode should start.
  47758. * The value goes from -1 (full screen) to 1 (not visible)
  47759. * It helps with side by side comparison against the final render
  47760. * This defaults to -1
  47761. */
  47762. private debugLimit;
  47763. /**
  47764. * @hidden
  47765. * This is reserved for the inspector.
  47766. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47767. * You can use the factor to better multiply the final value.
  47768. */
  47769. private debugFactor;
  47770. /**
  47771. * Defines the clear coat layer parameters for the material.
  47772. */
  47773. readonly clearCoat: PBRClearCoatConfiguration;
  47774. /**
  47775. * Defines the anisotropic parameters for the material.
  47776. */
  47777. readonly anisotropy: PBRAnisotropicConfiguration;
  47778. /**
  47779. * Defines the BRDF parameters for the material.
  47780. */
  47781. readonly brdf: PBRBRDFConfiguration;
  47782. /**
  47783. * Defines the Sheen parameters for the material.
  47784. */
  47785. readonly sheen: PBRSheenConfiguration;
  47786. /**
  47787. * Defines the SubSurface parameters for the material.
  47788. */
  47789. readonly subSurface: PBRSubSurfaceConfiguration;
  47790. /**
  47791. * Custom callback helping to override the default shader used in the material.
  47792. */
  47793. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47794. /**
  47795. * Instantiates a new PBRMaterial instance.
  47796. *
  47797. * @param name The material name
  47798. * @param scene The scene the material will be use in.
  47799. */
  47800. constructor(name: string, scene: Scene);
  47801. /**
  47802. * Gets a boolean indicating that current material needs to register RTT
  47803. */
  47804. readonly hasRenderTargetTextures: boolean;
  47805. /**
  47806. * Gets the name of the material class.
  47807. */
  47808. getClassName(): string;
  47809. /**
  47810. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47811. */
  47812. /**
  47813. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47814. */
  47815. useLogarithmicDepth: boolean;
  47816. /**
  47817. * Gets the current transparency mode.
  47818. */
  47819. /**
  47820. * Sets the transparency mode of the material.
  47821. *
  47822. * | Value | Type | Description |
  47823. * | ----- | ----------------------------------- | ----------- |
  47824. * | 0 | OPAQUE | |
  47825. * | 1 | ALPHATEST | |
  47826. * | 2 | ALPHABLEND | |
  47827. * | 3 | ALPHATESTANDBLEND | |
  47828. *
  47829. */
  47830. transparencyMode: Nullable<number>;
  47831. /**
  47832. * Returns true if alpha blending should be disabled.
  47833. */
  47834. private readonly _disableAlphaBlending;
  47835. /**
  47836. * Specifies whether or not this material should be rendered in alpha blend mode.
  47837. */
  47838. needAlphaBlending(): boolean;
  47839. /**
  47840. * Specifies if the mesh will require alpha blending.
  47841. * @param mesh - BJS mesh.
  47842. */
  47843. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47844. /**
  47845. * Specifies whether or not this material should be rendered in alpha test mode.
  47846. */
  47847. needAlphaTesting(): boolean;
  47848. /**
  47849. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47850. */
  47851. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47852. /**
  47853. * Gets the texture used for the alpha test.
  47854. */
  47855. getAlphaTestTexture(): Nullable<BaseTexture>;
  47856. /**
  47857. * Specifies that the submesh is ready to be used.
  47858. * @param mesh - BJS mesh.
  47859. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47860. * @param useInstances - Specifies that instances should be used.
  47861. * @returns - boolean indicating that the submesh is ready or not.
  47862. */
  47863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47864. /**
  47865. * Specifies if the material uses metallic roughness workflow.
  47866. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47867. */
  47868. isMetallicWorkflow(): boolean;
  47869. private _prepareEffect;
  47870. private _prepareDefines;
  47871. /**
  47872. * Force shader compilation
  47873. */
  47874. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47875. clipPlane: boolean;
  47876. }>): void;
  47877. /**
  47878. * Initializes the uniform buffer layout for the shader.
  47879. */
  47880. buildUniformLayout(): void;
  47881. /**
  47882. * Unbinds the material from the mesh
  47883. */
  47884. unbind(): void;
  47885. /**
  47886. * Binds the submesh data.
  47887. * @param world - The world matrix.
  47888. * @param mesh - The BJS mesh.
  47889. * @param subMesh - A submesh of the BJS mesh.
  47890. */
  47891. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47892. /**
  47893. * Returns the animatable textures.
  47894. * @returns - Array of animatable textures.
  47895. */
  47896. getAnimatables(): IAnimatable[];
  47897. /**
  47898. * Returns the texture used for reflections.
  47899. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47900. */
  47901. private _getReflectionTexture;
  47902. /**
  47903. * Returns an array of the actively used textures.
  47904. * @returns - Array of BaseTextures
  47905. */
  47906. getActiveTextures(): BaseTexture[];
  47907. /**
  47908. * Checks to see if a texture is used in the material.
  47909. * @param texture - Base texture to use.
  47910. * @returns - Boolean specifying if a texture is used in the material.
  47911. */
  47912. hasTexture(texture: BaseTexture): boolean;
  47913. /**
  47914. * Disposes the resources of the material.
  47915. * @param forceDisposeEffect - Forces the disposal of effects.
  47916. * @param forceDisposeTextures - Forces the disposal of all textures.
  47917. */
  47918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47919. }
  47920. }
  47921. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47922. import { Nullable } from "babylonjs/types";
  47923. import { Scene } from "babylonjs/scene";
  47924. import { Color3 } from "babylonjs/Maths/math";
  47925. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47926. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47928. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47929. /**
  47930. * The Physically based material of BJS.
  47931. *
  47932. * This offers the main features of a standard PBR material.
  47933. * For more information, please refer to the documentation :
  47934. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47935. */
  47936. export class PBRMaterial extends PBRBaseMaterial {
  47937. /**
  47938. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47939. */
  47940. static readonly PBRMATERIAL_OPAQUE: number;
  47941. /**
  47942. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47943. */
  47944. static readonly PBRMATERIAL_ALPHATEST: number;
  47945. /**
  47946. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47947. */
  47948. static readonly PBRMATERIAL_ALPHABLEND: number;
  47949. /**
  47950. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47951. * They are also discarded below the alpha cutoff threshold to improve performances.
  47952. */
  47953. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47954. /**
  47955. * Defines the default value of how much AO map is occluding the analytical lights
  47956. * (point spot...).
  47957. */
  47958. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47959. /**
  47960. * Intensity of the direct lights e.g. the four lights available in your scene.
  47961. * This impacts both the direct diffuse and specular highlights.
  47962. */
  47963. directIntensity: number;
  47964. /**
  47965. * Intensity of the emissive part of the material.
  47966. * This helps controlling the emissive effect without modifying the emissive color.
  47967. */
  47968. emissiveIntensity: number;
  47969. /**
  47970. * Intensity of the environment e.g. how much the environment will light the object
  47971. * either through harmonics for rough material or through the refelction for shiny ones.
  47972. */
  47973. environmentIntensity: number;
  47974. /**
  47975. * This is a special control allowing the reduction of the specular highlights coming from the
  47976. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47977. */
  47978. specularIntensity: number;
  47979. /**
  47980. * Debug Control allowing disabling the bump map on this material.
  47981. */
  47982. disableBumpMap: boolean;
  47983. /**
  47984. * AKA Diffuse Texture in standard nomenclature.
  47985. */
  47986. albedoTexture: BaseTexture;
  47987. /**
  47988. * AKA Occlusion Texture in other nomenclature.
  47989. */
  47990. ambientTexture: BaseTexture;
  47991. /**
  47992. * AKA Occlusion Texture Intensity in other nomenclature.
  47993. */
  47994. ambientTextureStrength: number;
  47995. /**
  47996. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47997. * 1 means it completely occludes it
  47998. * 0 mean it has no impact
  47999. */
  48000. ambientTextureImpactOnAnalyticalLights: number;
  48001. /**
  48002. * Stores the alpha values in a texture.
  48003. */
  48004. opacityTexture: BaseTexture;
  48005. /**
  48006. * Stores the reflection values in a texture.
  48007. */
  48008. reflectionTexture: Nullable<BaseTexture>;
  48009. /**
  48010. * Stores the emissive values in a texture.
  48011. */
  48012. emissiveTexture: BaseTexture;
  48013. /**
  48014. * AKA Specular texture in other nomenclature.
  48015. */
  48016. reflectivityTexture: BaseTexture;
  48017. /**
  48018. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48019. */
  48020. metallicTexture: BaseTexture;
  48021. /**
  48022. * Specifies the metallic scalar of the metallic/roughness workflow.
  48023. * Can also be used to scale the metalness values of the metallic texture.
  48024. */
  48025. metallic: Nullable<number>;
  48026. /**
  48027. * Specifies the roughness scalar of the metallic/roughness workflow.
  48028. * Can also be used to scale the roughness values of the metallic texture.
  48029. */
  48030. roughness: Nullable<number>;
  48031. /**
  48032. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48033. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48034. */
  48035. microSurfaceTexture: BaseTexture;
  48036. /**
  48037. * Stores surface normal data used to displace a mesh in a texture.
  48038. */
  48039. bumpTexture: BaseTexture;
  48040. /**
  48041. * Stores the pre-calculated light information of a mesh in a texture.
  48042. */
  48043. lightmapTexture: BaseTexture;
  48044. /**
  48045. * Stores the refracted light information in a texture.
  48046. */
  48047. refractionTexture: Nullable<BaseTexture>;
  48048. /**
  48049. * The color of a material in ambient lighting.
  48050. */
  48051. ambientColor: Color3;
  48052. /**
  48053. * AKA Diffuse Color in other nomenclature.
  48054. */
  48055. albedoColor: Color3;
  48056. /**
  48057. * AKA Specular Color in other nomenclature.
  48058. */
  48059. reflectivityColor: Color3;
  48060. /**
  48061. * The color reflected from the material.
  48062. */
  48063. reflectionColor: Color3;
  48064. /**
  48065. * The color emitted from the material.
  48066. */
  48067. emissiveColor: Color3;
  48068. /**
  48069. * AKA Glossiness in other nomenclature.
  48070. */
  48071. microSurface: number;
  48072. /**
  48073. * source material index of refraction (IOR)' / 'destination material IOR.
  48074. */
  48075. indexOfRefraction: number;
  48076. /**
  48077. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48078. */
  48079. invertRefractionY: boolean;
  48080. /**
  48081. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48082. * Materials half opaque for instance using refraction could benefit from this control.
  48083. */
  48084. linkRefractionWithTransparency: boolean;
  48085. /**
  48086. * If true, the light map contains occlusion information instead of lighting info.
  48087. */
  48088. useLightmapAsShadowmap: boolean;
  48089. /**
  48090. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48091. */
  48092. useAlphaFromAlbedoTexture: boolean;
  48093. /**
  48094. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48095. */
  48096. forceAlphaTest: boolean;
  48097. /**
  48098. * Defines the alpha limits in alpha test mode.
  48099. */
  48100. alphaCutOff: number;
  48101. /**
  48102. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48103. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48104. */
  48105. useSpecularOverAlpha: boolean;
  48106. /**
  48107. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48108. */
  48109. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48110. /**
  48111. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48112. */
  48113. useRoughnessFromMetallicTextureAlpha: boolean;
  48114. /**
  48115. * Specifies if the metallic texture contains the roughness information in its green channel.
  48116. */
  48117. useRoughnessFromMetallicTextureGreen: boolean;
  48118. /**
  48119. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48120. */
  48121. useMetallnessFromMetallicTextureBlue: boolean;
  48122. /**
  48123. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48124. */
  48125. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48126. /**
  48127. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48128. */
  48129. useAmbientInGrayScale: boolean;
  48130. /**
  48131. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48132. * The material will try to infer what glossiness each pixel should be.
  48133. */
  48134. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48135. /**
  48136. * BJS is using an harcoded light falloff based on a manually sets up range.
  48137. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48138. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48139. */
  48140. /**
  48141. * BJS is using an harcoded light falloff based on a manually sets up range.
  48142. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48143. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48144. */
  48145. usePhysicalLightFalloff: boolean;
  48146. /**
  48147. * In order to support the falloff compatibility with gltf, a special mode has been added
  48148. * to reproduce the gltf light falloff.
  48149. */
  48150. /**
  48151. * In order to support the falloff compatibility with gltf, a special mode has been added
  48152. * to reproduce the gltf light falloff.
  48153. */
  48154. useGLTFLightFalloff: boolean;
  48155. /**
  48156. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48157. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48158. */
  48159. useRadianceOverAlpha: boolean;
  48160. /**
  48161. * Allows using an object space normal map (instead of tangent space).
  48162. */
  48163. useObjectSpaceNormalMap: boolean;
  48164. /**
  48165. * Allows using the bump map in parallax mode.
  48166. */
  48167. useParallax: boolean;
  48168. /**
  48169. * Allows using the bump map in parallax occlusion mode.
  48170. */
  48171. useParallaxOcclusion: boolean;
  48172. /**
  48173. * Controls the scale bias of the parallax mode.
  48174. */
  48175. parallaxScaleBias: number;
  48176. /**
  48177. * If sets to true, disables all the lights affecting the material.
  48178. */
  48179. disableLighting: boolean;
  48180. /**
  48181. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48182. */
  48183. forceIrradianceInFragment: boolean;
  48184. /**
  48185. * Number of Simultaneous lights allowed on the material.
  48186. */
  48187. maxSimultaneousLights: number;
  48188. /**
  48189. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48190. */
  48191. invertNormalMapX: boolean;
  48192. /**
  48193. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48194. */
  48195. invertNormalMapY: boolean;
  48196. /**
  48197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48198. */
  48199. twoSidedLighting: boolean;
  48200. /**
  48201. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48202. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48203. */
  48204. useAlphaFresnel: boolean;
  48205. /**
  48206. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48207. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48208. */
  48209. useLinearAlphaFresnel: boolean;
  48210. /**
  48211. * Let user defines the brdf lookup texture used for IBL.
  48212. * A default 8bit version is embedded but you could point at :
  48213. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48214. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48215. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48216. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48217. */
  48218. environmentBRDFTexture: Nullable<BaseTexture>;
  48219. /**
  48220. * Force normal to face away from face.
  48221. */
  48222. forceNormalForward: boolean;
  48223. /**
  48224. * Enables specular anti aliasing in the PBR shader.
  48225. * It will both interacts on the Geometry for analytical and IBL lighting.
  48226. * It also prefilter the roughness map based on the bump values.
  48227. */
  48228. enableSpecularAntiAliasing: boolean;
  48229. /**
  48230. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48231. * makes the reflect vector face the model (under horizon).
  48232. */
  48233. useHorizonOcclusion: boolean;
  48234. /**
  48235. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48236. * too much the area relying on ambient texture to define their ambient occlusion.
  48237. */
  48238. useRadianceOcclusion: boolean;
  48239. /**
  48240. * If set to true, no lighting calculations will be applied.
  48241. */
  48242. unlit: boolean;
  48243. /**
  48244. * Gets the image processing configuration used either in this material.
  48245. */
  48246. /**
  48247. * Sets the Default image processing configuration used either in the this material.
  48248. *
  48249. * If sets to null, the scene one is in use.
  48250. */
  48251. imageProcessingConfiguration: ImageProcessingConfiguration;
  48252. /**
  48253. * Gets wether the color curves effect is enabled.
  48254. */
  48255. /**
  48256. * Sets wether the color curves effect is enabled.
  48257. */
  48258. cameraColorCurvesEnabled: boolean;
  48259. /**
  48260. * Gets wether the color grading effect is enabled.
  48261. */
  48262. /**
  48263. * Gets wether the color grading effect is enabled.
  48264. */
  48265. cameraColorGradingEnabled: boolean;
  48266. /**
  48267. * Gets wether tonemapping is enabled or not.
  48268. */
  48269. /**
  48270. * Sets wether tonemapping is enabled or not
  48271. */
  48272. cameraToneMappingEnabled: boolean;
  48273. /**
  48274. * The camera exposure used on this material.
  48275. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48276. * This corresponds to a photographic exposure.
  48277. */
  48278. /**
  48279. * The camera exposure used on this material.
  48280. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48281. * This corresponds to a photographic exposure.
  48282. */
  48283. cameraExposure: number;
  48284. /**
  48285. * Gets The camera contrast used on this material.
  48286. */
  48287. /**
  48288. * Sets The camera contrast used on this material.
  48289. */
  48290. cameraContrast: number;
  48291. /**
  48292. * Gets the Color Grading 2D Lookup Texture.
  48293. */
  48294. /**
  48295. * Sets the Color Grading 2D Lookup Texture.
  48296. */
  48297. cameraColorGradingTexture: Nullable<BaseTexture>;
  48298. /**
  48299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48301. * 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;
  48302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48303. */
  48304. /**
  48305. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48306. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48307. * 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;
  48308. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48309. */
  48310. cameraColorCurves: Nullable<ColorCurves>;
  48311. /**
  48312. * Instantiates a new PBRMaterial instance.
  48313. *
  48314. * @param name The material name
  48315. * @param scene The scene the material will be use in.
  48316. */
  48317. constructor(name: string, scene: Scene);
  48318. /**
  48319. * Returns the name of this material class.
  48320. */
  48321. getClassName(): string;
  48322. /**
  48323. * Makes a duplicate of the current material.
  48324. * @param name - name to use for the new material.
  48325. */
  48326. clone(name: string): PBRMaterial;
  48327. /**
  48328. * Serializes this PBR Material.
  48329. * @returns - An object with the serialized material.
  48330. */
  48331. serialize(): any;
  48332. /**
  48333. * Parses a PBR Material from a serialized object.
  48334. * @param source - Serialized object.
  48335. * @param scene - BJS scene instance.
  48336. * @param rootUrl - url for the scene object
  48337. * @returns - PBRMaterial
  48338. */
  48339. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48340. }
  48341. }
  48342. declare module "babylonjs/Misc/dds" {
  48343. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48344. import { Engine } from "babylonjs/Engines/engine";
  48345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48346. import { Nullable } from "babylonjs/types";
  48347. import { Scene } from "babylonjs/scene";
  48348. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48349. /**
  48350. * Direct draw surface info
  48351. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48352. */
  48353. export interface DDSInfo {
  48354. /**
  48355. * Width of the texture
  48356. */
  48357. width: number;
  48358. /**
  48359. * Width of the texture
  48360. */
  48361. height: number;
  48362. /**
  48363. * Number of Mipmaps for the texture
  48364. * @see https://en.wikipedia.org/wiki/Mipmap
  48365. */
  48366. mipmapCount: number;
  48367. /**
  48368. * If the textures format is a known fourCC format
  48369. * @see https://www.fourcc.org/
  48370. */
  48371. isFourCC: boolean;
  48372. /**
  48373. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48374. */
  48375. isRGB: boolean;
  48376. /**
  48377. * If the texture is a lumincance format
  48378. */
  48379. isLuminance: boolean;
  48380. /**
  48381. * If this is a cube texture
  48382. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48383. */
  48384. isCube: boolean;
  48385. /**
  48386. * If the texture is a compressed format eg. FOURCC_DXT1
  48387. */
  48388. isCompressed: boolean;
  48389. /**
  48390. * The dxgiFormat of the texture
  48391. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48392. */
  48393. dxgiFormat: number;
  48394. /**
  48395. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48396. */
  48397. textureType: number;
  48398. /**
  48399. * Sphericle polynomial created for the dds texture
  48400. */
  48401. sphericalPolynomial?: SphericalPolynomial;
  48402. }
  48403. /**
  48404. * Class used to provide DDS decompression tools
  48405. */
  48406. export class DDSTools {
  48407. /**
  48408. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48409. */
  48410. static StoreLODInAlphaChannel: boolean;
  48411. /**
  48412. * Gets DDS information from an array buffer
  48413. * @param arrayBuffer defines the array buffer to read data from
  48414. * @returns the DDS information
  48415. */
  48416. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48417. private static _FloatView;
  48418. private static _Int32View;
  48419. private static _ToHalfFloat;
  48420. private static _FromHalfFloat;
  48421. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48422. private static _GetHalfFloatRGBAArrayBuffer;
  48423. private static _GetFloatRGBAArrayBuffer;
  48424. private static _GetFloatAsUIntRGBAArrayBuffer;
  48425. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48426. private static _GetRGBAArrayBuffer;
  48427. private static _ExtractLongWordOrder;
  48428. private static _GetRGBArrayBuffer;
  48429. private static _GetLuminanceArrayBuffer;
  48430. /**
  48431. * Uploads DDS Levels to a Babylon Texture
  48432. * @hidden
  48433. */
  48434. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48435. }
  48436. module "babylonjs/Engines/engine" {
  48437. interface Engine {
  48438. /**
  48439. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48440. * @param rootUrl defines the url where the file to load is located
  48441. * @param scene defines the current scene
  48442. * @param lodScale defines scale to apply to the mip map selection
  48443. * @param lodOffset defines offset to apply to the mip map selection
  48444. * @param onLoad defines an optional callback raised when the texture is loaded
  48445. * @param onError defines an optional callback raised if there is an issue to load the texture
  48446. * @param format defines the format of the data
  48447. * @param forcedExtension defines the extension to use to pick the right loader
  48448. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48449. * @returns the cube texture as an InternalTexture
  48450. */
  48451. 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;
  48452. }
  48453. }
  48454. }
  48455. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48456. import { Nullable } from "babylonjs/types";
  48457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48458. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48459. /**
  48460. * Implementation of the DDS Texture Loader.
  48461. * @hidden
  48462. */
  48463. export class _DDSTextureLoader implements IInternalTextureLoader {
  48464. /**
  48465. * Defines wether the loader supports cascade loading the different faces.
  48466. */
  48467. readonly supportCascades: boolean;
  48468. /**
  48469. * This returns if the loader support the current file information.
  48470. * @param extension defines the file extension of the file being loaded
  48471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48472. * @param fallback defines the fallback internal texture if any
  48473. * @param isBase64 defines whether the texture is encoded as a base64
  48474. * @param isBuffer defines whether the texture data are stored as a buffer
  48475. * @returns true if the loader can load the specified file
  48476. */
  48477. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48478. /**
  48479. * Transform the url before loading if required.
  48480. * @param rootUrl the url of the texture
  48481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48482. * @returns the transformed texture
  48483. */
  48484. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48485. /**
  48486. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48487. * @param rootUrl the url of the texture
  48488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48489. * @returns the fallback texture
  48490. */
  48491. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48492. /**
  48493. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48494. * @param data contains the texture data
  48495. * @param texture defines the BabylonJS internal texture
  48496. * @param createPolynomials will be true if polynomials have been requested
  48497. * @param onLoad defines the callback to trigger once the texture is ready
  48498. * @param onError defines the callback to trigger in case of error
  48499. */
  48500. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48501. /**
  48502. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48503. * @param data contains the texture data
  48504. * @param texture defines the BabylonJS internal texture
  48505. * @param callback defines the method to call once ready to upload
  48506. */
  48507. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48508. }
  48509. }
  48510. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48511. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48512. /** @hidden */
  48513. export var rgbdEncodePixelShader: {
  48514. name: string;
  48515. shader: string;
  48516. };
  48517. }
  48518. declare module "babylonjs/Misc/environmentTextureTools" {
  48519. import { Nullable } from "babylonjs/types";
  48520. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48522. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48523. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48524. import "babylonjs/Shaders/rgbdEncode.fragment";
  48525. import "babylonjs/Shaders/rgbdDecode.fragment";
  48526. /**
  48527. * Raw texture data and descriptor sufficient for WebGL texture upload
  48528. */
  48529. export interface EnvironmentTextureInfo {
  48530. /**
  48531. * Version of the environment map
  48532. */
  48533. version: number;
  48534. /**
  48535. * Width of image
  48536. */
  48537. width: number;
  48538. /**
  48539. * Irradiance information stored in the file.
  48540. */
  48541. irradiance: any;
  48542. /**
  48543. * Specular information stored in the file.
  48544. */
  48545. specular: any;
  48546. }
  48547. /**
  48548. * Sets of helpers addressing the serialization and deserialization of environment texture
  48549. * stored in a BabylonJS env file.
  48550. * Those files are usually stored as .env files.
  48551. */
  48552. export class EnvironmentTextureTools {
  48553. /**
  48554. * Magic number identifying the env file.
  48555. */
  48556. private static _MagicBytes;
  48557. /**
  48558. * Gets the environment info from an env file.
  48559. * @param data The array buffer containing the .env bytes.
  48560. * @returns the environment file info (the json header) if successfully parsed.
  48561. */
  48562. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48563. /**
  48564. * Creates an environment texture from a loaded cube texture.
  48565. * @param texture defines the cube texture to convert in env file
  48566. * @return a promise containing the environment data if succesfull.
  48567. */
  48568. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48569. /**
  48570. * Creates a JSON representation of the spherical data.
  48571. * @param texture defines the texture containing the polynomials
  48572. * @return the JSON representation of the spherical info
  48573. */
  48574. private static _CreateEnvTextureIrradiance;
  48575. /**
  48576. * Uploads the texture info contained in the env file to the GPU.
  48577. * @param texture defines the internal texture to upload to
  48578. * @param arrayBuffer defines the buffer cotaining the data to load
  48579. * @param info defines the texture info retrieved through the GetEnvInfo method
  48580. * @returns a promise
  48581. */
  48582. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48583. /**
  48584. * Uploads the levels of image data to the GPU.
  48585. * @param texture defines the internal texture to upload to
  48586. * @param imageData defines the array buffer views of image data [mipmap][face]
  48587. * @returns a promise
  48588. */
  48589. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48590. /**
  48591. * Uploads spherical polynomials information to the texture.
  48592. * @param texture defines the texture we are trying to upload the information to
  48593. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48594. */
  48595. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48596. /** @hidden */
  48597. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48598. }
  48599. }
  48600. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48601. import { Nullable } from "babylonjs/types";
  48602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48603. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48604. /**
  48605. * Implementation of the ENV Texture Loader.
  48606. * @hidden
  48607. */
  48608. export class _ENVTextureLoader implements IInternalTextureLoader {
  48609. /**
  48610. * Defines wether the loader supports cascade loading the different faces.
  48611. */
  48612. readonly supportCascades: boolean;
  48613. /**
  48614. * This returns if the loader support the current file information.
  48615. * @param extension defines the file extension of the file being loaded
  48616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48617. * @param fallback defines the fallback internal texture if any
  48618. * @param isBase64 defines whether the texture is encoded as a base64
  48619. * @param isBuffer defines whether the texture data are stored as a buffer
  48620. * @returns true if the loader can load the specified file
  48621. */
  48622. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48623. /**
  48624. * Transform the url before loading if required.
  48625. * @param rootUrl the url of the texture
  48626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48627. * @returns the transformed texture
  48628. */
  48629. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48630. /**
  48631. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48632. * @param rootUrl the url of the texture
  48633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48634. * @returns the fallback texture
  48635. */
  48636. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48637. /**
  48638. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48639. * @param data contains the texture data
  48640. * @param texture defines the BabylonJS internal texture
  48641. * @param createPolynomials will be true if polynomials have been requested
  48642. * @param onLoad defines the callback to trigger once the texture is ready
  48643. * @param onError defines the callback to trigger in case of error
  48644. */
  48645. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48646. /**
  48647. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48648. * @param data contains the texture data
  48649. * @param texture defines the BabylonJS internal texture
  48650. * @param callback defines the method to call once ready to upload
  48651. */
  48652. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48653. }
  48654. }
  48655. declare module "babylonjs/Misc/khronosTextureContainer" {
  48656. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48657. /**
  48658. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48659. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48660. */
  48661. export class KhronosTextureContainer {
  48662. /** contents of the KTX container file */
  48663. arrayBuffer: any;
  48664. private static HEADER_LEN;
  48665. private static COMPRESSED_2D;
  48666. private static COMPRESSED_3D;
  48667. private static TEX_2D;
  48668. private static TEX_3D;
  48669. /**
  48670. * Gets the openGL type
  48671. */
  48672. glType: number;
  48673. /**
  48674. * Gets the openGL type size
  48675. */
  48676. glTypeSize: number;
  48677. /**
  48678. * Gets the openGL format
  48679. */
  48680. glFormat: number;
  48681. /**
  48682. * Gets the openGL internal format
  48683. */
  48684. glInternalFormat: number;
  48685. /**
  48686. * Gets the base internal format
  48687. */
  48688. glBaseInternalFormat: number;
  48689. /**
  48690. * Gets image width in pixel
  48691. */
  48692. pixelWidth: number;
  48693. /**
  48694. * Gets image height in pixel
  48695. */
  48696. pixelHeight: number;
  48697. /**
  48698. * Gets image depth in pixels
  48699. */
  48700. pixelDepth: number;
  48701. /**
  48702. * Gets the number of array elements
  48703. */
  48704. numberOfArrayElements: number;
  48705. /**
  48706. * Gets the number of faces
  48707. */
  48708. numberOfFaces: number;
  48709. /**
  48710. * Gets the number of mipmap levels
  48711. */
  48712. numberOfMipmapLevels: number;
  48713. /**
  48714. * Gets the bytes of key value data
  48715. */
  48716. bytesOfKeyValueData: number;
  48717. /**
  48718. * Gets the load type
  48719. */
  48720. loadType: number;
  48721. /**
  48722. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48723. */
  48724. isInvalid: boolean;
  48725. /**
  48726. * Creates a new KhronosTextureContainer
  48727. * @param arrayBuffer contents of the KTX container file
  48728. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48729. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48730. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48731. */
  48732. constructor(
  48733. /** contents of the KTX container file */
  48734. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48735. /**
  48736. * Uploads KTX content to a Babylon Texture.
  48737. * It is assumed that the texture has already been created & is currently bound
  48738. * @hidden
  48739. */
  48740. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48741. private _upload2DCompressedLevels;
  48742. }
  48743. }
  48744. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48745. import { Nullable } from "babylonjs/types";
  48746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48747. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48748. /**
  48749. * Implementation of the KTX Texture Loader.
  48750. * @hidden
  48751. */
  48752. export class _KTXTextureLoader implements IInternalTextureLoader {
  48753. /**
  48754. * Defines wether the loader supports cascade loading the different faces.
  48755. */
  48756. readonly supportCascades: boolean;
  48757. /**
  48758. * This returns if the loader support the current file information.
  48759. * @param extension defines the file extension of the file being loaded
  48760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48761. * @param fallback defines the fallback internal texture if any
  48762. * @param isBase64 defines whether the texture is encoded as a base64
  48763. * @param isBuffer defines whether the texture data are stored as a buffer
  48764. * @returns true if the loader can load the specified file
  48765. */
  48766. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48767. /**
  48768. * Transform the url before loading if required.
  48769. * @param rootUrl the url of the texture
  48770. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48771. * @returns the transformed texture
  48772. */
  48773. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48774. /**
  48775. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48776. * @param rootUrl the url of the texture
  48777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48778. * @returns the fallback texture
  48779. */
  48780. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48781. /**
  48782. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48783. * @param data contains the texture data
  48784. * @param texture defines the BabylonJS internal texture
  48785. * @param createPolynomials will be true if polynomials have been requested
  48786. * @param onLoad defines the callback to trigger once the texture is ready
  48787. * @param onError defines the callback to trigger in case of error
  48788. */
  48789. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48790. /**
  48791. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48792. * @param data contains the texture data
  48793. * @param texture defines the BabylonJS internal texture
  48794. * @param callback defines the method to call once ready to upload
  48795. */
  48796. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48797. }
  48798. }
  48799. declare module "babylonjs/Helpers/sceneHelpers" {
  48800. import { Nullable } from "babylonjs/types";
  48801. import { Mesh } from "babylonjs/Meshes/mesh";
  48802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48803. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48804. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48805. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48806. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48807. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48808. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48809. import "babylonjs/Meshes/Builders/boxBuilder";
  48810. /** @hidden */
  48811. export var _forceSceneHelpersToBundle: boolean;
  48812. module "babylonjs/scene" {
  48813. interface Scene {
  48814. /**
  48815. * Creates a default light for the scene.
  48816. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48817. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48818. */
  48819. createDefaultLight(replace?: boolean): void;
  48820. /**
  48821. * Creates a default camera for the scene.
  48822. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48823. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48824. * @param replace has default false, when true replaces the active camera in the scene
  48825. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48826. */
  48827. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48828. /**
  48829. * Creates a default camera and a default light.
  48830. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48831. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48832. * @param replace has the default false, when true replaces the active camera/light in the scene
  48833. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48834. */
  48835. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48836. /**
  48837. * Creates a new sky box
  48838. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48839. * @param environmentTexture defines the texture to use as environment texture
  48840. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48841. * @param scale defines the overall scale of the skybox
  48842. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48843. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48844. * @returns a new mesh holding the sky box
  48845. */
  48846. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48847. /**
  48848. * Creates a new environment
  48849. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48850. * @param options defines the options you can use to configure the environment
  48851. * @returns the new EnvironmentHelper
  48852. */
  48853. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48854. /**
  48855. * Creates a new VREXperienceHelper
  48856. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48857. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48858. * @returns a new VREXperienceHelper
  48859. */
  48860. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48861. /**
  48862. * Creates a new XREXperienceHelper
  48863. * @see http://doc.babylonjs.com/how_to/webxr
  48864. * @returns a promise for a new XREXperienceHelper
  48865. */
  48866. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48867. }
  48868. }
  48869. }
  48870. declare module "babylonjs/Helpers/videoDome" {
  48871. import { Scene } from "babylonjs/scene";
  48872. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48873. import { Mesh } from "babylonjs/Meshes/mesh";
  48874. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48875. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48876. import "babylonjs/Meshes/Builders/sphereBuilder";
  48877. /**
  48878. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48879. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48880. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48881. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48882. */
  48883. export class VideoDome extends TransformNode {
  48884. /**
  48885. * Define the video source as a Monoscopic panoramic 360 video.
  48886. */
  48887. static readonly MODE_MONOSCOPIC: number;
  48888. /**
  48889. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48890. */
  48891. static readonly MODE_TOPBOTTOM: number;
  48892. /**
  48893. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48894. */
  48895. static readonly MODE_SIDEBYSIDE: number;
  48896. private _useDirectMapping;
  48897. /**
  48898. * The video texture being displayed on the sphere
  48899. */
  48900. protected _videoTexture: VideoTexture;
  48901. /**
  48902. * Gets the video texture being displayed on the sphere
  48903. */
  48904. readonly videoTexture: VideoTexture;
  48905. /**
  48906. * The skybox material
  48907. */
  48908. protected _material: BackgroundMaterial;
  48909. /**
  48910. * The surface used for the skybox
  48911. */
  48912. protected _mesh: Mesh;
  48913. /**
  48914. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48915. * Also see the options.resolution property.
  48916. */
  48917. fovMultiplier: number;
  48918. private _videoMode;
  48919. /**
  48920. * Gets or set the current video mode for the video. It can be:
  48921. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48922. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48923. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48924. */
  48925. videoMode: number;
  48926. /**
  48927. * Oberserver used in Stereoscopic VR Mode.
  48928. */
  48929. private _onBeforeCameraRenderObserver;
  48930. /**
  48931. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48932. * @param name Element's name, child elements will append suffixes for their own names.
  48933. * @param urlsOrVideo defines the url(s) or the video element to use
  48934. * @param options An object containing optional or exposed sub element properties
  48935. */
  48936. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48937. resolution?: number;
  48938. clickToPlay?: boolean;
  48939. autoPlay?: boolean;
  48940. loop?: boolean;
  48941. size?: number;
  48942. poster?: string;
  48943. faceForward?: boolean;
  48944. useDirectMapping?: boolean;
  48945. }, scene: Scene);
  48946. private _changeVideoMode;
  48947. /**
  48948. * Releases resources associated with this node.
  48949. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48950. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48951. */
  48952. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48953. }
  48954. }
  48955. declare module "babylonjs/Helpers/index" {
  48956. export * from "babylonjs/Helpers/environmentHelper";
  48957. export * from "babylonjs/Helpers/photoDome";
  48958. export * from "babylonjs/Helpers/sceneHelpers";
  48959. export * from "babylonjs/Helpers/videoDome";
  48960. }
  48961. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48962. import { PerfCounter } from "babylonjs/Misc/tools";
  48963. import { IDisposable } from "babylonjs/scene";
  48964. import { Engine } from "babylonjs/Engines/engine";
  48965. /**
  48966. * This class can be used to get instrumentation data from a Babylon engine
  48967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48968. */
  48969. export class EngineInstrumentation implements IDisposable {
  48970. /**
  48971. * Define the instrumented engine.
  48972. */
  48973. engine: Engine;
  48974. private _captureGPUFrameTime;
  48975. private _gpuFrameTimeToken;
  48976. private _gpuFrameTime;
  48977. private _captureShaderCompilationTime;
  48978. private _shaderCompilationTime;
  48979. private _onBeginFrameObserver;
  48980. private _onEndFrameObserver;
  48981. private _onBeforeShaderCompilationObserver;
  48982. private _onAfterShaderCompilationObserver;
  48983. /**
  48984. * Gets the perf counter used for GPU frame time
  48985. */
  48986. readonly gpuFrameTimeCounter: PerfCounter;
  48987. /**
  48988. * Gets the GPU frame time capture status
  48989. */
  48990. /**
  48991. * Enable or disable the GPU frame time capture
  48992. */
  48993. captureGPUFrameTime: boolean;
  48994. /**
  48995. * Gets the perf counter used for shader compilation time
  48996. */
  48997. readonly shaderCompilationTimeCounter: PerfCounter;
  48998. /**
  48999. * Gets the shader compilation time capture status
  49000. */
  49001. /**
  49002. * Enable or disable the shader compilation time capture
  49003. */
  49004. captureShaderCompilationTime: boolean;
  49005. /**
  49006. * Instantiates a new engine instrumentation.
  49007. * This class can be used to get instrumentation data from a Babylon engine
  49008. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49009. * @param engine Defines the engine to instrument
  49010. */
  49011. constructor(
  49012. /**
  49013. * Define the instrumented engine.
  49014. */
  49015. engine: Engine);
  49016. /**
  49017. * Dispose and release associated resources.
  49018. */
  49019. dispose(): void;
  49020. }
  49021. }
  49022. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49023. import { PerfCounter } from "babylonjs/Misc/tools";
  49024. import { Scene, IDisposable } from "babylonjs/scene";
  49025. /**
  49026. * This class can be used to get instrumentation data from a Babylon engine
  49027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49028. */
  49029. export class SceneInstrumentation implements IDisposable {
  49030. /**
  49031. * Defines the scene to instrument
  49032. */
  49033. scene: Scene;
  49034. private _captureActiveMeshesEvaluationTime;
  49035. private _activeMeshesEvaluationTime;
  49036. private _captureRenderTargetsRenderTime;
  49037. private _renderTargetsRenderTime;
  49038. private _captureFrameTime;
  49039. private _frameTime;
  49040. private _captureRenderTime;
  49041. private _renderTime;
  49042. private _captureInterFrameTime;
  49043. private _interFrameTime;
  49044. private _captureParticlesRenderTime;
  49045. private _particlesRenderTime;
  49046. private _captureSpritesRenderTime;
  49047. private _spritesRenderTime;
  49048. private _capturePhysicsTime;
  49049. private _physicsTime;
  49050. private _captureAnimationsTime;
  49051. private _animationsTime;
  49052. private _captureCameraRenderTime;
  49053. private _cameraRenderTime;
  49054. private _onBeforeActiveMeshesEvaluationObserver;
  49055. private _onAfterActiveMeshesEvaluationObserver;
  49056. private _onBeforeRenderTargetsRenderObserver;
  49057. private _onAfterRenderTargetsRenderObserver;
  49058. private _onAfterRenderObserver;
  49059. private _onBeforeDrawPhaseObserver;
  49060. private _onAfterDrawPhaseObserver;
  49061. private _onBeforeAnimationsObserver;
  49062. private _onBeforeParticlesRenderingObserver;
  49063. private _onAfterParticlesRenderingObserver;
  49064. private _onBeforeSpritesRenderingObserver;
  49065. private _onAfterSpritesRenderingObserver;
  49066. private _onBeforePhysicsObserver;
  49067. private _onAfterPhysicsObserver;
  49068. private _onAfterAnimationsObserver;
  49069. private _onBeforeCameraRenderObserver;
  49070. private _onAfterCameraRenderObserver;
  49071. /**
  49072. * Gets the perf counter used for active meshes evaluation time
  49073. */
  49074. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49075. /**
  49076. * Gets the active meshes evaluation time capture status
  49077. */
  49078. /**
  49079. * Enable or disable the active meshes evaluation time capture
  49080. */
  49081. captureActiveMeshesEvaluationTime: boolean;
  49082. /**
  49083. * Gets the perf counter used for render targets render time
  49084. */
  49085. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49086. /**
  49087. * Gets the render targets render time capture status
  49088. */
  49089. /**
  49090. * Enable or disable the render targets render time capture
  49091. */
  49092. captureRenderTargetsRenderTime: boolean;
  49093. /**
  49094. * Gets the perf counter used for particles render time
  49095. */
  49096. readonly particlesRenderTimeCounter: PerfCounter;
  49097. /**
  49098. * Gets the particles render time capture status
  49099. */
  49100. /**
  49101. * Enable or disable the particles render time capture
  49102. */
  49103. captureParticlesRenderTime: boolean;
  49104. /**
  49105. * Gets the perf counter used for sprites render time
  49106. */
  49107. readonly spritesRenderTimeCounter: PerfCounter;
  49108. /**
  49109. * Gets the sprites render time capture status
  49110. */
  49111. /**
  49112. * Enable or disable the sprites render time capture
  49113. */
  49114. captureSpritesRenderTime: boolean;
  49115. /**
  49116. * Gets the perf counter used for physics time
  49117. */
  49118. readonly physicsTimeCounter: PerfCounter;
  49119. /**
  49120. * Gets the physics time capture status
  49121. */
  49122. /**
  49123. * Enable or disable the physics time capture
  49124. */
  49125. capturePhysicsTime: boolean;
  49126. /**
  49127. * Gets the perf counter used for animations time
  49128. */
  49129. readonly animationsTimeCounter: PerfCounter;
  49130. /**
  49131. * Gets the animations time capture status
  49132. */
  49133. /**
  49134. * Enable or disable the animations time capture
  49135. */
  49136. captureAnimationsTime: boolean;
  49137. /**
  49138. * Gets the perf counter used for frame time capture
  49139. */
  49140. readonly frameTimeCounter: PerfCounter;
  49141. /**
  49142. * Gets the frame time capture status
  49143. */
  49144. /**
  49145. * Enable or disable the frame time capture
  49146. */
  49147. captureFrameTime: boolean;
  49148. /**
  49149. * Gets the perf counter used for inter-frames time capture
  49150. */
  49151. readonly interFrameTimeCounter: PerfCounter;
  49152. /**
  49153. * Gets the inter-frames time capture status
  49154. */
  49155. /**
  49156. * Enable or disable the inter-frames time capture
  49157. */
  49158. captureInterFrameTime: boolean;
  49159. /**
  49160. * Gets the perf counter used for render time capture
  49161. */
  49162. readonly renderTimeCounter: PerfCounter;
  49163. /**
  49164. * Gets the render time capture status
  49165. */
  49166. /**
  49167. * Enable or disable the render time capture
  49168. */
  49169. captureRenderTime: boolean;
  49170. /**
  49171. * Gets the perf counter used for camera render time capture
  49172. */
  49173. readonly cameraRenderTimeCounter: PerfCounter;
  49174. /**
  49175. * Gets the camera render time capture status
  49176. */
  49177. /**
  49178. * Enable or disable the camera render time capture
  49179. */
  49180. captureCameraRenderTime: boolean;
  49181. /**
  49182. * Gets the perf counter used for draw calls
  49183. */
  49184. readonly drawCallsCounter: PerfCounter;
  49185. /**
  49186. * Instantiates a new scene instrumentation.
  49187. * This class can be used to get instrumentation data from a Babylon engine
  49188. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49189. * @param scene Defines the scene to instrument
  49190. */
  49191. constructor(
  49192. /**
  49193. * Defines the scene to instrument
  49194. */
  49195. scene: Scene);
  49196. /**
  49197. * Dispose and release associated resources.
  49198. */
  49199. dispose(): void;
  49200. }
  49201. }
  49202. declare module "babylonjs/Instrumentation/index" {
  49203. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49204. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49205. export * from "babylonjs/Instrumentation/timeToken";
  49206. }
  49207. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49208. /** @hidden */
  49209. export var glowMapGenerationPixelShader: {
  49210. name: string;
  49211. shader: string;
  49212. };
  49213. }
  49214. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49215. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49216. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49217. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49218. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49220. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49221. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49222. /** @hidden */
  49223. export var glowMapGenerationVertexShader: {
  49224. name: string;
  49225. shader: string;
  49226. };
  49227. }
  49228. declare module "babylonjs/Layers/effectLayer" {
  49229. import { Observable } from "babylonjs/Misc/observable";
  49230. import { Nullable } from "babylonjs/types";
  49231. import { Camera } from "babylonjs/Cameras/camera";
  49232. import { Scene } from "babylonjs/scene";
  49233. import { Color4, ISize } from "babylonjs/Maths/math";
  49234. import { Engine } from "babylonjs/Engines/engine";
  49235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49237. import { Mesh } from "babylonjs/Meshes/mesh";
  49238. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49239. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49240. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49241. import { Effect } from "babylonjs/Materials/effect";
  49242. import { Material } from "babylonjs/Materials/material";
  49243. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49244. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49245. /**
  49246. * Effect layer options. This helps customizing the behaviour
  49247. * of the effect layer.
  49248. */
  49249. export interface IEffectLayerOptions {
  49250. /**
  49251. * Multiplication factor apply to the canvas size to compute the render target size
  49252. * used to generated the objects (the smaller the faster).
  49253. */
  49254. mainTextureRatio: number;
  49255. /**
  49256. * Enforces a fixed size texture to ensure effect stability across devices.
  49257. */
  49258. mainTextureFixedSize?: number;
  49259. /**
  49260. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49261. */
  49262. alphaBlendingMode: number;
  49263. /**
  49264. * The camera attached to the layer.
  49265. */
  49266. camera: Nullable<Camera>;
  49267. /**
  49268. * The rendering group to draw the layer in.
  49269. */
  49270. renderingGroupId: number;
  49271. }
  49272. /**
  49273. * The effect layer Helps adding post process effect blended with the main pass.
  49274. *
  49275. * This can be for instance use to generate glow or higlight effects on the scene.
  49276. *
  49277. * The effect layer class can not be used directly and is intented to inherited from to be
  49278. * customized per effects.
  49279. */
  49280. export abstract class EffectLayer {
  49281. private _vertexBuffers;
  49282. private _indexBuffer;
  49283. private _cachedDefines;
  49284. private _effectLayerMapGenerationEffect;
  49285. private _effectLayerOptions;
  49286. private _mergeEffect;
  49287. protected _scene: Scene;
  49288. protected _engine: Engine;
  49289. protected _maxSize: number;
  49290. protected _mainTextureDesiredSize: ISize;
  49291. protected _mainTexture: RenderTargetTexture;
  49292. protected _shouldRender: boolean;
  49293. protected _postProcesses: PostProcess[];
  49294. protected _textures: BaseTexture[];
  49295. protected _emissiveTextureAndColor: {
  49296. texture: Nullable<BaseTexture>;
  49297. color: Color4;
  49298. };
  49299. /**
  49300. * The name of the layer
  49301. */
  49302. name: string;
  49303. /**
  49304. * The clear color of the texture used to generate the glow map.
  49305. */
  49306. neutralColor: Color4;
  49307. /**
  49308. * Specifies wether the highlight layer is enabled or not.
  49309. */
  49310. isEnabled: boolean;
  49311. /**
  49312. * Gets the camera attached to the layer.
  49313. */
  49314. readonly camera: Nullable<Camera>;
  49315. /**
  49316. * Gets the rendering group id the layer should render in.
  49317. */
  49318. readonly renderingGroupId: number;
  49319. /**
  49320. * An event triggered when the effect layer has been disposed.
  49321. */
  49322. onDisposeObservable: Observable<EffectLayer>;
  49323. /**
  49324. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49325. */
  49326. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49327. /**
  49328. * An event triggered when the generated texture is being merged in the scene.
  49329. */
  49330. onBeforeComposeObservable: Observable<EffectLayer>;
  49331. /**
  49332. * An event triggered when the generated texture has been merged in the scene.
  49333. */
  49334. onAfterComposeObservable: Observable<EffectLayer>;
  49335. /**
  49336. * An event triggered when the efffect layer changes its size.
  49337. */
  49338. onSizeChangedObservable: Observable<EffectLayer>;
  49339. /** @hidden */
  49340. static _SceneComponentInitialization: (scene: Scene) => void;
  49341. /**
  49342. * Instantiates a new effect Layer and references it in the scene.
  49343. * @param name The name of the layer
  49344. * @param scene The scene to use the layer in
  49345. */
  49346. constructor(
  49347. /** The Friendly of the effect in the scene */
  49348. name: string, scene: Scene);
  49349. /**
  49350. * Get the effect name of the layer.
  49351. * @return The effect name
  49352. */
  49353. abstract getEffectName(): string;
  49354. /**
  49355. * Checks for the readiness of the element composing the layer.
  49356. * @param subMesh the mesh to check for
  49357. * @param useInstances specify wether or not to use instances to render the mesh
  49358. * @return true if ready otherwise, false
  49359. */
  49360. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49361. /**
  49362. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49363. * @returns true if the effect requires stencil during the main canvas render pass.
  49364. */
  49365. abstract needStencil(): boolean;
  49366. /**
  49367. * Create the merge effect. This is the shader use to blit the information back
  49368. * to the main canvas at the end of the scene rendering.
  49369. * @returns The effect containing the shader used to merge the effect on the main canvas
  49370. */
  49371. protected abstract _createMergeEffect(): Effect;
  49372. /**
  49373. * Creates the render target textures and post processes used in the effect layer.
  49374. */
  49375. protected abstract _createTextureAndPostProcesses(): void;
  49376. /**
  49377. * Implementation specific of rendering the generating effect on the main canvas.
  49378. * @param effect The effect used to render through
  49379. */
  49380. protected abstract _internalRender(effect: Effect): void;
  49381. /**
  49382. * Sets the required values for both the emissive texture and and the main color.
  49383. */
  49384. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49385. /**
  49386. * Free any resources and references associated to a mesh.
  49387. * Internal use
  49388. * @param mesh The mesh to free.
  49389. */
  49390. abstract _disposeMesh(mesh: Mesh): void;
  49391. /**
  49392. * Serializes this layer (Glow or Highlight for example)
  49393. * @returns a serialized layer object
  49394. */
  49395. abstract serialize?(): any;
  49396. /**
  49397. * Initializes the effect layer with the required options.
  49398. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49399. */
  49400. protected _init(options: Partial<IEffectLayerOptions>): void;
  49401. /**
  49402. * Generates the index buffer of the full screen quad blending to the main canvas.
  49403. */
  49404. private _generateIndexBuffer;
  49405. /**
  49406. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49407. */
  49408. private _generateVertexBuffer;
  49409. /**
  49410. * Sets the main texture desired size which is the closest power of two
  49411. * of the engine canvas size.
  49412. */
  49413. private _setMainTextureSize;
  49414. /**
  49415. * Creates the main texture for the effect layer.
  49416. */
  49417. protected _createMainTexture(): void;
  49418. /**
  49419. * Adds specific effects defines.
  49420. * @param defines The defines to add specifics to.
  49421. */
  49422. protected _addCustomEffectDefines(defines: string[]): void;
  49423. /**
  49424. * Checks for the readiness of the element composing the layer.
  49425. * @param subMesh the mesh to check for
  49426. * @param useInstances specify wether or not to use instances to render the mesh
  49427. * @param emissiveTexture the associated emissive texture used to generate the glow
  49428. * @return true if ready otherwise, false
  49429. */
  49430. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49431. /**
  49432. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49433. */
  49434. render(): void;
  49435. /**
  49436. * Determine if a given mesh will be used in the current effect.
  49437. * @param mesh mesh to test
  49438. * @returns true if the mesh will be used
  49439. */
  49440. hasMesh(mesh: AbstractMesh): boolean;
  49441. /**
  49442. * Returns true if the layer contains information to display, otherwise false.
  49443. * @returns true if the glow layer should be rendered
  49444. */
  49445. shouldRender(): boolean;
  49446. /**
  49447. * Returns true if the mesh should render, otherwise false.
  49448. * @param mesh The mesh to render
  49449. * @returns true if it should render otherwise false
  49450. */
  49451. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49452. /**
  49453. * Returns true if the mesh can be rendered, otherwise false.
  49454. * @param mesh The mesh to render
  49455. * @param material The material used on the mesh
  49456. * @returns true if it can be rendered otherwise false
  49457. */
  49458. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49459. /**
  49460. * Returns true if the mesh should render, otherwise false.
  49461. * @param mesh The mesh to render
  49462. * @returns true if it should render otherwise false
  49463. */
  49464. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49465. /**
  49466. * Renders the submesh passed in parameter to the generation map.
  49467. */
  49468. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49469. /**
  49470. * Rebuild the required buffers.
  49471. * @hidden Internal use only.
  49472. */
  49473. _rebuild(): void;
  49474. /**
  49475. * Dispose only the render target textures and post process.
  49476. */
  49477. private _disposeTextureAndPostProcesses;
  49478. /**
  49479. * Dispose the highlight layer and free resources.
  49480. */
  49481. dispose(): void;
  49482. /**
  49483. * Gets the class name of the effect layer
  49484. * @returns the string with the class name of the effect layer
  49485. */
  49486. getClassName(): string;
  49487. /**
  49488. * Creates an effect layer from parsed effect layer data
  49489. * @param parsedEffectLayer defines effect layer data
  49490. * @param scene defines the current scene
  49491. * @param rootUrl defines the root URL containing the effect layer information
  49492. * @returns a parsed effect Layer
  49493. */
  49494. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49495. }
  49496. }
  49497. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49498. import { Scene } from "babylonjs/scene";
  49499. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49500. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49501. import { AbstractScene } from "babylonjs/abstractScene";
  49502. module "babylonjs/abstractScene" {
  49503. interface AbstractScene {
  49504. /**
  49505. * The list of effect layers (highlights/glow) added to the scene
  49506. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49507. * @see http://doc.babylonjs.com/how_to/glow_layer
  49508. */
  49509. effectLayers: Array<EffectLayer>;
  49510. /**
  49511. * Removes the given effect layer from this scene.
  49512. * @param toRemove defines the effect layer to remove
  49513. * @returns the index of the removed effect layer
  49514. */
  49515. removeEffectLayer(toRemove: EffectLayer): number;
  49516. /**
  49517. * Adds the given effect layer to this scene
  49518. * @param newEffectLayer defines the effect layer to add
  49519. */
  49520. addEffectLayer(newEffectLayer: EffectLayer): void;
  49521. }
  49522. }
  49523. /**
  49524. * Defines the layer scene component responsible to manage any effect layers
  49525. * in a given scene.
  49526. */
  49527. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49528. /**
  49529. * The component name helpfull to identify the component in the list of scene components.
  49530. */
  49531. readonly name: string;
  49532. /**
  49533. * The scene the component belongs to.
  49534. */
  49535. scene: Scene;
  49536. private _engine;
  49537. private _renderEffects;
  49538. private _needStencil;
  49539. private _previousStencilState;
  49540. /**
  49541. * Creates a new instance of the component for the given scene
  49542. * @param scene Defines the scene to register the component in
  49543. */
  49544. constructor(scene: Scene);
  49545. /**
  49546. * Registers the component in a given scene
  49547. */
  49548. register(): void;
  49549. /**
  49550. * Rebuilds the elements related to this component in case of
  49551. * context lost for instance.
  49552. */
  49553. rebuild(): void;
  49554. /**
  49555. * Serializes the component data to the specified json object
  49556. * @param serializationObject The object to serialize to
  49557. */
  49558. serialize(serializationObject: any): void;
  49559. /**
  49560. * Adds all the elements from the container to the scene
  49561. * @param container the container holding the elements
  49562. */
  49563. addFromContainer(container: AbstractScene): void;
  49564. /**
  49565. * Removes all the elements in the container from the scene
  49566. * @param container contains the elements to remove
  49567. * @param dispose if the removed element should be disposed (default: false)
  49568. */
  49569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49570. /**
  49571. * Disposes the component and the associated ressources.
  49572. */
  49573. dispose(): void;
  49574. private _isReadyForMesh;
  49575. private _renderMainTexture;
  49576. private _setStencil;
  49577. private _setStencilBack;
  49578. private _draw;
  49579. private _drawCamera;
  49580. private _drawRenderingGroup;
  49581. }
  49582. }
  49583. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49584. /** @hidden */
  49585. export var glowMapMergePixelShader: {
  49586. name: string;
  49587. shader: string;
  49588. };
  49589. }
  49590. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49591. /** @hidden */
  49592. export var glowMapMergeVertexShader: {
  49593. name: string;
  49594. shader: string;
  49595. };
  49596. }
  49597. declare module "babylonjs/Layers/glowLayer" {
  49598. import { Nullable } from "babylonjs/types";
  49599. import { Camera } from "babylonjs/Cameras/camera";
  49600. import { Scene } from "babylonjs/scene";
  49601. import { Color4 } from "babylonjs/Maths/math";
  49602. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49604. import { Mesh } from "babylonjs/Meshes/mesh";
  49605. import { Texture } from "babylonjs/Materials/Textures/texture";
  49606. import { Effect } from "babylonjs/Materials/effect";
  49607. import { Material } from "babylonjs/Materials/material";
  49608. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49609. import "babylonjs/Shaders/glowMapMerge.fragment";
  49610. import "babylonjs/Shaders/glowMapMerge.vertex";
  49611. import "babylonjs/Layers/effectLayerSceneComponent";
  49612. module "babylonjs/abstractScene" {
  49613. interface AbstractScene {
  49614. /**
  49615. * Return a the first highlight layer of the scene with a given name.
  49616. * @param name The name of the highlight layer to look for.
  49617. * @return The highlight layer if found otherwise null.
  49618. */
  49619. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49620. }
  49621. }
  49622. /**
  49623. * Glow layer options. This helps customizing the behaviour
  49624. * of the glow layer.
  49625. */
  49626. export interface IGlowLayerOptions {
  49627. /**
  49628. * Multiplication factor apply to the canvas size to compute the render target size
  49629. * used to generated the glowing objects (the smaller the faster).
  49630. */
  49631. mainTextureRatio: number;
  49632. /**
  49633. * Enforces a fixed size texture to ensure resize independant blur.
  49634. */
  49635. mainTextureFixedSize?: number;
  49636. /**
  49637. * How big is the kernel of the blur texture.
  49638. */
  49639. blurKernelSize: number;
  49640. /**
  49641. * The camera attached to the layer.
  49642. */
  49643. camera: Nullable<Camera>;
  49644. /**
  49645. * Enable MSAA by chosing the number of samples.
  49646. */
  49647. mainTextureSamples?: number;
  49648. /**
  49649. * The rendering group to draw the layer in.
  49650. */
  49651. renderingGroupId: number;
  49652. }
  49653. /**
  49654. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49655. *
  49656. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49657. * glowy meshes to your scene.
  49658. *
  49659. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49660. */
  49661. export class GlowLayer extends EffectLayer {
  49662. /**
  49663. * Effect Name of the layer.
  49664. */
  49665. static readonly EffectName: string;
  49666. /**
  49667. * The default blur kernel size used for the glow.
  49668. */
  49669. static DefaultBlurKernelSize: number;
  49670. /**
  49671. * The default texture size ratio used for the glow.
  49672. */
  49673. static DefaultTextureRatio: number;
  49674. /**
  49675. * Sets the kernel size of the blur.
  49676. */
  49677. /**
  49678. * Gets the kernel size of the blur.
  49679. */
  49680. blurKernelSize: number;
  49681. /**
  49682. * Sets the glow intensity.
  49683. */
  49684. /**
  49685. * Gets the glow intensity.
  49686. */
  49687. intensity: number;
  49688. private _options;
  49689. private _intensity;
  49690. private _horizontalBlurPostprocess1;
  49691. private _verticalBlurPostprocess1;
  49692. private _horizontalBlurPostprocess2;
  49693. private _verticalBlurPostprocess2;
  49694. private _blurTexture1;
  49695. private _blurTexture2;
  49696. private _postProcesses1;
  49697. private _postProcesses2;
  49698. private _includedOnlyMeshes;
  49699. private _excludedMeshes;
  49700. /**
  49701. * Callback used to let the user override the color selection on a per mesh basis
  49702. */
  49703. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49704. /**
  49705. * Callback used to let the user override the texture selection on a per mesh basis
  49706. */
  49707. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49708. /**
  49709. * Instantiates a new glow Layer and references it to the scene.
  49710. * @param name The name of the layer
  49711. * @param scene The scene to use the layer in
  49712. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49713. */
  49714. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49715. /**
  49716. * Get the effect name of the layer.
  49717. * @return The effect name
  49718. */
  49719. getEffectName(): string;
  49720. /**
  49721. * Create the merge effect. This is the shader use to blit the information back
  49722. * to the main canvas at the end of the scene rendering.
  49723. */
  49724. protected _createMergeEffect(): Effect;
  49725. /**
  49726. * Creates the render target textures and post processes used in the glow layer.
  49727. */
  49728. protected _createTextureAndPostProcesses(): void;
  49729. /**
  49730. * Checks for the readiness of the element composing the layer.
  49731. * @param subMesh the mesh to check for
  49732. * @param useInstances specify wether or not to use instances to render the mesh
  49733. * @param emissiveTexture the associated emissive texture used to generate the glow
  49734. * @return true if ready otherwise, false
  49735. */
  49736. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49737. /**
  49738. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49739. */
  49740. needStencil(): boolean;
  49741. /**
  49742. * Returns true if the mesh can be rendered, otherwise false.
  49743. * @param mesh The mesh to render
  49744. * @param material The material used on the mesh
  49745. * @returns true if it can be rendered otherwise false
  49746. */
  49747. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49748. /**
  49749. * Implementation specific of rendering the generating effect on the main canvas.
  49750. * @param effect The effect used to render through
  49751. */
  49752. protected _internalRender(effect: Effect): void;
  49753. /**
  49754. * Sets the required values for both the emissive texture and and the main color.
  49755. */
  49756. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49757. /**
  49758. * Returns true if the mesh should render, otherwise false.
  49759. * @param mesh The mesh to render
  49760. * @returns true if it should render otherwise false
  49761. */
  49762. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49763. /**
  49764. * Adds specific effects defines.
  49765. * @param defines The defines to add specifics to.
  49766. */
  49767. protected _addCustomEffectDefines(defines: string[]): void;
  49768. /**
  49769. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49770. * @param mesh The mesh to exclude from the glow layer
  49771. */
  49772. addExcludedMesh(mesh: Mesh): void;
  49773. /**
  49774. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49775. * @param mesh The mesh to remove
  49776. */
  49777. removeExcludedMesh(mesh: Mesh): void;
  49778. /**
  49779. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49780. * @param mesh The mesh to include in the glow layer
  49781. */
  49782. addIncludedOnlyMesh(mesh: Mesh): void;
  49783. /**
  49784. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49785. * @param mesh The mesh to remove
  49786. */
  49787. removeIncludedOnlyMesh(mesh: Mesh): void;
  49788. /**
  49789. * Determine if a given mesh will be used in the glow layer
  49790. * @param mesh The mesh to test
  49791. * @returns true if the mesh will be highlighted by the current glow layer
  49792. */
  49793. hasMesh(mesh: AbstractMesh): boolean;
  49794. /**
  49795. * Free any resources and references associated to a mesh.
  49796. * Internal use
  49797. * @param mesh The mesh to free.
  49798. * @hidden
  49799. */
  49800. _disposeMesh(mesh: Mesh): void;
  49801. /**
  49802. * Gets the class name of the effect layer
  49803. * @returns the string with the class name of the effect layer
  49804. */
  49805. getClassName(): string;
  49806. /**
  49807. * Serializes this glow layer
  49808. * @returns a serialized glow layer object
  49809. */
  49810. serialize(): any;
  49811. /**
  49812. * Creates a Glow Layer from parsed glow layer data
  49813. * @param parsedGlowLayer defines glow layer data
  49814. * @param scene defines the current scene
  49815. * @param rootUrl defines the root URL containing the glow layer information
  49816. * @returns a parsed Glow Layer
  49817. */
  49818. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49819. }
  49820. }
  49821. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49822. /** @hidden */
  49823. export var glowBlurPostProcessPixelShader: {
  49824. name: string;
  49825. shader: string;
  49826. };
  49827. }
  49828. declare module "babylonjs/Layers/highlightLayer" {
  49829. import { Observable } from "babylonjs/Misc/observable";
  49830. import { Nullable } from "babylonjs/types";
  49831. import { Camera } from "babylonjs/Cameras/camera";
  49832. import { Scene } from "babylonjs/scene";
  49833. import { Color3, Color4 } from "babylonjs/Maths/math";
  49834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49836. import { Mesh } from "babylonjs/Meshes/mesh";
  49837. import { Effect } from "babylonjs/Materials/effect";
  49838. import { Material } from "babylonjs/Materials/material";
  49839. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49840. import "babylonjs/Shaders/glowMapMerge.fragment";
  49841. import "babylonjs/Shaders/glowMapMerge.vertex";
  49842. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49843. module "babylonjs/abstractScene" {
  49844. interface AbstractScene {
  49845. /**
  49846. * Return a the first highlight layer of the scene with a given name.
  49847. * @param name The name of the highlight layer to look for.
  49848. * @return The highlight layer if found otherwise null.
  49849. */
  49850. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49851. }
  49852. }
  49853. /**
  49854. * Highlight layer options. This helps customizing the behaviour
  49855. * of the highlight layer.
  49856. */
  49857. export interface IHighlightLayerOptions {
  49858. /**
  49859. * Multiplication factor apply to the canvas size to compute the render target size
  49860. * used to generated the glowing objects (the smaller the faster).
  49861. */
  49862. mainTextureRatio: number;
  49863. /**
  49864. * Enforces a fixed size texture to ensure resize independant blur.
  49865. */
  49866. mainTextureFixedSize?: number;
  49867. /**
  49868. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49869. * of the picture to blur (the smaller the faster).
  49870. */
  49871. blurTextureSizeRatio: number;
  49872. /**
  49873. * How big in texel of the blur texture is the vertical blur.
  49874. */
  49875. blurVerticalSize: number;
  49876. /**
  49877. * How big in texel of the blur texture is the horizontal blur.
  49878. */
  49879. blurHorizontalSize: number;
  49880. /**
  49881. * Alpha blending mode used to apply the blur. Default is combine.
  49882. */
  49883. alphaBlendingMode: number;
  49884. /**
  49885. * The camera attached to the layer.
  49886. */
  49887. camera: Nullable<Camera>;
  49888. /**
  49889. * Should we display highlight as a solid stroke?
  49890. */
  49891. isStroke?: boolean;
  49892. /**
  49893. * The rendering group to draw the layer in.
  49894. */
  49895. renderingGroupId: number;
  49896. }
  49897. /**
  49898. * The highlight layer Helps adding a glow effect around a mesh.
  49899. *
  49900. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49901. * glowy meshes to your scene.
  49902. *
  49903. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49904. */
  49905. export class HighlightLayer extends EffectLayer {
  49906. name: string;
  49907. /**
  49908. * Effect Name of the highlight layer.
  49909. */
  49910. static readonly EffectName: string;
  49911. /**
  49912. * The neutral color used during the preparation of the glow effect.
  49913. * This is black by default as the blend operation is a blend operation.
  49914. */
  49915. static NeutralColor: Color4;
  49916. /**
  49917. * Stencil value used for glowing meshes.
  49918. */
  49919. static GlowingMeshStencilReference: number;
  49920. /**
  49921. * Stencil value used for the other meshes in the scene.
  49922. */
  49923. static NormalMeshStencilReference: number;
  49924. /**
  49925. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49926. */
  49927. innerGlow: boolean;
  49928. /**
  49929. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49930. */
  49931. outerGlow: boolean;
  49932. /**
  49933. * Specifies the horizontal size of the blur.
  49934. */
  49935. /**
  49936. * Gets the horizontal size of the blur.
  49937. */
  49938. blurHorizontalSize: number;
  49939. /**
  49940. * Specifies the vertical size of the blur.
  49941. */
  49942. /**
  49943. * Gets the vertical size of the blur.
  49944. */
  49945. blurVerticalSize: number;
  49946. /**
  49947. * An event triggered when the highlight layer is being blurred.
  49948. */
  49949. onBeforeBlurObservable: Observable<HighlightLayer>;
  49950. /**
  49951. * An event triggered when the highlight layer has been blurred.
  49952. */
  49953. onAfterBlurObservable: Observable<HighlightLayer>;
  49954. private _instanceGlowingMeshStencilReference;
  49955. private _options;
  49956. private _downSamplePostprocess;
  49957. private _horizontalBlurPostprocess;
  49958. private _verticalBlurPostprocess;
  49959. private _blurTexture;
  49960. private _meshes;
  49961. private _excludedMeshes;
  49962. /**
  49963. * Instantiates a new highlight Layer and references it to the scene..
  49964. * @param name The name of the layer
  49965. * @param scene The scene to use the layer in
  49966. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49967. */
  49968. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49969. /**
  49970. * Get the effect name of the layer.
  49971. * @return The effect name
  49972. */
  49973. getEffectName(): string;
  49974. /**
  49975. * Create the merge effect. This is the shader use to blit the information back
  49976. * to the main canvas at the end of the scene rendering.
  49977. */
  49978. protected _createMergeEffect(): Effect;
  49979. /**
  49980. * Creates the render target textures and post processes used in the highlight layer.
  49981. */
  49982. protected _createTextureAndPostProcesses(): void;
  49983. /**
  49984. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49985. */
  49986. needStencil(): boolean;
  49987. /**
  49988. * Checks for the readiness of the element composing the layer.
  49989. * @param subMesh the mesh to check for
  49990. * @param useInstances specify wether or not to use instances to render the mesh
  49991. * @param emissiveTexture the associated emissive texture used to generate the glow
  49992. * @return true if ready otherwise, false
  49993. */
  49994. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49995. /**
  49996. * Implementation specific of rendering the generating effect on the main canvas.
  49997. * @param effect The effect used to render through
  49998. */
  49999. protected _internalRender(effect: Effect): void;
  50000. /**
  50001. * Returns true if the layer contains information to display, otherwise false.
  50002. */
  50003. shouldRender(): boolean;
  50004. /**
  50005. * Returns true if the mesh should render, otherwise false.
  50006. * @param mesh The mesh to render
  50007. * @returns true if it should render otherwise false
  50008. */
  50009. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50010. /**
  50011. * Sets the required values for both the emissive texture and and the main color.
  50012. */
  50013. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50014. /**
  50015. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50016. * @param mesh The mesh to exclude from the highlight layer
  50017. */
  50018. addExcludedMesh(mesh: Mesh): void;
  50019. /**
  50020. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50021. * @param mesh The mesh to highlight
  50022. */
  50023. removeExcludedMesh(mesh: Mesh): void;
  50024. /**
  50025. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50026. * @param mesh mesh to test
  50027. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50028. */
  50029. hasMesh(mesh: AbstractMesh): boolean;
  50030. /**
  50031. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50032. * @param mesh The mesh to highlight
  50033. * @param color The color of the highlight
  50034. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50035. */
  50036. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50037. /**
  50038. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50039. * @param mesh The mesh to highlight
  50040. */
  50041. removeMesh(mesh: Mesh): void;
  50042. /**
  50043. * Force the stencil to the normal expected value for none glowing parts
  50044. */
  50045. private _defaultStencilReference;
  50046. /**
  50047. * Free any resources and references associated to a mesh.
  50048. * Internal use
  50049. * @param mesh The mesh to free.
  50050. * @hidden
  50051. */
  50052. _disposeMesh(mesh: Mesh): void;
  50053. /**
  50054. * Dispose the highlight layer and free resources.
  50055. */
  50056. dispose(): void;
  50057. /**
  50058. * Gets the class name of the effect layer
  50059. * @returns the string with the class name of the effect layer
  50060. */
  50061. getClassName(): string;
  50062. /**
  50063. * Serializes this Highlight layer
  50064. * @returns a serialized Highlight layer object
  50065. */
  50066. serialize(): any;
  50067. /**
  50068. * Creates a Highlight layer from parsed Highlight layer data
  50069. * @param parsedHightlightLayer defines the Highlight layer data
  50070. * @param scene defines the current scene
  50071. * @param rootUrl defines the root URL containing the Highlight layer information
  50072. * @returns a parsed Highlight layer
  50073. */
  50074. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50075. }
  50076. }
  50077. declare module "babylonjs/Layers/layerSceneComponent" {
  50078. import { Scene } from "babylonjs/scene";
  50079. import { ISceneComponent } from "babylonjs/sceneComponent";
  50080. import { Layer } from "babylonjs/Layers/layer";
  50081. import { AbstractScene } from "babylonjs/abstractScene";
  50082. module "babylonjs/abstractScene" {
  50083. interface AbstractScene {
  50084. /**
  50085. * The list of layers (background and foreground) of the scene
  50086. */
  50087. layers: Array<Layer>;
  50088. }
  50089. }
  50090. /**
  50091. * Defines the layer scene component responsible to manage any layers
  50092. * in a given scene.
  50093. */
  50094. export class LayerSceneComponent implements ISceneComponent {
  50095. /**
  50096. * The component name helpfull to identify the component in the list of scene components.
  50097. */
  50098. readonly name: string;
  50099. /**
  50100. * The scene the component belongs to.
  50101. */
  50102. scene: Scene;
  50103. private _engine;
  50104. /**
  50105. * Creates a new instance of the component for the given scene
  50106. * @param scene Defines the scene to register the component in
  50107. */
  50108. constructor(scene: Scene);
  50109. /**
  50110. * Registers the component in a given scene
  50111. */
  50112. register(): void;
  50113. /**
  50114. * Rebuilds the elements related to this component in case of
  50115. * context lost for instance.
  50116. */
  50117. rebuild(): void;
  50118. /**
  50119. * Disposes the component and the associated ressources.
  50120. */
  50121. dispose(): void;
  50122. private _draw;
  50123. private _drawCameraPredicate;
  50124. private _drawCameraBackground;
  50125. private _drawCameraForeground;
  50126. private _drawRenderTargetPredicate;
  50127. private _drawRenderTargetBackground;
  50128. private _drawRenderTargetForeground;
  50129. /**
  50130. * Adds all the elements from the container to the scene
  50131. * @param container the container holding the elements
  50132. */
  50133. addFromContainer(container: AbstractScene): void;
  50134. /**
  50135. * Removes all the elements in the container from the scene
  50136. * @param container contains the elements to remove
  50137. * @param dispose if the removed element should be disposed (default: false)
  50138. */
  50139. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50140. }
  50141. }
  50142. declare module "babylonjs/Shaders/layer.fragment" {
  50143. /** @hidden */
  50144. export var layerPixelShader: {
  50145. name: string;
  50146. shader: string;
  50147. };
  50148. }
  50149. declare module "babylonjs/Shaders/layer.vertex" {
  50150. /** @hidden */
  50151. export var layerVertexShader: {
  50152. name: string;
  50153. shader: string;
  50154. };
  50155. }
  50156. declare module "babylonjs/Layers/layer" {
  50157. import { Observable } from "babylonjs/Misc/observable";
  50158. import { Nullable } from "babylonjs/types";
  50159. import { Scene } from "babylonjs/scene";
  50160. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50161. import { Texture } from "babylonjs/Materials/Textures/texture";
  50162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50163. import "babylonjs/Shaders/layer.fragment";
  50164. import "babylonjs/Shaders/layer.vertex";
  50165. /**
  50166. * This represents a full screen 2d layer.
  50167. * This can be useful to display a picture in the background of your scene for instance.
  50168. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50169. */
  50170. export class Layer {
  50171. /**
  50172. * Define the name of the layer.
  50173. */
  50174. name: string;
  50175. /**
  50176. * Define the texture the layer should display.
  50177. */
  50178. texture: Nullable<Texture>;
  50179. /**
  50180. * Is the layer in background or foreground.
  50181. */
  50182. isBackground: boolean;
  50183. /**
  50184. * Define the color of the layer (instead of texture).
  50185. */
  50186. color: Color4;
  50187. /**
  50188. * Define the scale of the layer in order to zoom in out of the texture.
  50189. */
  50190. scale: Vector2;
  50191. /**
  50192. * Define an offset for the layer in order to shift the texture.
  50193. */
  50194. offset: Vector2;
  50195. /**
  50196. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50197. */
  50198. alphaBlendingMode: number;
  50199. /**
  50200. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50201. * Alpha test will not mix with the background color in case of transparency.
  50202. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50203. */
  50204. alphaTest: boolean;
  50205. /**
  50206. * Define a mask to restrict the layer to only some of the scene cameras.
  50207. */
  50208. layerMask: number;
  50209. /**
  50210. * Define the list of render target the layer is visible into.
  50211. */
  50212. renderTargetTextures: RenderTargetTexture[];
  50213. /**
  50214. * Define if the layer is only used in renderTarget or if it also
  50215. * renders in the main frame buffer of the canvas.
  50216. */
  50217. renderOnlyInRenderTargetTextures: boolean;
  50218. private _scene;
  50219. private _vertexBuffers;
  50220. private _indexBuffer;
  50221. private _effect;
  50222. private _alphaTestEffect;
  50223. /**
  50224. * An event triggered when the layer is disposed.
  50225. */
  50226. onDisposeObservable: Observable<Layer>;
  50227. private _onDisposeObserver;
  50228. /**
  50229. * Back compatibility with callback before the onDisposeObservable existed.
  50230. * The set callback will be triggered when the layer has been disposed.
  50231. */
  50232. onDispose: () => void;
  50233. /**
  50234. * An event triggered before rendering the scene
  50235. */
  50236. onBeforeRenderObservable: Observable<Layer>;
  50237. private _onBeforeRenderObserver;
  50238. /**
  50239. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50240. * The set callback will be triggered just before rendering the layer.
  50241. */
  50242. onBeforeRender: () => void;
  50243. /**
  50244. * An event triggered after rendering the scene
  50245. */
  50246. onAfterRenderObservable: Observable<Layer>;
  50247. private _onAfterRenderObserver;
  50248. /**
  50249. * Back compatibility with callback before the onAfterRenderObservable existed.
  50250. * The set callback will be triggered just after rendering the layer.
  50251. */
  50252. onAfterRender: () => void;
  50253. /**
  50254. * Instantiates a new layer.
  50255. * This represents a full screen 2d layer.
  50256. * This can be useful to display a picture in the background of your scene for instance.
  50257. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50258. * @param name Define the name of the layer in the scene
  50259. * @param imgUrl Define the url of the texture to display in the layer
  50260. * @param scene Define the scene the layer belongs to
  50261. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50262. * @param color Defines a color for the layer
  50263. */
  50264. constructor(
  50265. /**
  50266. * Define the name of the layer.
  50267. */
  50268. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50269. private _createIndexBuffer;
  50270. /** @hidden */
  50271. _rebuild(): void;
  50272. /**
  50273. * Renders the layer in the scene.
  50274. */
  50275. render(): void;
  50276. /**
  50277. * Disposes and releases the associated ressources.
  50278. */
  50279. dispose(): void;
  50280. }
  50281. }
  50282. declare module "babylonjs/Layers/index" {
  50283. export * from "babylonjs/Layers/effectLayer";
  50284. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50285. export * from "babylonjs/Layers/glowLayer";
  50286. export * from "babylonjs/Layers/highlightLayer";
  50287. export * from "babylonjs/Layers/layer";
  50288. export * from "babylonjs/Layers/layerSceneComponent";
  50289. }
  50290. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50291. /** @hidden */
  50292. export var lensFlarePixelShader: {
  50293. name: string;
  50294. shader: string;
  50295. };
  50296. }
  50297. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50298. /** @hidden */
  50299. export var lensFlareVertexShader: {
  50300. name: string;
  50301. shader: string;
  50302. };
  50303. }
  50304. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50305. import { Scene } from "babylonjs/scene";
  50306. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50308. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50309. import "babylonjs/Shaders/lensFlare.fragment";
  50310. import "babylonjs/Shaders/lensFlare.vertex";
  50311. /**
  50312. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50313. * It is usually composed of several `lensFlare`.
  50314. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50315. */
  50316. export class LensFlareSystem {
  50317. /**
  50318. * Define the name of the lens flare system
  50319. */
  50320. name: string;
  50321. /**
  50322. * List of lens flares used in this system.
  50323. */
  50324. lensFlares: LensFlare[];
  50325. /**
  50326. * Define a limit from the border the lens flare can be visible.
  50327. */
  50328. borderLimit: number;
  50329. /**
  50330. * Define a viewport border we do not want to see the lens flare in.
  50331. */
  50332. viewportBorder: number;
  50333. /**
  50334. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50335. */
  50336. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50337. /**
  50338. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50339. */
  50340. layerMask: number;
  50341. /**
  50342. * Define the id of the lens flare system in the scene.
  50343. * (equal to name by default)
  50344. */
  50345. id: string;
  50346. private _scene;
  50347. private _emitter;
  50348. private _vertexBuffers;
  50349. private _indexBuffer;
  50350. private _effect;
  50351. private _positionX;
  50352. private _positionY;
  50353. private _isEnabled;
  50354. /** @hidden */
  50355. static _SceneComponentInitialization: (scene: Scene) => void;
  50356. /**
  50357. * Instantiates a lens flare system.
  50358. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50359. * It is usually composed of several `lensFlare`.
  50360. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50361. * @param name Define the name of the lens flare system in the scene
  50362. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50363. * @param scene Define the scene the lens flare system belongs to
  50364. */
  50365. constructor(
  50366. /**
  50367. * Define the name of the lens flare system
  50368. */
  50369. name: string, emitter: any, scene: Scene);
  50370. /**
  50371. * Define if the lens flare system is enabled.
  50372. */
  50373. isEnabled: boolean;
  50374. /**
  50375. * Get the scene the effects belongs to.
  50376. * @returns the scene holding the lens flare system
  50377. */
  50378. getScene(): Scene;
  50379. /**
  50380. * Get the emitter of the lens flare system.
  50381. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50382. * @returns the emitter of the lens flare system
  50383. */
  50384. getEmitter(): any;
  50385. /**
  50386. * Set the emitter of the lens flare system.
  50387. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50388. * @param newEmitter Define the new emitter of the system
  50389. */
  50390. setEmitter(newEmitter: any): void;
  50391. /**
  50392. * Get the lens flare system emitter position.
  50393. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50394. * @returns the position
  50395. */
  50396. getEmitterPosition(): Vector3;
  50397. /**
  50398. * @hidden
  50399. */
  50400. computeEffectivePosition(globalViewport: Viewport): boolean;
  50401. /** @hidden */
  50402. _isVisible(): boolean;
  50403. /**
  50404. * @hidden
  50405. */
  50406. render(): boolean;
  50407. /**
  50408. * Dispose and release the lens flare with its associated resources.
  50409. */
  50410. dispose(): void;
  50411. /**
  50412. * Parse a lens flare system from a JSON repressentation
  50413. * @param parsedLensFlareSystem Define the JSON to parse
  50414. * @param scene Define the scene the parsed system should be instantiated in
  50415. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50416. * @returns the parsed system
  50417. */
  50418. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50419. /**
  50420. * Serialize the current Lens Flare System into a JSON representation.
  50421. * @returns the serialized JSON
  50422. */
  50423. serialize(): any;
  50424. }
  50425. }
  50426. declare module "babylonjs/LensFlares/lensFlare" {
  50427. import { Nullable } from "babylonjs/types";
  50428. import { Color3 } from "babylonjs/Maths/math";
  50429. import { Texture } from "babylonjs/Materials/Textures/texture";
  50430. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50431. /**
  50432. * This represents one of the lens effect in a `lensFlareSystem`.
  50433. * It controls one of the indiviual texture used in the effect.
  50434. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50435. */
  50436. export class LensFlare {
  50437. /**
  50438. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50439. */
  50440. size: number;
  50441. /**
  50442. * 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.
  50443. */
  50444. position: number;
  50445. /**
  50446. * Define the lens color.
  50447. */
  50448. color: Color3;
  50449. /**
  50450. * Define the lens texture.
  50451. */
  50452. texture: Nullable<Texture>;
  50453. /**
  50454. * Define the alpha mode to render this particular lens.
  50455. */
  50456. alphaMode: number;
  50457. private _system;
  50458. /**
  50459. * Creates a new Lens Flare.
  50460. * This represents one of the lens effect in a `lensFlareSystem`.
  50461. * It controls one of the indiviual texture used in the effect.
  50462. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50463. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50464. * @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.
  50465. * @param color Define the lens color
  50466. * @param imgUrl Define the lens texture url
  50467. * @param system Define the `lensFlareSystem` this flare is part of
  50468. * @returns The newly created Lens Flare
  50469. */
  50470. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50471. /**
  50472. * Instantiates a new Lens Flare.
  50473. * This represents one of the lens effect in a `lensFlareSystem`.
  50474. * It controls one of the indiviual texture used in the effect.
  50475. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50476. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50477. * @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.
  50478. * @param color Define the lens color
  50479. * @param imgUrl Define the lens texture url
  50480. * @param system Define the `lensFlareSystem` this flare is part of
  50481. */
  50482. constructor(
  50483. /**
  50484. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50485. */
  50486. size: number,
  50487. /**
  50488. * 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.
  50489. */
  50490. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50491. /**
  50492. * Dispose and release the lens flare with its associated resources.
  50493. */
  50494. dispose(): void;
  50495. }
  50496. }
  50497. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50498. import { Nullable } from "babylonjs/types";
  50499. import { Scene } from "babylonjs/scene";
  50500. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50501. import { AbstractScene } from "babylonjs/abstractScene";
  50502. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50503. module "babylonjs/abstractScene" {
  50504. interface AbstractScene {
  50505. /**
  50506. * The list of lens flare system added to the scene
  50507. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50508. */
  50509. lensFlareSystems: Array<LensFlareSystem>;
  50510. /**
  50511. * Removes the given lens flare system from this scene.
  50512. * @param toRemove The lens flare system to remove
  50513. * @returns The index of the removed lens flare system
  50514. */
  50515. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50516. /**
  50517. * Adds the given lens flare system to this scene
  50518. * @param newLensFlareSystem The lens flare system to add
  50519. */
  50520. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50521. /**
  50522. * Gets a lens flare system using its name
  50523. * @param name defines the name to look for
  50524. * @returns the lens flare system or null if not found
  50525. */
  50526. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50527. /**
  50528. * Gets a lens flare system using its id
  50529. * @param id defines the id to look for
  50530. * @returns the lens flare system or null if not found
  50531. */
  50532. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50533. }
  50534. }
  50535. /**
  50536. * Defines the lens flare scene component responsible to manage any lens flares
  50537. * in a given scene.
  50538. */
  50539. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50540. /**
  50541. * The component name helpfull to identify the component in the list of scene components.
  50542. */
  50543. readonly name: string;
  50544. /**
  50545. * The scene the component belongs to.
  50546. */
  50547. scene: Scene;
  50548. /**
  50549. * Creates a new instance of the component for the given scene
  50550. * @param scene Defines the scene to register the component in
  50551. */
  50552. constructor(scene: Scene);
  50553. /**
  50554. * Registers the component in a given scene
  50555. */
  50556. register(): void;
  50557. /**
  50558. * Rebuilds the elements related to this component in case of
  50559. * context lost for instance.
  50560. */
  50561. rebuild(): void;
  50562. /**
  50563. * Adds all the elements from the container to the scene
  50564. * @param container the container holding the elements
  50565. */
  50566. addFromContainer(container: AbstractScene): void;
  50567. /**
  50568. * Removes all the elements in the container from the scene
  50569. * @param container contains the elements to remove
  50570. * @param dispose if the removed element should be disposed (default: false)
  50571. */
  50572. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50573. /**
  50574. * Serializes the component data to the specified json object
  50575. * @param serializationObject The object to serialize to
  50576. */
  50577. serialize(serializationObject: any): void;
  50578. /**
  50579. * Disposes the component and the associated ressources.
  50580. */
  50581. dispose(): void;
  50582. private _draw;
  50583. }
  50584. }
  50585. declare module "babylonjs/LensFlares/index" {
  50586. export * from "babylonjs/LensFlares/lensFlare";
  50587. export * from "babylonjs/LensFlares/lensFlareSystem";
  50588. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50589. }
  50590. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50591. import { Scene } from "babylonjs/scene";
  50592. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50593. import { AbstractScene } from "babylonjs/abstractScene";
  50594. /**
  50595. * Defines the shadow generator component responsible to manage any shadow generators
  50596. * in a given scene.
  50597. */
  50598. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50599. /**
  50600. * The component name helpfull to identify the component in the list of scene components.
  50601. */
  50602. readonly name: string;
  50603. /**
  50604. * The scene the component belongs to.
  50605. */
  50606. scene: Scene;
  50607. /**
  50608. * Creates a new instance of the component for the given scene
  50609. * @param scene Defines the scene to register the component in
  50610. */
  50611. constructor(scene: Scene);
  50612. /**
  50613. * Registers the component in a given scene
  50614. */
  50615. register(): void;
  50616. /**
  50617. * Rebuilds the elements related to this component in case of
  50618. * context lost for instance.
  50619. */
  50620. rebuild(): void;
  50621. /**
  50622. * Serializes the component data to the specified json object
  50623. * @param serializationObject The object to serialize to
  50624. */
  50625. serialize(serializationObject: any): void;
  50626. /**
  50627. * Adds all the elements from the container to the scene
  50628. * @param container the container holding the elements
  50629. */
  50630. addFromContainer(container: AbstractScene): void;
  50631. /**
  50632. * Removes all the elements in the container from the scene
  50633. * @param container contains the elements to remove
  50634. * @param dispose if the removed element should be disposed (default: false)
  50635. */
  50636. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50637. /**
  50638. * Rebuilds the elements related to this component in case of
  50639. * context lost for instance.
  50640. */
  50641. dispose(): void;
  50642. private _gatherRenderTargets;
  50643. }
  50644. }
  50645. declare module "babylonjs/Lights/Shadows/index" {
  50646. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50647. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50648. }
  50649. declare module "babylonjs/Lights/pointLight" {
  50650. import { Scene } from "babylonjs/scene";
  50651. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50653. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50654. import { Effect } from "babylonjs/Materials/effect";
  50655. /**
  50656. * A point light is a light defined by an unique point in world space.
  50657. * The light is emitted in every direction from this point.
  50658. * A good example of a point light is a standard light bulb.
  50659. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50660. */
  50661. export class PointLight extends ShadowLight {
  50662. private _shadowAngle;
  50663. /**
  50664. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50665. * This specifies what angle the shadow will use to be created.
  50666. *
  50667. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50668. */
  50669. /**
  50670. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50671. * This specifies what angle the shadow will use to be created.
  50672. *
  50673. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50674. */
  50675. shadowAngle: number;
  50676. /**
  50677. * Gets the direction if it has been set.
  50678. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50679. */
  50680. /**
  50681. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50682. */
  50683. direction: Vector3;
  50684. /**
  50685. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50686. * A PointLight emits the light in every direction.
  50687. * It can cast shadows.
  50688. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50689. * ```javascript
  50690. * var pointLight = new PointLight("pl", camera.position, scene);
  50691. * ```
  50692. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50693. * @param name The light friendly name
  50694. * @param position The position of the point light in the scene
  50695. * @param scene The scene the lights belongs to
  50696. */
  50697. constructor(name: string, position: Vector3, scene: Scene);
  50698. /**
  50699. * Returns the string "PointLight"
  50700. * @returns the class name
  50701. */
  50702. getClassName(): string;
  50703. /**
  50704. * Returns the integer 0.
  50705. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50706. */
  50707. getTypeID(): number;
  50708. /**
  50709. * Specifies wether or not the shadowmap should be a cube texture.
  50710. * @returns true if the shadowmap needs to be a cube texture.
  50711. */
  50712. needCube(): boolean;
  50713. /**
  50714. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50715. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50716. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50717. */
  50718. getShadowDirection(faceIndex?: number): Vector3;
  50719. /**
  50720. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50721. * - fov = PI / 2
  50722. * - aspect ratio : 1.0
  50723. * - z-near and far equal to the active camera minZ and maxZ.
  50724. * Returns the PointLight.
  50725. */
  50726. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50727. protected _buildUniformLayout(): void;
  50728. /**
  50729. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50730. * @param effect The effect to update
  50731. * @param lightIndex The index of the light in the effect to update
  50732. * @returns The point light
  50733. */
  50734. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50735. /**
  50736. * Prepares the list of defines specific to the light type.
  50737. * @param defines the list of defines
  50738. * @param lightIndex defines the index of the light for the effect
  50739. */
  50740. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50741. }
  50742. }
  50743. declare module "babylonjs/Lights/index" {
  50744. export * from "babylonjs/Lights/light";
  50745. export * from "babylonjs/Lights/shadowLight";
  50746. export * from "babylonjs/Lights/Shadows/index";
  50747. export * from "babylonjs/Lights/directionalLight";
  50748. export * from "babylonjs/Lights/hemisphericLight";
  50749. export * from "babylonjs/Lights/pointLight";
  50750. export * from "babylonjs/Lights/spotLight";
  50751. }
  50752. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50753. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50754. /**
  50755. * Header information of HDR texture files.
  50756. */
  50757. export interface HDRInfo {
  50758. /**
  50759. * The height of the texture in pixels.
  50760. */
  50761. height: number;
  50762. /**
  50763. * The width of the texture in pixels.
  50764. */
  50765. width: number;
  50766. /**
  50767. * The index of the beginning of the data in the binary file.
  50768. */
  50769. dataPosition: number;
  50770. }
  50771. /**
  50772. * This groups tools to convert HDR texture to native colors array.
  50773. */
  50774. export class HDRTools {
  50775. private static Ldexp;
  50776. private static Rgbe2float;
  50777. private static readStringLine;
  50778. /**
  50779. * Reads header information from an RGBE texture stored in a native array.
  50780. * More information on this format are available here:
  50781. * https://en.wikipedia.org/wiki/RGBE_image_format
  50782. *
  50783. * @param uint8array The binary file stored in native array.
  50784. * @return The header information.
  50785. */
  50786. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50787. /**
  50788. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50789. * This RGBE texture needs to store the information as a panorama.
  50790. *
  50791. * More information on this format are available here:
  50792. * https://en.wikipedia.org/wiki/RGBE_image_format
  50793. *
  50794. * @param buffer The binary file stored in an array buffer.
  50795. * @param size The expected size of the extracted cubemap.
  50796. * @return The Cube Map information.
  50797. */
  50798. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50799. /**
  50800. * Returns the pixels data extracted from an RGBE texture.
  50801. * This pixels will be stored left to right up to down in the R G B order in one array.
  50802. *
  50803. * More information on this format are available here:
  50804. * https://en.wikipedia.org/wiki/RGBE_image_format
  50805. *
  50806. * @param uint8array The binary file stored in an array buffer.
  50807. * @param hdrInfo The header information of the file.
  50808. * @return The pixels data in RGB right to left up to down order.
  50809. */
  50810. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50811. private static RGBE_ReadPixels_RLE;
  50812. }
  50813. }
  50814. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50815. import { Nullable } from "babylonjs/types";
  50816. import { Scene } from "babylonjs/scene";
  50817. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50819. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50820. /**
  50821. * This represents a texture coming from an HDR input.
  50822. *
  50823. * The only supported format is currently panorama picture stored in RGBE format.
  50824. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50825. */
  50826. export class HDRCubeTexture extends BaseTexture {
  50827. private static _facesMapping;
  50828. private _generateHarmonics;
  50829. private _noMipmap;
  50830. private _textureMatrix;
  50831. private _size;
  50832. private _onLoad;
  50833. private _onError;
  50834. /**
  50835. * The texture URL.
  50836. */
  50837. url: string;
  50838. /**
  50839. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50840. */
  50841. coordinatesMode: number;
  50842. protected _isBlocking: boolean;
  50843. /**
  50844. * Sets wether or not the texture is blocking during loading.
  50845. */
  50846. /**
  50847. * Gets wether or not the texture is blocking during loading.
  50848. */
  50849. isBlocking: boolean;
  50850. protected _rotationY: number;
  50851. /**
  50852. * Sets texture matrix rotation angle around Y axis in radians.
  50853. */
  50854. /**
  50855. * Gets texture matrix rotation angle around Y axis radians.
  50856. */
  50857. rotationY: number;
  50858. /**
  50859. * Gets or sets the center of the bounding box associated with the cube texture
  50860. * It must define where the camera used to render the texture was set
  50861. */
  50862. boundingBoxPosition: Vector3;
  50863. private _boundingBoxSize;
  50864. /**
  50865. * Gets or sets the size of the bounding box associated with the cube texture
  50866. * When defined, the cubemap will switch to local mode
  50867. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50868. * @example https://www.babylonjs-playground.com/#RNASML
  50869. */
  50870. boundingBoxSize: Vector3;
  50871. /**
  50872. * Instantiates an HDRTexture from the following parameters.
  50873. *
  50874. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50875. * @param scene The scene the texture will be used in
  50876. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50877. * @param noMipmap Forces to not generate the mipmap if true
  50878. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50879. * @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)
  50880. * @param reserved Reserved flag for internal use.
  50881. */
  50882. 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>);
  50883. /**
  50884. * Get the current class name of the texture useful for serialization or dynamic coding.
  50885. * @returns "HDRCubeTexture"
  50886. */
  50887. getClassName(): string;
  50888. /**
  50889. * Occurs when the file is raw .hdr file.
  50890. */
  50891. private loadTexture;
  50892. clone(): HDRCubeTexture;
  50893. delayLoad(): void;
  50894. /**
  50895. * Get the texture reflection matrix used to rotate/transform the reflection.
  50896. * @returns the reflection matrix
  50897. */
  50898. getReflectionTextureMatrix(): Matrix;
  50899. /**
  50900. * Set the texture reflection matrix used to rotate/transform the reflection.
  50901. * @param value Define the reflection matrix to set
  50902. */
  50903. setReflectionTextureMatrix(value: Matrix): void;
  50904. /**
  50905. * Parses a JSON representation of an HDR Texture in order to create the texture
  50906. * @param parsedTexture Define the JSON representation
  50907. * @param scene Define the scene the texture should be created in
  50908. * @param rootUrl Define the root url in case we need to load relative dependencies
  50909. * @returns the newly created texture after parsing
  50910. */
  50911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50912. serialize(): any;
  50913. }
  50914. }
  50915. declare module "babylonjs/Physics/physicsEngine" {
  50916. import { Nullable } from "babylonjs/types";
  50917. import { Vector3 } from "babylonjs/Maths/math";
  50918. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50919. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50920. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50921. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50922. /**
  50923. * Class used to control physics engine
  50924. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50925. */
  50926. export class PhysicsEngine implements IPhysicsEngine {
  50927. private _physicsPlugin;
  50928. /**
  50929. * Global value used to control the smallest number supported by the simulation
  50930. */
  50931. static Epsilon: number;
  50932. private _impostors;
  50933. private _joints;
  50934. /**
  50935. * Gets the gravity vector used by the simulation
  50936. */
  50937. gravity: Vector3;
  50938. /**
  50939. * Factory used to create the default physics plugin.
  50940. * @returns The default physics plugin
  50941. */
  50942. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50943. /**
  50944. * Creates a new Physics Engine
  50945. * @param gravity defines the gravity vector used by the simulation
  50946. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50947. */
  50948. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50949. /**
  50950. * Sets the gravity vector used by the simulation
  50951. * @param gravity defines the gravity vector to use
  50952. */
  50953. setGravity(gravity: Vector3): void;
  50954. /**
  50955. * Set the time step of the physics engine.
  50956. * Default is 1/60.
  50957. * To slow it down, enter 1/600 for example.
  50958. * To speed it up, 1/30
  50959. * @param newTimeStep defines the new timestep to apply to this world.
  50960. */
  50961. setTimeStep(newTimeStep?: number): void;
  50962. /**
  50963. * Get the time step of the physics engine.
  50964. * @returns the current time step
  50965. */
  50966. getTimeStep(): number;
  50967. /**
  50968. * Release all resources
  50969. */
  50970. dispose(): void;
  50971. /**
  50972. * Gets the name of the current physics plugin
  50973. * @returns the name of the plugin
  50974. */
  50975. getPhysicsPluginName(): string;
  50976. /**
  50977. * Adding a new impostor for the impostor tracking.
  50978. * This will be done by the impostor itself.
  50979. * @param impostor the impostor to add
  50980. */
  50981. addImpostor(impostor: PhysicsImpostor): void;
  50982. /**
  50983. * Remove an impostor from the engine.
  50984. * This impostor and its mesh will not longer be updated by the physics engine.
  50985. * @param impostor the impostor to remove
  50986. */
  50987. removeImpostor(impostor: PhysicsImpostor): void;
  50988. /**
  50989. * Add a joint to the physics engine
  50990. * @param mainImpostor defines the main impostor to which the joint is added.
  50991. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50992. * @param joint defines the joint that will connect both impostors.
  50993. */
  50994. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50995. /**
  50996. * Removes a joint from the simulation
  50997. * @param mainImpostor defines the impostor used with the joint
  50998. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50999. * @param joint defines the joint to remove
  51000. */
  51001. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51002. /**
  51003. * Called by the scene. No need to call it.
  51004. * @param delta defines the timespam between frames
  51005. */
  51006. _step(delta: number): void;
  51007. /**
  51008. * Gets the current plugin used to run the simulation
  51009. * @returns current plugin
  51010. */
  51011. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51012. /**
  51013. * Gets the list of physic impostors
  51014. * @returns an array of PhysicsImpostor
  51015. */
  51016. getImpostors(): Array<PhysicsImpostor>;
  51017. /**
  51018. * Gets the impostor for a physics enabled object
  51019. * @param object defines the object impersonated by the impostor
  51020. * @returns the PhysicsImpostor or null if not found
  51021. */
  51022. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51023. /**
  51024. * Gets the impostor for a physics body object
  51025. * @param body defines physics body used by the impostor
  51026. * @returns the PhysicsImpostor or null if not found
  51027. */
  51028. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51029. /**
  51030. * Does a raycast in the physics world
  51031. * @param from when should the ray start?
  51032. * @param to when should the ray end?
  51033. * @returns PhysicsRaycastResult
  51034. */
  51035. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51036. }
  51037. }
  51038. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51039. import { Nullable } from "babylonjs/types";
  51040. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51042. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51043. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51044. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51045. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51046. /** @hidden */
  51047. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51048. private _useDeltaForWorldStep;
  51049. world: any;
  51050. name: string;
  51051. private _physicsMaterials;
  51052. private _fixedTimeStep;
  51053. private _cannonRaycastResult;
  51054. private _raycastResult;
  51055. private _removeAfterStep;
  51056. BJSCANNON: any;
  51057. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51058. setGravity(gravity: Vector3): void;
  51059. setTimeStep(timeStep: number): void;
  51060. getTimeStep(): number;
  51061. executeStep(delta: number): void;
  51062. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51063. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51064. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51065. private _processChildMeshes;
  51066. removePhysicsBody(impostor: PhysicsImpostor): void;
  51067. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51068. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51069. private _addMaterial;
  51070. private _checkWithEpsilon;
  51071. private _createShape;
  51072. private _createHeightmap;
  51073. private _minus90X;
  51074. private _plus90X;
  51075. private _tmpPosition;
  51076. private _tmpDeltaPosition;
  51077. private _tmpUnityRotation;
  51078. private _updatePhysicsBodyTransformation;
  51079. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51080. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51081. isSupported(): boolean;
  51082. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51083. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51084. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51085. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51086. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51087. getBodyMass(impostor: PhysicsImpostor): number;
  51088. getBodyFriction(impostor: PhysicsImpostor): number;
  51089. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51090. getBodyRestitution(impostor: PhysicsImpostor): number;
  51091. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51092. sleepBody(impostor: PhysicsImpostor): void;
  51093. wakeUpBody(impostor: PhysicsImpostor): void;
  51094. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51095. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51096. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51097. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51098. getRadius(impostor: PhysicsImpostor): number;
  51099. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51100. dispose(): void;
  51101. private _extendNamespace;
  51102. /**
  51103. * Does a raycast in the physics world
  51104. * @param from when should the ray start?
  51105. * @param to when should the ray end?
  51106. * @returns PhysicsRaycastResult
  51107. */
  51108. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51109. }
  51110. }
  51111. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51112. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51113. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51114. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51116. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51117. import { Nullable } from "babylonjs/types";
  51118. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51119. /** @hidden */
  51120. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51121. world: any;
  51122. name: string;
  51123. BJSOIMO: any;
  51124. private _raycastResult;
  51125. constructor(iterations?: number, oimoInjection?: any);
  51126. setGravity(gravity: Vector3): void;
  51127. setTimeStep(timeStep: number): void;
  51128. getTimeStep(): number;
  51129. private _tmpImpostorsArray;
  51130. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51131. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51132. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51133. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51134. private _tmpPositionVector;
  51135. removePhysicsBody(impostor: PhysicsImpostor): void;
  51136. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51137. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51138. isSupported(): boolean;
  51139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51140. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51141. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51142. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51143. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51144. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51146. getBodyMass(impostor: PhysicsImpostor): number;
  51147. getBodyFriction(impostor: PhysicsImpostor): number;
  51148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51149. getBodyRestitution(impostor: PhysicsImpostor): number;
  51150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51151. sleepBody(impostor: PhysicsImpostor): void;
  51152. wakeUpBody(impostor: PhysicsImpostor): void;
  51153. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51154. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51155. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51156. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51157. getRadius(impostor: PhysicsImpostor): number;
  51158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51159. dispose(): void;
  51160. /**
  51161. * Does a raycast in the physics world
  51162. * @param from when should the ray start?
  51163. * @param to when should the ray end?
  51164. * @returns PhysicsRaycastResult
  51165. */
  51166. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51167. }
  51168. }
  51169. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51170. import { Nullable } from "babylonjs/types";
  51171. import { Scene } from "babylonjs/scene";
  51172. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51173. import { Mesh } from "babylonjs/Meshes/mesh";
  51174. /**
  51175. * Class containing static functions to help procedurally build meshes
  51176. */
  51177. export class RibbonBuilder {
  51178. /**
  51179. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51180. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51181. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51182. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51183. * * 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
  51184. * * 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
  51185. * * 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
  51186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51188. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51189. * * 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
  51190. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51191. * * 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
  51192. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51194. * @param name defines the name of the mesh
  51195. * @param options defines the options used to create the mesh
  51196. * @param scene defines the hosting scene
  51197. * @returns the ribbon mesh
  51198. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51199. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51200. */
  51201. static CreateRibbon(name: string, options: {
  51202. pathArray: Vector3[][];
  51203. closeArray?: boolean;
  51204. closePath?: boolean;
  51205. offset?: number;
  51206. updatable?: boolean;
  51207. sideOrientation?: number;
  51208. frontUVs?: Vector4;
  51209. backUVs?: Vector4;
  51210. instance?: Mesh;
  51211. invertUV?: boolean;
  51212. uvs?: Vector2[];
  51213. colors?: Color4[];
  51214. }, scene?: Nullable<Scene>): Mesh;
  51215. }
  51216. }
  51217. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51218. import { Nullable } from "babylonjs/types";
  51219. import { Scene } from "babylonjs/scene";
  51220. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51221. import { Mesh } from "babylonjs/Meshes/mesh";
  51222. /**
  51223. * Class containing static functions to help procedurally build meshes
  51224. */
  51225. export class ShapeBuilder {
  51226. /**
  51227. * 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.
  51228. * * 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.
  51229. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51230. * * 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.
  51231. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51232. * * 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
  51233. * * 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
  51234. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51237. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51239. * @param name defines the name of the mesh
  51240. * @param options defines the options used to create the mesh
  51241. * @param scene defines the hosting scene
  51242. * @returns the extruded shape mesh
  51243. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51245. */
  51246. static ExtrudeShape(name: string, options: {
  51247. shape: Vector3[];
  51248. path: Vector3[];
  51249. scale?: number;
  51250. rotation?: number;
  51251. cap?: number;
  51252. updatable?: boolean;
  51253. sideOrientation?: number;
  51254. frontUVs?: Vector4;
  51255. backUVs?: Vector4;
  51256. instance?: Mesh;
  51257. invertUV?: boolean;
  51258. }, scene?: Nullable<Scene>): Mesh;
  51259. /**
  51260. * Creates an custom extruded shape mesh.
  51261. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51262. * * 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.
  51263. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51264. * * 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
  51265. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51266. * * 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
  51267. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51268. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51269. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51270. * * 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
  51271. * * 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
  51272. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51277. * @param name defines the name of the mesh
  51278. * @param options defines the options used to create the mesh
  51279. * @param scene defines the hosting scene
  51280. * @returns the custom extruded shape mesh
  51281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51282. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51284. */
  51285. static ExtrudeShapeCustom(name: string, options: {
  51286. shape: Vector3[];
  51287. path: Vector3[];
  51288. scaleFunction?: any;
  51289. rotationFunction?: any;
  51290. ribbonCloseArray?: boolean;
  51291. ribbonClosePath?: boolean;
  51292. cap?: number;
  51293. updatable?: boolean;
  51294. sideOrientation?: number;
  51295. frontUVs?: Vector4;
  51296. backUVs?: Vector4;
  51297. instance?: Mesh;
  51298. invertUV?: boolean;
  51299. }, scene?: Nullable<Scene>): Mesh;
  51300. private static _ExtrudeShapeGeneric;
  51301. }
  51302. }
  51303. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51304. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51305. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51306. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51307. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51308. import { Nullable } from "babylonjs/types";
  51309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51310. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51311. /**
  51312. * AmmoJS Physics plugin
  51313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51314. * @see https://github.com/kripken/ammo.js/
  51315. */
  51316. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51317. private _useDeltaForWorldStep;
  51318. /**
  51319. * Reference to the Ammo library
  51320. */
  51321. bjsAMMO: any;
  51322. /**
  51323. * Created ammoJS world which physics bodies are added to
  51324. */
  51325. world: any;
  51326. /**
  51327. * Name of the plugin
  51328. */
  51329. name: string;
  51330. private _timeStep;
  51331. private _fixedTimeStep;
  51332. private _maxSteps;
  51333. private _tmpQuaternion;
  51334. private _tmpAmmoTransform;
  51335. private _tmpAmmoQuaternion;
  51336. private _tmpAmmoConcreteContactResultCallback;
  51337. private _collisionConfiguration;
  51338. private _dispatcher;
  51339. private _overlappingPairCache;
  51340. private _solver;
  51341. private _softBodySolver;
  51342. private _tmpAmmoVectorA;
  51343. private _tmpAmmoVectorB;
  51344. private _tmpAmmoVectorC;
  51345. private _tmpAmmoVectorD;
  51346. private _tmpContactCallbackResult;
  51347. private _tmpAmmoVectorRCA;
  51348. private _tmpAmmoVectorRCB;
  51349. private _raycastResult;
  51350. private static readonly DISABLE_COLLISION_FLAG;
  51351. private static readonly KINEMATIC_FLAG;
  51352. private static readonly DISABLE_DEACTIVATION_FLAG;
  51353. /**
  51354. * Initializes the ammoJS plugin
  51355. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51356. * @param ammoInjection can be used to inject your own ammo reference
  51357. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51358. */
  51359. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51360. /**
  51361. * Sets the gravity of the physics world (m/(s^2))
  51362. * @param gravity Gravity to set
  51363. */
  51364. setGravity(gravity: Vector3): void;
  51365. /**
  51366. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51367. * @param timeStep timestep to use in seconds
  51368. */
  51369. setTimeStep(timeStep: number): void;
  51370. /**
  51371. * 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)
  51372. * @param fixedTimeStep fixedTimeStep to use in seconds
  51373. */
  51374. setFixedTimeStep(fixedTimeStep: number): void;
  51375. /**
  51376. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51377. * @param maxSteps the maximum number of steps by the physics engine per frame
  51378. */
  51379. setMaxSteps(maxSteps: number): void;
  51380. /**
  51381. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51382. * @returns the current timestep in seconds
  51383. */
  51384. getTimeStep(): number;
  51385. private _isImpostorInContact;
  51386. private _isImpostorPairInContact;
  51387. private _stepSimulation;
  51388. /**
  51389. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51390. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51391. * After the step the babylon meshes are set to the position of the physics imposters
  51392. * @param delta amount of time to step forward
  51393. * @param impostors array of imposters to update before/after the step
  51394. */
  51395. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51396. /**
  51397. * Update babylon mesh to match physics world object
  51398. * @param impostor imposter to match
  51399. */
  51400. private _afterSoftStep;
  51401. /**
  51402. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51403. * @param impostor imposter to match
  51404. */
  51405. private _ropeStep;
  51406. /**
  51407. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51408. * @param impostor imposter to match
  51409. */
  51410. private _softbodyOrClothStep;
  51411. private _tmpVector;
  51412. private _tmpMatrix;
  51413. /**
  51414. * Applies an impulse on the imposter
  51415. * @param impostor imposter to apply impulse to
  51416. * @param force amount of force to be applied to the imposter
  51417. * @param contactPoint the location to apply the impulse on the imposter
  51418. */
  51419. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51420. /**
  51421. * Applies a force on the imposter
  51422. * @param impostor imposter to apply force
  51423. * @param force amount of force to be applied to the imposter
  51424. * @param contactPoint the location to apply the force on the imposter
  51425. */
  51426. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51427. /**
  51428. * Creates a physics body using the plugin
  51429. * @param impostor the imposter to create the physics body on
  51430. */
  51431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51432. /**
  51433. * Removes the physics body from the imposter and disposes of the body's memory
  51434. * @param impostor imposter to remove the physics body from
  51435. */
  51436. removePhysicsBody(impostor: PhysicsImpostor): void;
  51437. /**
  51438. * Generates a joint
  51439. * @param impostorJoint the imposter joint to create the joint with
  51440. */
  51441. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51442. /**
  51443. * Removes a joint
  51444. * @param impostorJoint the imposter joint to remove the joint from
  51445. */
  51446. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51447. private _addMeshVerts;
  51448. /**
  51449. * Initialise the soft body vertices to match its object's (mesh) vertices
  51450. * Softbody vertices (nodes) are in world space and to match this
  51451. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51452. * @param impostor to create the softbody for
  51453. */
  51454. private _softVertexData;
  51455. /**
  51456. * Create an impostor's soft body
  51457. * @param impostor to create the softbody for
  51458. */
  51459. private _createSoftbody;
  51460. /**
  51461. * Create cloth for an impostor
  51462. * @param impostor to create the softbody for
  51463. */
  51464. private _createCloth;
  51465. /**
  51466. * Create rope for an impostor
  51467. * @param impostor to create the softbody for
  51468. */
  51469. private _createRope;
  51470. private _addHullVerts;
  51471. private _createShape;
  51472. /**
  51473. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51474. * @param impostor imposter containing the physics body and babylon object
  51475. */
  51476. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51477. /**
  51478. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51479. * @param impostor imposter containing the physics body and babylon object
  51480. * @param newPosition new position
  51481. * @param newRotation new rotation
  51482. */
  51483. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51484. /**
  51485. * If this plugin is supported
  51486. * @returns true if its supported
  51487. */
  51488. isSupported(): boolean;
  51489. /**
  51490. * Sets the linear velocity of the physics body
  51491. * @param impostor imposter to set the velocity on
  51492. * @param velocity velocity to set
  51493. */
  51494. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51495. /**
  51496. * Sets the angular velocity of the physics body
  51497. * @param impostor imposter to set the velocity on
  51498. * @param velocity velocity to set
  51499. */
  51500. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51501. /**
  51502. * gets the linear velocity
  51503. * @param impostor imposter to get linear velocity from
  51504. * @returns linear velocity
  51505. */
  51506. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51507. /**
  51508. * gets the angular velocity
  51509. * @param impostor imposter to get angular velocity from
  51510. * @returns angular velocity
  51511. */
  51512. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51513. /**
  51514. * Sets the mass of physics body
  51515. * @param impostor imposter to set the mass on
  51516. * @param mass mass to set
  51517. */
  51518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51519. /**
  51520. * Gets the mass of the physics body
  51521. * @param impostor imposter to get the mass from
  51522. * @returns mass
  51523. */
  51524. getBodyMass(impostor: PhysicsImpostor): number;
  51525. /**
  51526. * Gets friction of the impostor
  51527. * @param impostor impostor to get friction from
  51528. * @returns friction value
  51529. */
  51530. getBodyFriction(impostor: PhysicsImpostor): number;
  51531. /**
  51532. * Sets friction of the impostor
  51533. * @param impostor impostor to set friction on
  51534. * @param friction friction value
  51535. */
  51536. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51537. /**
  51538. * Gets restitution of the impostor
  51539. * @param impostor impostor to get restitution from
  51540. * @returns restitution value
  51541. */
  51542. getBodyRestitution(impostor: PhysicsImpostor): number;
  51543. /**
  51544. * Sets resitution of the impostor
  51545. * @param impostor impostor to set resitution on
  51546. * @param restitution resitution value
  51547. */
  51548. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51549. /**
  51550. * Gets pressure inside the impostor
  51551. * @param impostor impostor to get pressure from
  51552. * @returns pressure value
  51553. */
  51554. getBodyPressure(impostor: PhysicsImpostor): number;
  51555. /**
  51556. * Sets pressure inside a soft body impostor
  51557. * Cloth and rope must remain 0 pressure
  51558. * @param impostor impostor to set pressure on
  51559. * @param pressure pressure value
  51560. */
  51561. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51562. /**
  51563. * Gets stiffness of the impostor
  51564. * @param impostor impostor to get stiffness from
  51565. * @returns pressure value
  51566. */
  51567. getBodyStiffness(impostor: PhysicsImpostor): number;
  51568. /**
  51569. * Sets stiffness of the impostor
  51570. * @param impostor impostor to set stiffness on
  51571. * @param stiffness stiffness value from 0 to 1
  51572. */
  51573. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51574. /**
  51575. * Gets velocityIterations of the impostor
  51576. * @param impostor impostor to get velocity iterations from
  51577. * @returns velocityIterations value
  51578. */
  51579. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51580. /**
  51581. * Sets velocityIterations of the impostor
  51582. * @param impostor impostor to set velocity iterations on
  51583. * @param velocityIterations velocityIterations value
  51584. */
  51585. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51586. /**
  51587. * Gets positionIterations of the impostor
  51588. * @param impostor impostor to get position iterations from
  51589. * @returns positionIterations value
  51590. */
  51591. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51592. /**
  51593. * Sets positionIterations of the impostor
  51594. * @param impostor impostor to set position on
  51595. * @param positionIterations positionIterations value
  51596. */
  51597. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51598. /**
  51599. * Append an anchor to a cloth object
  51600. * @param impostor is the cloth impostor to add anchor to
  51601. * @param otherImpostor is the rigid impostor to anchor to
  51602. * @param width ratio across width from 0 to 1
  51603. * @param height ratio up height from 0 to 1
  51604. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51605. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51606. */
  51607. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51608. /**
  51609. * Append an hook to a rope object
  51610. * @param impostor is the rope impostor to add hook to
  51611. * @param otherImpostor is the rigid impostor to hook to
  51612. * @param length ratio along the rope from 0 to 1
  51613. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51614. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51615. */
  51616. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51617. /**
  51618. * Sleeps the physics body and stops it from being active
  51619. * @param impostor impostor to sleep
  51620. */
  51621. sleepBody(impostor: PhysicsImpostor): void;
  51622. /**
  51623. * Activates the physics body
  51624. * @param impostor impostor to activate
  51625. */
  51626. wakeUpBody(impostor: PhysicsImpostor): void;
  51627. /**
  51628. * Updates the distance parameters of the joint
  51629. * @param joint joint to update
  51630. * @param maxDistance maximum distance of the joint
  51631. * @param minDistance minimum distance of the joint
  51632. */
  51633. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51634. /**
  51635. * Sets a motor on the joint
  51636. * @param joint joint to set motor on
  51637. * @param speed speed of the motor
  51638. * @param maxForce maximum force of the motor
  51639. * @param motorIndex index of the motor
  51640. */
  51641. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51642. /**
  51643. * Sets the motors limit
  51644. * @param joint joint to set limit on
  51645. * @param upperLimit upper limit
  51646. * @param lowerLimit lower limit
  51647. */
  51648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51649. /**
  51650. * Syncs the position and rotation of a mesh with the impostor
  51651. * @param mesh mesh to sync
  51652. * @param impostor impostor to update the mesh with
  51653. */
  51654. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51655. /**
  51656. * Gets the radius of the impostor
  51657. * @param impostor impostor to get radius from
  51658. * @returns the radius
  51659. */
  51660. getRadius(impostor: PhysicsImpostor): number;
  51661. /**
  51662. * Gets the box size of the impostor
  51663. * @param impostor impostor to get box size from
  51664. * @param result the resulting box size
  51665. */
  51666. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51667. /**
  51668. * Disposes of the impostor
  51669. */
  51670. dispose(): void;
  51671. /**
  51672. * Does a raycast in the physics world
  51673. * @param from when should the ray start?
  51674. * @param to when should the ray end?
  51675. * @returns PhysicsRaycastResult
  51676. */
  51677. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51678. }
  51679. }
  51680. declare module "babylonjs/Probes/reflectionProbe" {
  51681. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51682. import { Vector3 } from "babylonjs/Maths/math";
  51683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51684. import { Nullable } from "babylonjs/types";
  51685. import { Scene } from "babylonjs/scene";
  51686. module "babylonjs/abstractScene" {
  51687. interface AbstractScene {
  51688. /**
  51689. * The list of reflection probes added to the scene
  51690. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51691. */
  51692. reflectionProbes: Array<ReflectionProbe>;
  51693. /**
  51694. * Removes the given reflection probe from this scene.
  51695. * @param toRemove The reflection probe to remove
  51696. * @returns The index of the removed reflection probe
  51697. */
  51698. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51699. /**
  51700. * Adds the given reflection probe to this scene.
  51701. * @param newReflectionProbe The reflection probe to add
  51702. */
  51703. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51704. }
  51705. }
  51706. /**
  51707. * Class used to generate realtime reflection / refraction cube textures
  51708. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51709. */
  51710. export class ReflectionProbe {
  51711. /** defines the name of the probe */
  51712. name: string;
  51713. private _scene;
  51714. private _renderTargetTexture;
  51715. private _projectionMatrix;
  51716. private _viewMatrix;
  51717. private _target;
  51718. private _add;
  51719. private _attachedMesh;
  51720. private _invertYAxis;
  51721. /** Gets or sets probe position (center of the cube map) */
  51722. position: Vector3;
  51723. /**
  51724. * Creates a new reflection probe
  51725. * @param name defines the name of the probe
  51726. * @param size defines the texture resolution (for each face)
  51727. * @param scene defines the hosting scene
  51728. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51729. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51730. */
  51731. constructor(
  51732. /** defines the name of the probe */
  51733. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51734. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51735. samples: number;
  51736. /** Gets or sets the refresh rate to use (on every frame by default) */
  51737. refreshRate: number;
  51738. /**
  51739. * Gets the hosting scene
  51740. * @returns a Scene
  51741. */
  51742. getScene(): Scene;
  51743. /** Gets the internal CubeTexture used to render to */
  51744. readonly cubeTexture: RenderTargetTexture;
  51745. /** Gets the list of meshes to render */
  51746. readonly renderList: Nullable<AbstractMesh[]>;
  51747. /**
  51748. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51749. * @param mesh defines the mesh to attach to
  51750. */
  51751. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51752. /**
  51753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51754. * @param renderingGroupId The rendering group id corresponding to its index
  51755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51756. */
  51757. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51758. /**
  51759. * Clean all associated resources
  51760. */
  51761. dispose(): void;
  51762. /**
  51763. * Converts the reflection probe information to a readable string for debug purpose.
  51764. * @param fullDetails Supports for multiple levels of logging within scene loading
  51765. * @returns the human readable reflection probe info
  51766. */
  51767. toString(fullDetails?: boolean): string;
  51768. /**
  51769. * Get the class name of the relfection probe.
  51770. * @returns "ReflectionProbe"
  51771. */
  51772. getClassName(): string;
  51773. /**
  51774. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51775. * @returns The JSON representation of the texture
  51776. */
  51777. serialize(): any;
  51778. /**
  51779. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51780. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51781. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51782. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51783. * @returns The parsed reflection probe if successful
  51784. */
  51785. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51786. }
  51787. }
  51788. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51789. /** @hidden */
  51790. export var _BabylonLoaderRegistered: boolean;
  51791. }
  51792. declare module "babylonjs/Loading/Plugins/index" {
  51793. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51794. }
  51795. declare module "babylonjs/Loading/index" {
  51796. export * from "babylonjs/Loading/loadingScreen";
  51797. export * from "babylonjs/Loading/Plugins/index";
  51798. export * from "babylonjs/Loading/sceneLoader";
  51799. export * from "babylonjs/Loading/sceneLoaderFlags";
  51800. }
  51801. declare module "babylonjs/Materials/Background/index" {
  51802. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51803. }
  51804. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51805. import { Scene } from "babylonjs/scene";
  51806. import { Color3 } from "babylonjs/Maths/math";
  51807. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51809. /**
  51810. * The Physically based simple base material of BJS.
  51811. *
  51812. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51813. * It is used as the base class for both the specGloss and metalRough conventions.
  51814. */
  51815. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51816. /**
  51817. * Number of Simultaneous lights allowed on the material.
  51818. */
  51819. maxSimultaneousLights: number;
  51820. /**
  51821. * If sets to true, disables all the lights affecting the material.
  51822. */
  51823. disableLighting: boolean;
  51824. /**
  51825. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51826. */
  51827. environmentTexture: BaseTexture;
  51828. /**
  51829. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51830. */
  51831. invertNormalMapX: boolean;
  51832. /**
  51833. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51834. */
  51835. invertNormalMapY: boolean;
  51836. /**
  51837. * Normal map used in the model.
  51838. */
  51839. normalTexture: BaseTexture;
  51840. /**
  51841. * Emissivie color used to self-illuminate the model.
  51842. */
  51843. emissiveColor: Color3;
  51844. /**
  51845. * Emissivie texture used to self-illuminate the model.
  51846. */
  51847. emissiveTexture: BaseTexture;
  51848. /**
  51849. * Occlusion Channel Strenght.
  51850. */
  51851. occlusionStrength: number;
  51852. /**
  51853. * Occlusion Texture of the material (adding extra occlusion effects).
  51854. */
  51855. occlusionTexture: BaseTexture;
  51856. /**
  51857. * Defines the alpha limits in alpha test mode.
  51858. */
  51859. alphaCutOff: number;
  51860. /**
  51861. * Gets the current double sided mode.
  51862. */
  51863. /**
  51864. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51865. */
  51866. doubleSided: boolean;
  51867. /**
  51868. * Stores the pre-calculated light information of a mesh in a texture.
  51869. */
  51870. lightmapTexture: BaseTexture;
  51871. /**
  51872. * If true, the light map contains occlusion information instead of lighting info.
  51873. */
  51874. useLightmapAsShadowmap: boolean;
  51875. /**
  51876. * Instantiates a new PBRMaterial instance.
  51877. *
  51878. * @param name The material name
  51879. * @param scene The scene the material will be use in.
  51880. */
  51881. constructor(name: string, scene: Scene);
  51882. getClassName(): string;
  51883. }
  51884. }
  51885. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51886. import { Scene } from "babylonjs/scene";
  51887. import { Color3 } from "babylonjs/Maths/math";
  51888. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51889. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51890. /**
  51891. * The PBR material of BJS following the metal roughness convention.
  51892. *
  51893. * This fits to the PBR convention in the GLTF definition:
  51894. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51895. */
  51896. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51897. /**
  51898. * The base color has two different interpretations depending on the value of metalness.
  51899. * When the material is a metal, the base color is the specific measured reflectance value
  51900. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51901. * of the material.
  51902. */
  51903. baseColor: Color3;
  51904. /**
  51905. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51906. * well as opacity information in the alpha channel.
  51907. */
  51908. baseTexture: BaseTexture;
  51909. /**
  51910. * Specifies the metallic scalar value of the material.
  51911. * Can also be used to scale the metalness values of the metallic texture.
  51912. */
  51913. metallic: number;
  51914. /**
  51915. * Specifies the roughness scalar value of the material.
  51916. * Can also be used to scale the roughness values of the metallic texture.
  51917. */
  51918. roughness: number;
  51919. /**
  51920. * Texture containing both the metallic value in the B channel and the
  51921. * roughness value in the G channel to keep better precision.
  51922. */
  51923. metallicRoughnessTexture: BaseTexture;
  51924. /**
  51925. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51926. *
  51927. * @param name The material name
  51928. * @param scene The scene the material will be use in.
  51929. */
  51930. constructor(name: string, scene: Scene);
  51931. /**
  51932. * Return the currrent class name of the material.
  51933. */
  51934. getClassName(): string;
  51935. /**
  51936. * Makes a duplicate of the current material.
  51937. * @param name - name to use for the new material.
  51938. */
  51939. clone(name: string): PBRMetallicRoughnessMaterial;
  51940. /**
  51941. * Serialize the material to a parsable JSON object.
  51942. */
  51943. serialize(): any;
  51944. /**
  51945. * Parses a JSON object correponding to the serialize function.
  51946. */
  51947. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51948. }
  51949. }
  51950. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51951. import { Scene } from "babylonjs/scene";
  51952. import { Color3 } from "babylonjs/Maths/math";
  51953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51954. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51955. /**
  51956. * The PBR material of BJS following the specular glossiness convention.
  51957. *
  51958. * This fits to the PBR convention in the GLTF definition:
  51959. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51960. */
  51961. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51962. /**
  51963. * Specifies the diffuse color of the material.
  51964. */
  51965. diffuseColor: Color3;
  51966. /**
  51967. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51968. * channel.
  51969. */
  51970. diffuseTexture: BaseTexture;
  51971. /**
  51972. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51973. */
  51974. specularColor: Color3;
  51975. /**
  51976. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51977. */
  51978. glossiness: number;
  51979. /**
  51980. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51981. */
  51982. specularGlossinessTexture: BaseTexture;
  51983. /**
  51984. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51985. *
  51986. * @param name The material name
  51987. * @param scene The scene the material will be use in.
  51988. */
  51989. constructor(name: string, scene: Scene);
  51990. /**
  51991. * Return the currrent class name of the material.
  51992. */
  51993. getClassName(): string;
  51994. /**
  51995. * Makes a duplicate of the current material.
  51996. * @param name - name to use for the new material.
  51997. */
  51998. clone(name: string): PBRSpecularGlossinessMaterial;
  51999. /**
  52000. * Serialize the material to a parsable JSON object.
  52001. */
  52002. serialize(): any;
  52003. /**
  52004. * Parses a JSON object correponding to the serialize function.
  52005. */
  52006. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52007. }
  52008. }
  52009. declare module "babylonjs/Materials/PBR/index" {
  52010. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52011. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52012. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52013. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52014. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52015. }
  52016. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52017. import { Nullable } from "babylonjs/types";
  52018. import { Scene } from "babylonjs/scene";
  52019. import { Matrix } from "babylonjs/Maths/math";
  52020. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52021. /**
  52022. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52023. * It can help converting any input color in a desired output one. This can then be used to create effects
  52024. * from sepia, black and white to sixties or futuristic rendering...
  52025. *
  52026. * The only supported format is currently 3dl.
  52027. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52028. */
  52029. export class ColorGradingTexture extends BaseTexture {
  52030. /**
  52031. * The current texture matrix. (will always be identity in color grading texture)
  52032. */
  52033. private _textureMatrix;
  52034. /**
  52035. * The texture URL.
  52036. */
  52037. url: string;
  52038. /**
  52039. * Empty line regex stored for GC.
  52040. */
  52041. private static _noneEmptyLineRegex;
  52042. private _engine;
  52043. /**
  52044. * Instantiates a ColorGradingTexture from the following parameters.
  52045. *
  52046. * @param url The location of the color gradind data (currently only supporting 3dl)
  52047. * @param scene The scene the texture will be used in
  52048. */
  52049. constructor(url: string, scene: Scene);
  52050. /**
  52051. * Returns the texture matrix used in most of the material.
  52052. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52053. */
  52054. getTextureMatrix(): Matrix;
  52055. /**
  52056. * Occurs when the file being loaded is a .3dl LUT file.
  52057. */
  52058. private load3dlTexture;
  52059. /**
  52060. * Starts the loading process of the texture.
  52061. */
  52062. private loadTexture;
  52063. /**
  52064. * Clones the color gradind texture.
  52065. */
  52066. clone(): ColorGradingTexture;
  52067. /**
  52068. * Called during delayed load for textures.
  52069. */
  52070. delayLoad(): void;
  52071. /**
  52072. * Parses a color grading texture serialized by Babylon.
  52073. * @param parsedTexture The texture information being parsedTexture
  52074. * @param scene The scene to load the texture in
  52075. * @param rootUrl The root url of the data assets to load
  52076. * @return A color gradind texture
  52077. */
  52078. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52079. /**
  52080. * Serializes the LUT texture to json format.
  52081. */
  52082. serialize(): any;
  52083. }
  52084. }
  52085. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52086. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52087. import { Scene } from "babylonjs/scene";
  52088. import { Nullable } from "babylonjs/types";
  52089. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52090. /**
  52091. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52092. */
  52093. export class EquiRectangularCubeTexture extends BaseTexture {
  52094. /** The six faces of the cube. */
  52095. private static _FacesMapping;
  52096. private _noMipmap;
  52097. private _onLoad;
  52098. private _onError;
  52099. /** The size of the cubemap. */
  52100. private _size;
  52101. /** The buffer of the image. */
  52102. private _buffer;
  52103. /** The width of the input image. */
  52104. private _width;
  52105. /** The height of the input image. */
  52106. private _height;
  52107. /** The URL to the image. */
  52108. url: string;
  52109. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52110. coordinatesMode: number;
  52111. /**
  52112. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52113. * @param url The location of the image
  52114. * @param scene The scene the texture will be used in
  52115. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52116. * @param noMipmap Forces to not generate the mipmap if true
  52117. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52118. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52119. * @param onLoad — defines a callback called when texture is loaded
  52120. * @param onError — defines a callback called if there is an error
  52121. */
  52122. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52123. /**
  52124. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52125. */
  52126. private loadImage;
  52127. /**
  52128. * Convert the image buffer into a cubemap and create a CubeTexture.
  52129. */
  52130. private loadTexture;
  52131. /**
  52132. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52133. * @param buffer The ArrayBuffer that should be converted.
  52134. * @returns The buffer as Float32Array.
  52135. */
  52136. private getFloat32ArrayFromArrayBuffer;
  52137. /**
  52138. * Get the current class name of the texture useful for serialization or dynamic coding.
  52139. * @returns "EquiRectangularCubeTexture"
  52140. */
  52141. getClassName(): string;
  52142. /**
  52143. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52144. * @returns A clone of the current EquiRectangularCubeTexture.
  52145. */
  52146. clone(): EquiRectangularCubeTexture;
  52147. }
  52148. }
  52149. declare module "babylonjs/Misc/tga" {
  52150. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52151. /**
  52152. * Based on jsTGALoader - Javascript loader for TGA file
  52153. * By Vincent Thibault
  52154. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52155. */
  52156. export class TGATools {
  52157. private static _TYPE_INDEXED;
  52158. private static _TYPE_RGB;
  52159. private static _TYPE_GREY;
  52160. private static _TYPE_RLE_INDEXED;
  52161. private static _TYPE_RLE_RGB;
  52162. private static _TYPE_RLE_GREY;
  52163. private static _ORIGIN_MASK;
  52164. private static _ORIGIN_SHIFT;
  52165. private static _ORIGIN_BL;
  52166. private static _ORIGIN_BR;
  52167. private static _ORIGIN_UL;
  52168. private static _ORIGIN_UR;
  52169. /**
  52170. * Gets the header of a TGA file
  52171. * @param data defines the TGA data
  52172. * @returns the header
  52173. */
  52174. static GetTGAHeader(data: Uint8Array): any;
  52175. /**
  52176. * Uploads TGA content to a Babylon Texture
  52177. * @hidden
  52178. */
  52179. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52180. /** @hidden */
  52181. 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;
  52182. /** @hidden */
  52183. 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;
  52184. /** @hidden */
  52185. 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;
  52186. /** @hidden */
  52187. 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;
  52188. /** @hidden */
  52189. 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;
  52190. /** @hidden */
  52191. 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;
  52192. }
  52193. }
  52194. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52195. import { Nullable } from "babylonjs/types";
  52196. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52197. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52198. /**
  52199. * Implementation of the TGA Texture Loader.
  52200. * @hidden
  52201. */
  52202. export class _TGATextureLoader implements IInternalTextureLoader {
  52203. /**
  52204. * Defines wether the loader supports cascade loading the different faces.
  52205. */
  52206. readonly supportCascades: boolean;
  52207. /**
  52208. * This returns if the loader support the current file information.
  52209. * @param extension defines the file extension of the file being loaded
  52210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52211. * @param fallback defines the fallback internal texture if any
  52212. * @param isBase64 defines whether the texture is encoded as a base64
  52213. * @param isBuffer defines whether the texture data are stored as a buffer
  52214. * @returns true if the loader can load the specified file
  52215. */
  52216. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52217. /**
  52218. * Transform the url before loading if required.
  52219. * @param rootUrl the url of the texture
  52220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52221. * @returns the transformed texture
  52222. */
  52223. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52224. /**
  52225. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52226. * @param rootUrl the url of the texture
  52227. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52228. * @returns the fallback texture
  52229. */
  52230. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52231. /**
  52232. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52233. * @param data contains the texture data
  52234. * @param texture defines the BabylonJS internal texture
  52235. * @param createPolynomials will be true if polynomials have been requested
  52236. * @param onLoad defines the callback to trigger once the texture is ready
  52237. * @param onError defines the callback to trigger in case of error
  52238. */
  52239. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52240. /**
  52241. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52242. * @param data contains the texture data
  52243. * @param texture defines the BabylonJS internal texture
  52244. * @param callback defines the method to call once ready to upload
  52245. */
  52246. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52247. }
  52248. }
  52249. declare module "babylonjs/Misc/basis" {
  52250. import { Nullable } from "babylonjs/types";
  52251. import { Engine } from "babylonjs/Engines/engine";
  52252. /**
  52253. * Info about the .basis files
  52254. */
  52255. class BasisFileInfo {
  52256. /**
  52257. * If the file has alpha
  52258. */
  52259. hasAlpha: boolean;
  52260. /**
  52261. * Width of the image
  52262. */
  52263. width: number;
  52264. /**
  52265. * Height of the image
  52266. */
  52267. height: number;
  52268. /**
  52269. * Aligned width used when falling back to Rgb565 ((width + 3) & ~3)
  52270. */
  52271. alignedWidth: number;
  52272. /**
  52273. * Aligned height used when falling back to Rgb565 ((height + 3) & ~3)
  52274. */
  52275. alignedHeight: number;
  52276. }
  52277. /**
  52278. * Used to load .Basis files
  52279. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52280. */
  52281. export class BasisTools {
  52282. private static _IgnoreSupportedFormats;
  52283. private static _LoadScriptPromise;
  52284. private static _FallbackURL;
  52285. private static _BASIS_FORMAT;
  52286. /**
  52287. * Basis module can be aquired from https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52288. * This should be set prior to loading a .basis texture
  52289. */
  52290. static BasisModule: Nullable<any>;
  52291. /**
  52292. * Verifies that the BasisModule has been populated and falls back to loading from the web if not availible
  52293. * @returns promise which will resolve if the basis module was loaded
  52294. */
  52295. static VerifyBasisModuleAsync(): any;
  52296. /**
  52297. * Verifies that the basis module has been populated and creates a bsis file from the image data
  52298. * @param data array buffer of the .basis file
  52299. * @returns the Basis file
  52300. */
  52301. static LoadBasisFile(data: ArrayBuffer): any;
  52302. /**
  52303. * Detects the supported transcode format for the file
  52304. * @param engine Babylon engine
  52305. * @param fileInfo info about the file
  52306. * @returns the chosed format or null if none are supported
  52307. */
  52308. static GetSupportedTranscodeFormat(engine: Engine, fileInfo: BasisFileInfo): Nullable<number>;
  52309. /**
  52310. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52311. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52312. * @returns internal format corresponding to the Basis format
  52313. */
  52314. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52315. /**
  52316. * Retreives information about the basis file eg. dimensions
  52317. * @param basisFile the basis file to get the info from
  52318. * @returns information about the basis file
  52319. */
  52320. static GetFileInfo(basisFile: any): BasisFileInfo;
  52321. /**
  52322. * Transcodes the basis file to the requested format to be transferred to the gpu
  52323. * @param format fromat to be transferred to
  52324. * @param fileInfo information about the loaded file
  52325. * @param loadedFile the loaded basis file
  52326. * @returns the resulting pixels and if the transcode fell back to using Rgb565
  52327. */
  52328. static TranscodeFile(format: Nullable<number>, fileInfo: BasisFileInfo, loadedFile: any): {
  52329. fallbackToRgb565: boolean;
  52330. pixels: Uint8Array;
  52331. };
  52332. /**
  52333. * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js
  52334. * An unoptimized version of dxtToRgb565. Also, the floating
  52335. * point math used to compute the colors actually results in
  52336. * slightly different colors compared to hardware DXT decoders.
  52337. * @param src dxt src pixels
  52338. * @param srcByteOffset offset for the start of src
  52339. * @param width aligned width of the image
  52340. * @param height aligned height of the image
  52341. * @return the converted pixels
  52342. */
  52343. static ConvertDxtToRgb565(src: Uint16Array, srcByteOffset: number, width: number, height: number): Uint16Array;
  52344. }
  52345. }
  52346. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52347. import { Nullable } from "babylonjs/types";
  52348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52349. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52350. /**
  52351. * Loader for .basis file format
  52352. */
  52353. export class _BasisTextureLoader implements IInternalTextureLoader {
  52354. /**
  52355. * Defines whether the loader supports cascade loading the different faces.
  52356. */
  52357. readonly supportCascades: boolean;
  52358. /**
  52359. * This returns if the loader support the current file information.
  52360. * @param extension defines the file extension of the file being loaded
  52361. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52362. * @param fallback defines the fallback internal texture if any
  52363. * @param isBase64 defines whether the texture is encoded as a base64
  52364. * @param isBuffer defines whether the texture data are stored as a buffer
  52365. * @returns true if the loader can load the specified file
  52366. */
  52367. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52368. /**
  52369. * Transform the url before loading if required.
  52370. * @param rootUrl the url of the texture
  52371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52372. * @returns the transformed texture
  52373. */
  52374. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52375. /**
  52376. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52377. * @param rootUrl the url of the texture
  52378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52379. * @returns the fallback texture
  52380. */
  52381. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52382. /**
  52383. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52384. * @param data contains the texture data
  52385. * @param texture defines the BabylonJS internal texture
  52386. * @param createPolynomials will be true if polynomials have been requested
  52387. * @param onLoad defines the callback to trigger once the texture is ready
  52388. * @param onError defines the callback to trigger in case of error
  52389. */
  52390. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52391. /**
  52392. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52393. * @param data contains the texture data
  52394. * @param texture defines the BabylonJS internal texture
  52395. * @param callback defines the method to call once ready to upload
  52396. */
  52397. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52398. }
  52399. }
  52400. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52401. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52402. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52403. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52404. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52405. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52406. }
  52407. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52408. import { Scene } from "babylonjs/scene";
  52409. import { Texture } from "babylonjs/Materials/Textures/texture";
  52410. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52411. /**
  52412. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  52413. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52414. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52415. */
  52416. export class CustomProceduralTexture extends ProceduralTexture {
  52417. private _animate;
  52418. private _time;
  52419. private _config;
  52420. private _texturePath;
  52421. /**
  52422. * Instantiates a new Custom Procedural Texture.
  52423. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  52424. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52425. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52426. * @param name Define the name of the texture
  52427. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52428. * @param size Define the size of the texture to create
  52429. * @param scene Define the scene the texture belongs to
  52430. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52431. * @param generateMipMaps Define if the texture should creates mip maps or not
  52432. */
  52433. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52434. private _loadJson;
  52435. /**
  52436. * Is the texture ready to be used ? (rendered at least once)
  52437. * @returns true if ready, otherwise, false.
  52438. */
  52439. isReady(): boolean;
  52440. /**
  52441. * Render the texture to its associated render target.
  52442. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52443. */
  52444. render(useCameraPostProcess?: boolean): void;
  52445. /**
  52446. * Update the list of dependant textures samplers in the shader.
  52447. */
  52448. updateTextures(): void;
  52449. /**
  52450. * Update the uniform values of the procedural texture in the shader.
  52451. */
  52452. updateShaderUniforms(): void;
  52453. /**
  52454. * Define if the texture animates or not.
  52455. */
  52456. animate: boolean;
  52457. }
  52458. }
  52459. declare module "babylonjs/Shaders/noise.fragment" {
  52460. /** @hidden */
  52461. export var noisePixelShader: {
  52462. name: string;
  52463. shader: string;
  52464. };
  52465. }
  52466. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52467. import { Nullable } from "babylonjs/types";
  52468. import { Scene } from "babylonjs/scene";
  52469. import { Texture } from "babylonjs/Materials/Textures/texture";
  52470. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52471. import "babylonjs/Shaders/noise.fragment";
  52472. /**
  52473. * Class used to generate noise procedural textures
  52474. */
  52475. export class NoiseProceduralTexture extends ProceduralTexture {
  52476. private _time;
  52477. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52478. brightness: number;
  52479. /** Defines the number of octaves to process */
  52480. octaves: number;
  52481. /** Defines the level of persistence (0.8 by default) */
  52482. persistence: number;
  52483. /** Gets or sets animation speed factor (default is 1) */
  52484. animationSpeedFactor: number;
  52485. /**
  52486. * Creates a new NoiseProceduralTexture
  52487. * @param name defines the name fo the texture
  52488. * @param size defines the size of the texture (default is 256)
  52489. * @param scene defines the hosting scene
  52490. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52491. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52492. */
  52493. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52494. private _updateShaderUniforms;
  52495. protected _getDefines(): string;
  52496. /** Generate the current state of the procedural texture */
  52497. render(useCameraPostProcess?: boolean): void;
  52498. /**
  52499. * Serializes this noise procedural texture
  52500. * @returns a serialized noise procedural texture object
  52501. */
  52502. serialize(): any;
  52503. /**
  52504. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52505. * @param parsedTexture defines parsed texture data
  52506. * @param scene defines the current scene
  52507. * @param rootUrl defines the root URL containing noise procedural texture information
  52508. * @returns a parsed NoiseProceduralTexture
  52509. */
  52510. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52511. }
  52512. }
  52513. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52514. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52515. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52516. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52517. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52518. }
  52519. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52520. import { Nullable } from "babylonjs/types";
  52521. import { Scene } from "babylonjs/scene";
  52522. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52524. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52525. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52526. /**
  52527. * Raw cube texture where the raw buffers are passed in
  52528. */
  52529. export class RawCubeTexture extends CubeTexture {
  52530. /**
  52531. * Creates a cube texture where the raw buffers are passed in.
  52532. * @param scene defines the scene the texture is attached to
  52533. * @param data defines the array of data to use to create each face
  52534. * @param size defines the size of the textures
  52535. * @param format defines the format of the data
  52536. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52537. * @param generateMipMaps defines if the engine should generate the mip levels
  52538. * @param invertY defines if data must be stored with Y axis inverted
  52539. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52540. * @param compression defines the compression used (null by default)
  52541. */
  52542. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52543. /**
  52544. * Updates the raw cube texture.
  52545. * @param data defines the data to store
  52546. * @param format defines the data format
  52547. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52548. * @param invertY defines if data must be stored with Y axis inverted
  52549. * @param compression defines the compression used (null by default)
  52550. * @param level defines which level of the texture to update
  52551. */
  52552. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52553. /**
  52554. * Updates a raw cube texture with RGBD encoded data.
  52555. * @param data defines the array of data [mipmap][face] to use to create each face
  52556. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52557. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52558. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52559. * @returns a promsie that resolves when the operation is complete
  52560. */
  52561. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52562. /**
  52563. * Clones the raw cube texture.
  52564. * @return a new cube texture
  52565. */
  52566. clone(): CubeTexture;
  52567. /** @hidden */
  52568. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52569. }
  52570. }
  52571. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52572. import { Scene } from "babylonjs/scene";
  52573. import { Texture } from "babylonjs/Materials/Textures/texture";
  52574. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52575. /**
  52576. * Class used to store 3D textures containing user data
  52577. */
  52578. export class RawTexture3D extends Texture {
  52579. /** Gets or sets the texture format to use */
  52580. format: number;
  52581. private _engine;
  52582. /**
  52583. * Create a new RawTexture3D
  52584. * @param data defines the data of the texture
  52585. * @param width defines the width of the texture
  52586. * @param height defines the height of the texture
  52587. * @param depth defines the depth of the texture
  52588. * @param format defines the texture format to use
  52589. * @param scene defines the hosting scene
  52590. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52591. * @param invertY defines if texture must be stored with Y axis inverted
  52592. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52593. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52594. */
  52595. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52596. /** Gets or sets the texture format to use */
  52597. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52598. /**
  52599. * Update the texture with new data
  52600. * @param data defines the data to store in the texture
  52601. */
  52602. update(data: ArrayBufferView): void;
  52603. }
  52604. }
  52605. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52606. import { Scene } from "babylonjs/scene";
  52607. import { Plane } from "babylonjs/Maths/math";
  52608. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52609. /**
  52610. * Creates a refraction texture used by refraction channel of the standard material.
  52611. * It is like a mirror but to see through a material.
  52612. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52613. */
  52614. export class RefractionTexture extends RenderTargetTexture {
  52615. /**
  52616. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52617. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  52618. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52619. */
  52620. refractionPlane: Plane;
  52621. /**
  52622. * Define how deep under the surface we should see.
  52623. */
  52624. depth: number;
  52625. /**
  52626. * Creates a refraction texture used by refraction channel of the standard material.
  52627. * It is like a mirror but to see through a material.
  52628. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52629. * @param name Define the texture name
  52630. * @param size Define the size of the underlying texture
  52631. * @param scene Define the scene the refraction belongs to
  52632. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52633. */
  52634. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52635. /**
  52636. * Clone the refraction texture.
  52637. * @returns the cloned texture
  52638. */
  52639. clone(): RefractionTexture;
  52640. /**
  52641. * Serialize the texture to a JSON representation you could use in Parse later on
  52642. * @returns the serialized JSON representation
  52643. */
  52644. serialize(): any;
  52645. }
  52646. }
  52647. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52648. import { Nullable } from "babylonjs/types";
  52649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52650. import { Matrix } from "babylonjs/Maths/math";
  52651. import { Engine } from "babylonjs/Engines/engine";
  52652. import { Scene } from "babylonjs/scene";
  52653. /**
  52654. * Defines the options related to the creation of an HtmlElementTexture
  52655. */
  52656. export interface IHtmlElementTextureOptions {
  52657. /**
  52658. * Defines wether mip maps should be created or not.
  52659. */
  52660. generateMipMaps?: boolean;
  52661. /**
  52662. * Defines the sampling mode of the texture.
  52663. */
  52664. samplingMode?: number;
  52665. /**
  52666. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52667. */
  52668. engine: Nullable<Engine>;
  52669. /**
  52670. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52671. */
  52672. scene: Nullable<Scene>;
  52673. }
  52674. /**
  52675. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52676. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52677. * is automatically managed.
  52678. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52679. * in your application.
  52680. *
  52681. * As the update is not automatic, you need to call them manually.
  52682. */
  52683. export class HtmlElementTexture extends BaseTexture {
  52684. /**
  52685. * The texture URL.
  52686. */
  52687. element: HTMLVideoElement | HTMLCanvasElement;
  52688. private static readonly DefaultOptions;
  52689. private _textureMatrix;
  52690. private _engine;
  52691. private _isVideo;
  52692. private _generateMipMaps;
  52693. private _samplingMode;
  52694. /**
  52695. * Instantiates a HtmlElementTexture from the following parameters.
  52696. *
  52697. * @param name Defines the name of the texture
  52698. * @param element Defines the video or canvas the texture is filled with
  52699. * @param options Defines the other none mandatory texture creation options
  52700. */
  52701. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52702. private _createInternalTexture;
  52703. /**
  52704. * Returns the texture matrix used in most of the material.
  52705. */
  52706. getTextureMatrix(): Matrix;
  52707. /**
  52708. * Updates the content of the texture.
  52709. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52710. */
  52711. update(invertY?: Nullable<boolean>): void;
  52712. }
  52713. }
  52714. declare module "babylonjs/Materials/Textures/index" {
  52715. export * from "babylonjs/Materials/Textures/baseTexture";
  52716. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52717. export * from "babylonjs/Materials/Textures/cubeTexture";
  52718. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52719. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52720. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52721. export * from "babylonjs/Materials/Textures/internalTexture";
  52722. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52723. export * from "babylonjs/Materials/Textures/Loaders/index";
  52724. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52725. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52726. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52727. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52728. export * from "babylonjs/Materials/Textures/rawTexture";
  52729. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52730. export * from "babylonjs/Materials/Textures/refractionTexture";
  52731. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52732. export * from "babylonjs/Materials/Textures/texture";
  52733. export * from "babylonjs/Materials/Textures/videoTexture";
  52734. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52735. }
  52736. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52737. /**
  52738. * Enum used to define the target of a block
  52739. */
  52740. export enum NodeMaterialBlockTargets {
  52741. /** Vertex shader */
  52742. Vertex = 1,
  52743. /** Fragment shader */
  52744. Fragment = 2,
  52745. /** Vertex and Fragment */
  52746. VertexAndFragment = 3
  52747. }
  52748. }
  52749. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52750. /**
  52751. * Defines the kind of connection point for node based material
  52752. */
  52753. export enum NodeMaterialBlockConnectionPointTypes {
  52754. /** Float */
  52755. Float = 1,
  52756. /** Int */
  52757. Int = 2,
  52758. /** Vector2 */
  52759. Vector2 = 4,
  52760. /** Vector3 */
  52761. Vector3 = 8,
  52762. /** Vector4 */
  52763. Vector4 = 16,
  52764. /** Color3 */
  52765. Color3 = 32,
  52766. /** Color4 */
  52767. Color4 = 64,
  52768. /** Matrix */
  52769. Matrix = 128,
  52770. /** Texture */
  52771. Texture = 256,
  52772. /** Texture3D */
  52773. Texture3D = 512,
  52774. /** Vector3 or Color3 */
  52775. Vector3OrColor3 = 40,
  52776. /** Vector3 or Vector4 */
  52777. Vector3OrVector4 = 24,
  52778. /** Vector4 or Color4 */
  52779. Vector4OrColor4 = 80,
  52780. /** Color3 or Color4 */
  52781. Color3OrColor4 = 96,
  52782. /** Vector3 or Color3 */
  52783. Vector3OrColor3OrVector4OrColor4 = 120
  52784. }
  52785. }
  52786. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52787. /**
  52788. * Enum used to define well known values e.g. values automatically provided by the system
  52789. */
  52790. export enum NodeMaterialWellKnownValues {
  52791. /** World */
  52792. World = 1,
  52793. /** View */
  52794. View = 2,
  52795. /** Projection */
  52796. Projection = 3,
  52797. /** ViewProjection */
  52798. ViewProjection = 4,
  52799. /** WorldView */
  52800. WorldView = 5,
  52801. /** WorldViewProjection */
  52802. WorldViewProjection = 6,
  52803. /** Will be filled by the block itself */
  52804. Automatic = 7
  52805. }
  52806. }
  52807. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52808. /**
  52809. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52810. */
  52811. export enum NodeMaterialBlockConnectionPointMode {
  52812. /** Value is an uniform */
  52813. Uniform = 0,
  52814. /** Value is a mesh attribute */
  52815. Attribute = 1,
  52816. /** Value is a varying between vertex and fragment shaders */
  52817. Varying = 2,
  52818. /** Mode is undefined */
  52819. Undefined = 3
  52820. }
  52821. }
  52822. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  52823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52825. /**
  52826. * Class used to store shared data between 2 NodeMaterialBuildState
  52827. */
  52828. export class NodeMaterialBuildStateSharedData {
  52829. /**
  52830. * Gets the list of emitted varyings
  52831. */
  52832. varyings: string[];
  52833. /**
  52834. * Gets the varying declaration string
  52835. */
  52836. varyingDeclaration: string;
  52837. /**
  52838. * Uniform connection points
  52839. */
  52840. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  52841. /**
  52842. * Bindable blocks (Blocks that need to set data to the effect)
  52843. */
  52844. bindableBlocks: NodeMaterialBlock[];
  52845. /**
  52846. * List of blocks that can provide a compilation fallback
  52847. */
  52848. blocksWithFallbacks: NodeMaterialBlock[];
  52849. /**
  52850. * List of blocks that can provide a define update
  52851. */
  52852. blocksWithDefines: NodeMaterialBlock[];
  52853. /**
  52854. * List of blocks that can provide a repeatable content
  52855. */
  52856. repeatableContentBlocks: NodeMaterialBlock[];
  52857. /**
  52858. * List of blocks that can block the isReady function for the material
  52859. */
  52860. blockingBlocks: NodeMaterialBlock[];
  52861. /**
  52862. * Build Id used to avoid multiple recompilations
  52863. */
  52864. buildId: number;
  52865. /** List of emitted variables */
  52866. variableNames: {
  52867. [key: string]: number;
  52868. };
  52869. /** List of emitted defines */
  52870. defineNames: {
  52871. [key: string]: number;
  52872. };
  52873. /** Should emit comments? */
  52874. emitComments: boolean;
  52875. /** Emit build activity */
  52876. verbose: boolean;
  52877. /**
  52878. * Gets the compilation hints emitted at compilation time
  52879. */
  52880. hints: {
  52881. needWorldViewMatrix: boolean;
  52882. needWorldViewProjectionMatrix: boolean;
  52883. needAlphaBlending: boolean;
  52884. needAlphaTesting: boolean;
  52885. };
  52886. /**
  52887. * List of compilation checks
  52888. */
  52889. checks: {
  52890. emitVertex: boolean;
  52891. emitFragment: boolean;
  52892. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52893. };
  52894. /** Creates a new shared data */
  52895. constructor();
  52896. /**
  52897. * Emits console errors and exceptions if there is a failing check
  52898. */
  52899. emitErrors(): void;
  52900. }
  52901. }
  52902. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  52903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52904. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52905. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52906. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  52907. /**
  52908. * Class used to store node based material build state
  52909. */
  52910. export class NodeMaterialBuildState {
  52911. /**
  52912. * Gets the list of emitted attributes
  52913. */
  52914. attributes: string[];
  52915. /**
  52916. * Gets the list of emitted uniforms
  52917. */
  52918. uniforms: string[];
  52919. /**
  52920. * Gets the list of emitted samplers
  52921. */
  52922. samplers: string[];
  52923. /**
  52924. * Gets the list of emitted functions
  52925. */
  52926. functions: {
  52927. [key: string]: string;
  52928. };
  52929. /**
  52930. * Gets the target of the compilation state
  52931. */
  52932. target: NodeMaterialBlockTargets;
  52933. /**
  52934. * Shared data between multiple NodeMaterialBuildState instances
  52935. */
  52936. sharedData: NodeMaterialBuildStateSharedData;
  52937. /** @hidden */
  52938. _vertexState: NodeMaterialBuildState;
  52939. private _attributeDeclaration;
  52940. private _uniformDeclaration;
  52941. private _samplerDeclaration;
  52942. private _varyingTransfer;
  52943. private _repeatableContentAnchorIndex;
  52944. /** @hidden */
  52945. _builtCompilationString: string;
  52946. /**
  52947. * Gets the emitted compilation strings
  52948. */
  52949. compilationString: string;
  52950. /**
  52951. * Finalize the compilation strings
  52952. * @param state defines the current compilation state
  52953. */
  52954. finalize(state: NodeMaterialBuildState): void;
  52955. /** @hidden */
  52956. readonly _repeatableContentAnchor: string;
  52957. /** @hidden */
  52958. _getFreeVariableName(prefix: string): string;
  52959. /** @hidden */
  52960. _getFreeDefineName(prefix: string): string;
  52961. /** @hidden */
  52962. _excludeVariableName(name: string): void;
  52963. /** @hidden */
  52964. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52965. /** @hidden */
  52966. _emitFunction(name: string, code: string, comments: string): void;
  52967. /** @hidden */
  52968. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52969. replaceStrings?: {
  52970. search: RegExp;
  52971. replace: string;
  52972. }[];
  52973. }): string;
  52974. /** @hidden */
  52975. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52976. repeatKey?: string;
  52977. removeAttributes?: boolean;
  52978. removeUniforms?: boolean;
  52979. removeVaryings?: boolean;
  52980. removeIfDef?: boolean;
  52981. replaceStrings?: {
  52982. search: RegExp;
  52983. replace: string;
  52984. }[];
  52985. }): void;
  52986. /** @hidden */
  52987. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  52988. private _emitDefine;
  52989. /** @hidden */
  52990. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  52991. }
  52992. }
  52993. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  52994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52995. /**
  52996. * Root class for all node material optimizers
  52997. */
  52998. export class NodeMaterialOptimizer {
  52999. /**
  53000. * Function used to optimize a NodeMaterial graph
  53001. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53002. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53003. */
  53004. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53005. }
  53006. }
  53007. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53010. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53011. /**
  53012. * Block used to transform a vector4 with a matrix
  53013. */
  53014. export class Vector4TransformBlock extends NodeMaterialBlock {
  53015. /**
  53016. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53017. */
  53018. complementW: number;
  53019. /**
  53020. * Creates a new Vector4TransformBlock
  53021. * @param name defines the block name
  53022. */
  53023. constructor(name: string);
  53024. /**
  53025. * Gets the current class name
  53026. * @returns the class name
  53027. */
  53028. getClassName(): string;
  53029. /**
  53030. * Gets the vector input
  53031. */
  53032. readonly vector: NodeMaterialConnectionPoint;
  53033. /**
  53034. * Gets the matrix transform input
  53035. */
  53036. readonly transform: NodeMaterialConnectionPoint;
  53037. protected _buildBlock(state: NodeMaterialBuildState): this;
  53038. }
  53039. }
  53040. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53044. /**
  53045. * Block used to output the vertex position
  53046. */
  53047. export class VertexOutputBlock extends NodeMaterialBlock {
  53048. /**
  53049. * Creates a new VertexOutputBlock
  53050. * @param name defines the block name
  53051. */
  53052. constructor(name: string);
  53053. /**
  53054. * Gets the current class name
  53055. * @returns the class name
  53056. */
  53057. getClassName(): string;
  53058. /**
  53059. * Gets the vector input component
  53060. */
  53061. readonly vector: NodeMaterialConnectionPoint;
  53062. protected _buildBlock(state: NodeMaterialBuildState): this;
  53063. }
  53064. }
  53065. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53069. /**
  53070. * Block used to output the final color
  53071. */
  53072. export class FragmentOutputBlock extends NodeMaterialBlock {
  53073. /**
  53074. * Gets or sets a boolean indicating if this block will output an alpha value
  53075. */
  53076. alphaBlendingEnabled: boolean;
  53077. /**
  53078. * Create a new FragmentOutputBlock
  53079. * @param name defines the block name
  53080. */
  53081. constructor(name: string);
  53082. /**
  53083. * Gets the current class name
  53084. * @returns the class name
  53085. */
  53086. getClassName(): string;
  53087. /**
  53088. * Gets the color input component
  53089. */
  53090. readonly color: NodeMaterialConnectionPoint;
  53091. protected _buildBlock(state: NodeMaterialBuildState): this;
  53092. }
  53093. }
  53094. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53096. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53097. import { Scene } from "babylonjs/scene";
  53098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53099. import { Matrix } from "babylonjs/Maths/math";
  53100. import { Mesh } from "babylonjs/Meshes/mesh";
  53101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53102. import { Observable } from "babylonjs/Misc/observable";
  53103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53104. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53105. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53106. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53107. import { Nullable } from "babylonjs/types";
  53108. /**
  53109. * Interface used to configure the node material editor
  53110. */
  53111. export interface INodeMaterialEditorOptions {
  53112. /** Define the URl to load node editor script */
  53113. editorURL?: string;
  53114. }
  53115. /** @hidden */
  53116. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53117. /** BONES */
  53118. NUM_BONE_INFLUENCERS: number;
  53119. BonesPerMesh: number;
  53120. BONETEXTURE: boolean;
  53121. /** MORPH TARGETS */
  53122. MORPHTARGETS: boolean;
  53123. MORPHTARGETS_NORMAL: boolean;
  53124. MORPHTARGETS_TANGENT: boolean;
  53125. NUM_MORPH_INFLUENCERS: number;
  53126. /** IMAGE PROCESSING */
  53127. IMAGEPROCESSING: boolean;
  53128. VIGNETTE: boolean;
  53129. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53130. VIGNETTEBLENDMODEOPAQUE: boolean;
  53131. TONEMAPPING: boolean;
  53132. TONEMAPPING_ACES: boolean;
  53133. CONTRAST: boolean;
  53134. EXPOSURE: boolean;
  53135. COLORCURVES: boolean;
  53136. COLORGRADING: boolean;
  53137. COLORGRADING3D: boolean;
  53138. SAMPLER3DGREENDEPTH: boolean;
  53139. SAMPLER3DBGRMAP: boolean;
  53140. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53141. constructor();
  53142. setValue(name: string, value: boolean): void;
  53143. }
  53144. /**
  53145. * Class used to configure NodeMaterial
  53146. */
  53147. export interface INodeMaterialOptions {
  53148. /**
  53149. * Defines if blocks should emit comments
  53150. */
  53151. emitComments: boolean;
  53152. }
  53153. /**
  53154. * Class used to create a node based material built by assembling shader blocks
  53155. */
  53156. export class NodeMaterial extends PushMaterial {
  53157. private _options;
  53158. private _vertexCompilationState;
  53159. private _fragmentCompilationState;
  53160. private _sharedData;
  53161. private _buildId;
  53162. private _buildWasSuccessful;
  53163. private _cachedWorldViewMatrix;
  53164. private _cachedWorldViewProjectionMatrix;
  53165. private _textureConnectionPoints;
  53166. private _optimizers;
  53167. /** Define the URl to load node editor script */
  53168. static EditorURL: string;
  53169. private BJSNODEMATERIALEDITOR;
  53170. /** Get the inspector from bundle or global */
  53171. private _getGlobalNodeMaterialEditor;
  53172. /**
  53173. * Defines the maximum number of lights that can be used in the material
  53174. */
  53175. maxSimultaneousLights: number;
  53176. /**
  53177. * Observable raised when the material is built
  53178. */
  53179. onBuildObservable: Observable<NodeMaterial>;
  53180. /**
  53181. * Gets or sets the root nodes of the material vertex shader
  53182. */
  53183. _vertexOutputNodes: NodeMaterialBlock[];
  53184. /**
  53185. * Gets or sets the root nodes of the material fragment (pixel) shader
  53186. */
  53187. _fragmentOutputNodes: NodeMaterialBlock[];
  53188. /** Gets or sets options to control the node material overall behavior */
  53189. options: INodeMaterialOptions;
  53190. /**
  53191. * Default configuration related to image processing available in the standard Material.
  53192. */
  53193. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53194. /**
  53195. * Gets the image processing configuration used either in this material.
  53196. */
  53197. /**
  53198. * Sets the Default image processing configuration used either in the this material.
  53199. *
  53200. * If sets to null, the scene one is in use.
  53201. */
  53202. imageProcessingConfiguration: ImageProcessingConfiguration;
  53203. /**
  53204. * Create a new node based material
  53205. * @param name defines the material name
  53206. * @param scene defines the hosting scene
  53207. * @param options defines creation option
  53208. */
  53209. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53210. /**
  53211. * Gets the current class name of the material e.g. "NodeMaterial"
  53212. * @returns the class name
  53213. */
  53214. getClassName(): string;
  53215. /**
  53216. * Keep track of the image processing observer to allow dispose and replace.
  53217. */
  53218. private _imageProcessingObserver;
  53219. /**
  53220. * Attaches a new image processing configuration to the Standard Material.
  53221. * @param configuration
  53222. */
  53223. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53224. /**
  53225. * Adds a new optimizer to the list of optimizers
  53226. * @param optimizer defines the optimizers to add
  53227. * @returns the current material
  53228. */
  53229. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53230. /**
  53231. * Remove an optimizer from the list of optimizers
  53232. * @param optimizer defines the optimizers to remove
  53233. * @returns the current material
  53234. */
  53235. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53236. /**
  53237. * Add a new block to the list of output nodes
  53238. * @param node defines the node to add
  53239. * @returns the current material
  53240. */
  53241. addOutputNode(node: NodeMaterialBlock): this;
  53242. /**
  53243. * Remove a block from the list of root nodes
  53244. * @param node defines the node to remove
  53245. * @returns the current material
  53246. */
  53247. removeOutputNode(node: NodeMaterialBlock): this;
  53248. private _addVertexOutputNode;
  53249. private _removeVertexOutputNode;
  53250. private _addFragmentOutputNode;
  53251. private _removeFragmentOutputNode;
  53252. /**
  53253. * Specifies if the material will require alpha blending
  53254. * @returns a boolean specifying if alpha blending is needed
  53255. */
  53256. needAlphaBlending(): boolean;
  53257. /**
  53258. * Specifies if this material should be rendered in alpha test mode
  53259. * @returns a boolean specifying if an alpha test is needed.
  53260. */
  53261. needAlphaTesting(): boolean;
  53262. private _initializeBlock;
  53263. private _resetDualBlocks;
  53264. /**
  53265. * Build the material and generates the inner effect
  53266. * @param verbose defines if the build should log activity
  53267. */
  53268. build(verbose?: boolean): void;
  53269. /**
  53270. * Runs an otpimization phase to try to improve the shader code
  53271. */
  53272. optimize(): void;
  53273. private _prepareDefinesForAttributes;
  53274. /**
  53275. * Get if the submesh is ready to be used and all its information available.
  53276. * Child classes can use it to update shaders
  53277. * @param mesh defines the mesh to check
  53278. * @param subMesh defines which submesh to check
  53279. * @param useInstances specifies that instances should be used
  53280. * @returns a boolean indicating that the submesh is ready or not
  53281. */
  53282. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53283. /**
  53284. * Binds the world matrix to the material
  53285. * @param world defines the world transformation matrix
  53286. */
  53287. bindOnlyWorldMatrix(world: Matrix): void;
  53288. /**
  53289. * Binds the submesh to this material by preparing the effect and shader to draw
  53290. * @param world defines the world transformation matrix
  53291. * @param mesh defines the mesh containing the submesh
  53292. * @param subMesh defines the submesh to bind the material to
  53293. */
  53294. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53295. /**
  53296. * Gets the active textures from the material
  53297. * @returns an array of textures
  53298. */
  53299. getActiveTextures(): BaseTexture[];
  53300. /**
  53301. * Specifies if the material uses a texture
  53302. * @param texture defines the texture to check against the material
  53303. * @returns a boolean specifying if the material uses the texture
  53304. */
  53305. hasTexture(texture: BaseTexture): boolean;
  53306. /**
  53307. * Disposes the material
  53308. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53309. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53310. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53311. */
  53312. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53313. /** Creates the node editor window. */
  53314. private _createNodeEditor;
  53315. /**
  53316. * Launch the node material editor
  53317. * @param config Define the configuration of the editor
  53318. * @return a promise fulfilled when the node editor is visible
  53319. */
  53320. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53321. /**
  53322. * Clear the current material
  53323. */
  53324. clear(): void;
  53325. /**
  53326. * Clear the current material and set it to a default state
  53327. */
  53328. setToDefault(): void;
  53329. }
  53330. }
  53331. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53332. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53333. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53334. import { Nullable } from "babylonjs/types";
  53335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53336. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53337. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53339. import { Mesh } from "babylonjs/Meshes/mesh";
  53340. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53341. /**
  53342. * Defines a block that can be used inside a node based material
  53343. */
  53344. export class NodeMaterialBlock {
  53345. private _buildId;
  53346. private _target;
  53347. private _isFinalMerger;
  53348. /** @hidden */
  53349. _inputs: NodeMaterialConnectionPoint[];
  53350. /** @hidden */
  53351. _outputs: NodeMaterialConnectionPoint[];
  53352. /**
  53353. * Gets or sets the name of the block
  53354. */
  53355. name: string;
  53356. /**
  53357. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53358. */
  53359. readonly isFinalMerger: boolean;
  53360. /**
  53361. * Gets or sets the build Id
  53362. */
  53363. buildId: number;
  53364. /**
  53365. * Gets or sets the target of the block
  53366. */
  53367. target: NodeMaterialBlockTargets;
  53368. /**
  53369. * Gets the list of input points
  53370. */
  53371. readonly inputs: NodeMaterialConnectionPoint[];
  53372. /** Gets the list of output points */
  53373. readonly outputs: NodeMaterialConnectionPoint[];
  53374. /**
  53375. * Find an input by its name
  53376. * @param name defines the name of the input to look for
  53377. * @returns the input or null if not found
  53378. */
  53379. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53380. /**
  53381. * Find an output by its name
  53382. * @param name defines the name of the outputto look for
  53383. * @returns the output or null if not found
  53384. */
  53385. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53386. /**
  53387. * Creates a new NodeMaterialBlock
  53388. * @param name defines the block name
  53389. * @param target defines the target of that block (Vertex by default)
  53390. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53391. */
  53392. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53393. /**
  53394. * Initialize the block and prepare the context for build
  53395. * @param state defines the state that will be used for the build
  53396. */
  53397. initialize(state: NodeMaterialBuildState): void;
  53398. /**
  53399. * Bind data to effect. Will only be called for blocks with isBindable === true
  53400. * @param effect defines the effect to bind data to
  53401. * @param nodeMaterial defines the hosting NodeMaterial
  53402. * @param mesh defines the mesh that will be rendered
  53403. */
  53404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53405. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53406. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53407. protected _writeFloat(value: number): string;
  53408. /**
  53409. * Gets the current class name e.g. "NodeMaterialBlock"
  53410. * @returns the class name
  53411. */
  53412. getClassName(): string;
  53413. /**
  53414. * Register a new input. Must be called inside a block constructor
  53415. * @param name defines the connection point name
  53416. * @param type defines the connection point type
  53417. * @param isOptional defines a boolean indicating that this input can be omitted
  53418. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53419. * @returns the current block
  53420. */
  53421. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53422. /**
  53423. * Register a new output. Must be called inside a block constructor
  53424. * @param name defines the connection point name
  53425. * @param type defines the connection point type
  53426. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53427. * @returns the current block
  53428. */
  53429. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53430. /**
  53431. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53432. * @param forOutput defines an optional connection point to check compatibility with
  53433. * @returns the first available input or null
  53434. */
  53435. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53436. /**
  53437. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53438. * @param forBlock defines an optional block to check compatibility with
  53439. * @returns the first available input or null
  53440. */
  53441. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53442. /**
  53443. * Connect current block with another block
  53444. * @param other defines the block to connect with
  53445. * @param options define the various options to help pick the right connections
  53446. * @returns the current block
  53447. */
  53448. connectTo(other: NodeMaterialBlock, options?: {
  53449. input?: string;
  53450. output?: string;
  53451. outputSwizzle?: string;
  53452. }): this | undefined;
  53453. protected _buildBlock(state: NodeMaterialBuildState): void;
  53454. /**
  53455. * Add potential fallbacks if shader compilation fails
  53456. * @param mesh defines the mesh to be rendered
  53457. * @param fallbacks defines the current prioritized list of fallbacks
  53458. */
  53459. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53460. /**
  53461. * Update defines for shader compilation
  53462. * @param mesh defines the mesh to be rendered
  53463. * @param nodeMaterial defines the node material requesting the update
  53464. * @param defines defines the material defines to update
  53465. * @param useInstances specifies that instances should be used
  53466. */
  53467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53468. /**
  53469. * Lets the block try to connect some inputs automatically
  53470. */
  53471. autoConfigure(): void;
  53472. /**
  53473. * Function called when a block is declared as repeatable content generator
  53474. * @param vertexShaderState defines the current compilation state for the vertex shader
  53475. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53476. * @param mesh defines the mesh to be rendered
  53477. * @param defines defines the material defines to update
  53478. */
  53479. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53480. /**
  53481. * Checks if the block is ready
  53482. * @param mesh defines the mesh to be rendered
  53483. * @param nodeMaterial defines the node material requesting the update
  53484. * @param defines defines the material defines to update
  53485. * @param useInstances specifies that instances should be used
  53486. * @returns true if the block is ready
  53487. */
  53488. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53489. /**
  53490. * Compile the current node and generate the shader code
  53491. * @param state defines the current compilation state (uniforms, samplers, current string)
  53492. * @returns the current block
  53493. */
  53494. build(state: NodeMaterialBuildState): this | undefined;
  53495. }
  53496. }
  53497. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53498. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53499. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53500. import { Nullable } from "babylonjs/types";
  53501. import { Effect } from "babylonjs/Materials/effect";
  53502. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53503. import { Scene } from "babylonjs/scene";
  53504. import { Matrix } from "babylonjs/Maths/math";
  53505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53506. /**
  53507. * Defines a connection point for a block
  53508. */
  53509. export class NodeMaterialConnectionPoint {
  53510. /** @hidden */
  53511. _ownerBlock: NodeMaterialBlock;
  53512. /** @hidden */
  53513. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53514. private _associatedVariableName;
  53515. private _endpoints;
  53516. private _storedValue;
  53517. private _valueCallback;
  53518. private _mode;
  53519. /** @hidden */
  53520. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53521. /** @hidden */
  53522. _needToEmitVarying: boolean;
  53523. /**
  53524. * Gets or sets the connection point type (default is float)
  53525. */
  53526. type: NodeMaterialBlockConnectionPointTypes;
  53527. /**
  53528. * Gets or sets the connection point name
  53529. */
  53530. name: string;
  53531. /**
  53532. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53533. */
  53534. swizzle: string;
  53535. /**
  53536. * Gets or sets a boolean indicating that this connection point can be omitted
  53537. */
  53538. isOptional: boolean;
  53539. /**
  53540. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53541. */
  53542. define: string;
  53543. /** Gets or sets the target of that connection point */
  53544. target: NodeMaterialBlockTargets;
  53545. /**
  53546. * Gets or sets the value of that point.
  53547. * Please note that this value will be ignored if valueCallback is defined
  53548. */
  53549. value: any;
  53550. /**
  53551. * Gets or sets a callback used to get the value of that point.
  53552. * Please note that setting this value will force the connection point to ignore the value property
  53553. */
  53554. valueCallback: () => any;
  53555. /**
  53556. * Gets or sets the associated variable name in the shader
  53557. */
  53558. associatedVariableName: string;
  53559. /**
  53560. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53561. * In this case the connection point name must be the name of the uniform to use.
  53562. * Can only be set on inputs
  53563. */
  53564. isUniform: boolean;
  53565. /**
  53566. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53567. * In this case the connection point name must be the name of the attribute to use
  53568. * Can only be set on inputs
  53569. */
  53570. isAttribute: boolean;
  53571. /**
  53572. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53573. * Can only be set on exit points
  53574. */
  53575. isVarying: boolean;
  53576. /** Get the other side of the connection (if any) */
  53577. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53578. /** Get the block that owns this connection point */
  53579. readonly ownerBlock: NodeMaterialBlock;
  53580. /** Get the block connected on the other side of this connection (if any) */
  53581. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53582. /** Get the block connected on the endpoints of this connection (if any) */
  53583. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53584. /**
  53585. * Creates a new connection point
  53586. * @param name defines the connection point name
  53587. * @param ownerBlock defines the block hosting this connection point
  53588. */
  53589. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53590. /**
  53591. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53592. * @returns the class name
  53593. */
  53594. getClassName(): string;
  53595. /**
  53596. * Set the source of this connection point to a vertex attribute
  53597. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53598. * @returns the current connection point
  53599. */
  53600. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53601. /**
  53602. * Set the source of this connection point to a well known value
  53603. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53604. * @returns the current connection point
  53605. */
  53606. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53607. /**
  53608. * Gets a boolean indicating that the current connection point is a well known value
  53609. */
  53610. readonly isWellKnownValue: boolean;
  53611. /**
  53612. * Gets or sets the current well known value or null if not defined as well know value
  53613. */
  53614. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53615. private _getTypeLength;
  53616. /**
  53617. * Connect this point to another connection point
  53618. * @param connectionPoint defines the other connection point
  53619. * @returns the current connection point
  53620. */
  53621. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53622. /**
  53623. * Disconnect this point from one of his endpoint
  53624. * @param endpoint defines the other connection point
  53625. * @returns the current connection point
  53626. */
  53627. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53628. /**
  53629. * When connection point is an uniform, this function will send its value to the effect
  53630. * @param effect defines the effect to transmit value to
  53631. * @param world defines the world matrix
  53632. * @param worldView defines the worldxview matrix
  53633. * @param worldViewProjection defines the worldxviewxprojection matrix
  53634. */
  53635. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53636. /**
  53637. * When connection point is an uniform, this function will send its value to the effect
  53638. * @param effect defines the effect to transmit value to
  53639. * @param scene defines the hosting scene
  53640. */
  53641. transmit(effect: Effect, scene: Scene): void;
  53642. }
  53643. }
  53644. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53648. import { Mesh } from "babylonjs/Meshes/mesh";
  53649. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53651. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53652. /**
  53653. * Block used to add support for vertex skinning (bones)
  53654. */
  53655. export class BonesBlock extends NodeMaterialBlock {
  53656. /**
  53657. * Creates a new BonesBlock
  53658. * @param name defines the block name
  53659. */
  53660. constructor(name: string);
  53661. /**
  53662. * Initialize the block and prepare the context for build
  53663. * @param state defines the state that will be used for the build
  53664. */
  53665. initialize(state: NodeMaterialBuildState): void;
  53666. /**
  53667. * Gets the current class name
  53668. * @returns the class name
  53669. */
  53670. getClassName(): string;
  53671. /**
  53672. * Gets the matrix indices input component
  53673. */
  53674. readonly matricesIndices: NodeMaterialConnectionPoint;
  53675. /**
  53676. * Gets the matrix weights input component
  53677. */
  53678. readonly matricesWeights: NodeMaterialConnectionPoint;
  53679. /**
  53680. * Gets the extra matrix indices input component
  53681. */
  53682. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53683. /**
  53684. * Gets the extra matrix weights input component
  53685. */
  53686. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53687. /**
  53688. * Gets the world input component
  53689. */
  53690. readonly world: NodeMaterialConnectionPoint;
  53691. autoConfigure(): void;
  53692. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53693. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53695. protected _buildBlock(state: NodeMaterialBuildState): this;
  53696. }
  53697. }
  53698. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53700. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53703. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53704. /**
  53705. * Block used to add support for instances
  53706. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53707. */
  53708. export class InstancesBlock extends NodeMaterialBlock {
  53709. /**
  53710. * Creates a new InstancesBlock
  53711. * @param name defines the block name
  53712. */
  53713. constructor(name: string);
  53714. /**
  53715. * Gets the current class name
  53716. * @returns the class name
  53717. */
  53718. getClassName(): string;
  53719. /**
  53720. * Gets the first world row input component
  53721. */
  53722. readonly world0: NodeMaterialConnectionPoint;
  53723. /**
  53724. * Gets the second world row input component
  53725. */
  53726. readonly world1: NodeMaterialConnectionPoint;
  53727. /**
  53728. * Gets the third world row input component
  53729. */
  53730. readonly world2: NodeMaterialConnectionPoint;
  53731. /**
  53732. * Gets the forth world row input component
  53733. */
  53734. readonly world3: NodeMaterialConnectionPoint;
  53735. /**
  53736. * Gets the world input component
  53737. */
  53738. readonly world: NodeMaterialConnectionPoint;
  53739. /**
  53740. * Gets the output component
  53741. */
  53742. readonly output: NodeMaterialConnectionPoint;
  53743. autoConfigure(): void;
  53744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53745. protected _buildBlock(state: NodeMaterialBuildState): this;
  53746. }
  53747. }
  53748. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53753. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53754. import { Effect } from "babylonjs/Materials/effect";
  53755. import { Mesh } from "babylonjs/Meshes/mesh";
  53756. /**
  53757. * Block used to add morph targets support to vertex shader
  53758. */
  53759. export class MorphTargetsBlock extends NodeMaterialBlock {
  53760. private _repeatableContentAnchor;
  53761. private _repeatebleContentGenerated;
  53762. /**
  53763. * Create a new MorphTargetsBlock
  53764. * @param name defines the block name
  53765. */
  53766. constructor(name: string);
  53767. /**
  53768. * Gets the current class name
  53769. * @returns the class name
  53770. */
  53771. getClassName(): string;
  53772. /**
  53773. * Gets the position input component
  53774. */
  53775. readonly position: NodeMaterialConnectionPoint;
  53776. /**
  53777. * Gets the normal input component
  53778. */
  53779. readonly normal: NodeMaterialConnectionPoint;
  53780. /**
  53781. * Gets the tangent input component
  53782. */
  53783. readonly tangent: NodeMaterialConnectionPoint;
  53784. /**
  53785. * Gets the position output component
  53786. */
  53787. readonly positionOutput: NodeMaterialConnectionPoint;
  53788. /**
  53789. * Gets the normal output component
  53790. */
  53791. readonly normalOutput: NodeMaterialConnectionPoint;
  53792. /**
  53793. * Gets the tangent output component
  53794. */
  53795. readonly tangentOutput: NodeMaterialConnectionPoint;
  53796. initialize(state: NodeMaterialBuildState): void;
  53797. autoConfigure(): void;
  53798. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53800. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53801. protected _buildBlock(state: NodeMaterialBuildState): this;
  53802. }
  53803. }
  53804. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  53805. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  53806. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  53807. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  53808. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  53809. }
  53810. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  53811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53814. /**
  53815. * Block used to add an alpha test in the fragment shader
  53816. */
  53817. export class AlphaTestBlock extends NodeMaterialBlock {
  53818. /**
  53819. * Gets or sets the alpha value where alpha testing happens
  53820. */
  53821. alphaCutOff: number;
  53822. /**
  53823. * Create a new AlphaTestBlock
  53824. * @param name defines the block name
  53825. */
  53826. constructor(name: string);
  53827. /**
  53828. * Gets the current class name
  53829. * @returns the class name
  53830. */
  53831. getClassName(): string;
  53832. /**
  53833. * Gets the color input component
  53834. */
  53835. readonly color: NodeMaterialConnectionPoint;
  53836. protected _buildBlock(state: NodeMaterialBuildState): this;
  53837. }
  53838. }
  53839. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  53840. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53843. /**
  53844. * Block used to create a Color4 out of 4 inputs (one for each component)
  53845. */
  53846. export class RGBAMergerBlock extends NodeMaterialBlock {
  53847. /**
  53848. * Create a new RGBAMergerBlock
  53849. * @param name defines the block name
  53850. */
  53851. constructor(name: string);
  53852. /**
  53853. * Gets the current class name
  53854. * @returns the class name
  53855. */
  53856. getClassName(): string;
  53857. /**
  53858. * Gets the R input component
  53859. */
  53860. readonly r: NodeMaterialConnectionPoint;
  53861. /**
  53862. * Gets the G input component
  53863. */
  53864. readonly g: NodeMaterialConnectionPoint;
  53865. /**
  53866. * Gets the B input component
  53867. */
  53868. readonly b: NodeMaterialConnectionPoint;
  53869. /**
  53870. * Gets the RGB input component
  53871. */
  53872. readonly rgb: NodeMaterialConnectionPoint;
  53873. /**
  53874. * Gets the R input component
  53875. */
  53876. readonly a: NodeMaterialConnectionPoint;
  53877. protected _buildBlock(state: NodeMaterialBuildState): this;
  53878. }
  53879. }
  53880. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  53881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53884. /**
  53885. * Block used to create a Color3 out of 3 inputs (one for each component)
  53886. */
  53887. export class RGBMergerBlock extends NodeMaterialBlock {
  53888. /**
  53889. * Create a new RGBMergerBlock
  53890. * @param name defines the block name
  53891. */
  53892. constructor(name: string);
  53893. /**
  53894. * Gets the current class name
  53895. * @returns the class name
  53896. */
  53897. getClassName(): string;
  53898. /**
  53899. * Gets the R component input
  53900. */
  53901. readonly r: NodeMaterialConnectionPoint;
  53902. /**
  53903. * Gets the G component input
  53904. */
  53905. readonly g: NodeMaterialConnectionPoint;
  53906. /**
  53907. * Gets the B component input
  53908. */
  53909. readonly b: NodeMaterialConnectionPoint;
  53910. protected _buildBlock(state: NodeMaterialBuildState): this;
  53911. }
  53912. }
  53913. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  53914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53917. /**
  53918. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  53919. */
  53920. export class RGBASplitterBlock extends NodeMaterialBlock {
  53921. /**
  53922. * Create a new RGBASplitterBlock
  53923. * @param name defines the block name
  53924. */
  53925. constructor(name: string);
  53926. /**
  53927. * Gets the current class name
  53928. * @returns the class name
  53929. */
  53930. getClassName(): string;
  53931. /**
  53932. * Gets the input component
  53933. */
  53934. readonly input: NodeMaterialConnectionPoint;
  53935. protected _buildBlock(state: NodeMaterialBuildState): this;
  53936. }
  53937. }
  53938. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  53939. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53940. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53941. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53942. /**
  53943. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  53944. */
  53945. export class RGBSplitterBlock extends NodeMaterialBlock {
  53946. /**
  53947. * Create a new RGBSplitterBlock
  53948. * @param name defines the block name
  53949. */
  53950. constructor(name: string);
  53951. /**
  53952. * Gets the current class name
  53953. * @returns the class name
  53954. */
  53955. getClassName(): string;
  53956. /**
  53957. * Gets the input component
  53958. */
  53959. readonly input: NodeMaterialConnectionPoint;
  53960. protected _buildBlock(state: NodeMaterialBuildState): this;
  53961. }
  53962. }
  53963. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53968. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53969. /**
  53970. * Block used to read a texture from a sampler
  53971. */
  53972. export class TextureBlock extends NodeMaterialBlock {
  53973. private _defineName;
  53974. /**
  53975. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  53976. */
  53977. autoConnectTextureMatrix: boolean;
  53978. /**
  53979. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  53980. */
  53981. autoSelectUV: boolean;
  53982. /**
  53983. * Create a new TextureBlock
  53984. * @param name defines the block name
  53985. */
  53986. constructor(name: string);
  53987. /**
  53988. * Gets the current class name
  53989. * @returns the class name
  53990. */
  53991. getClassName(): string;
  53992. /**
  53993. * Gets the uv input component
  53994. */
  53995. readonly uv: NodeMaterialConnectionPoint;
  53996. /**
  53997. * Gets the texture information input component
  53998. */
  53999. readonly textureInfo: NodeMaterialConnectionPoint;
  54000. /**
  54001. * Gets the transformed uv input component
  54002. */
  54003. readonly transformedUV: NodeMaterialConnectionPoint;
  54004. /**
  54005. * Gets the texture input component
  54006. */
  54007. readonly texture: NodeMaterialConnectionPoint;
  54008. /**
  54009. * Gets the texture transform input component
  54010. */
  54011. readonly textureTransform: NodeMaterialConnectionPoint;
  54012. autoConfigure(): void;
  54013. initialize(state: NodeMaterialBuildState): void;
  54014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54015. isReady(): boolean;
  54016. private _injectVertexCode;
  54017. protected _buildBlock(state: NodeMaterialBuildState): this;
  54018. }
  54019. }
  54020. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54025. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54026. import { Effect } from "babylonjs/Materials/effect";
  54027. import { Mesh } from "babylonjs/Meshes/mesh";
  54028. /**
  54029. * Block used to add image processing support to fragment shader
  54030. */
  54031. export class ImageProcessingBlock extends NodeMaterialBlock {
  54032. /**
  54033. * Create a new ImageProcessingBlock
  54034. * @param name defines the block name
  54035. */
  54036. constructor(name: string);
  54037. /**
  54038. * Gets the current class name
  54039. * @returns the class name
  54040. */
  54041. getClassName(): string;
  54042. /**
  54043. * Gets the color input component
  54044. */
  54045. readonly color: NodeMaterialConnectionPoint;
  54046. /**
  54047. * Initialize the block and prepare the context for build
  54048. * @param state defines the state that will be used for the build
  54049. */
  54050. initialize(state: NodeMaterialBuildState): void;
  54051. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54052. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54053. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54054. protected _buildBlock(state: NodeMaterialBuildState): this;
  54055. }
  54056. }
  54057. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54058. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54059. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54060. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54061. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54062. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54063. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54064. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54065. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54066. }
  54067. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54070. import { Mesh } from "babylonjs/Meshes/mesh";
  54071. import { Effect } from "babylonjs/Materials/effect";
  54072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54074. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54075. /**
  54076. * Block used to add support for scene fog
  54077. */
  54078. export class FogBlock extends NodeMaterialBlock {
  54079. /**
  54080. * Create a new FogBlock
  54081. * @param name defines the block name
  54082. */
  54083. constructor(name: string);
  54084. /**
  54085. * Gets the current class name
  54086. * @returns the class name
  54087. */
  54088. getClassName(): string;
  54089. /**
  54090. * Gets the world position input component
  54091. */
  54092. readonly worldPosition: NodeMaterialConnectionPoint;
  54093. /**
  54094. * Gets the view input component
  54095. */
  54096. readonly view: NodeMaterialConnectionPoint;
  54097. /**
  54098. * Gets the color input component
  54099. */
  54100. readonly color: NodeMaterialConnectionPoint;
  54101. /**
  54102. * Gets the fog color input component
  54103. */
  54104. readonly fogColor: NodeMaterialConnectionPoint;
  54105. /**
  54106. * Gets the for parameter input component
  54107. */
  54108. readonly fogParameters: NodeMaterialConnectionPoint;
  54109. autoConfigure(): void;
  54110. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54111. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54112. protected _buildBlock(state: NodeMaterialBuildState): this;
  54113. }
  54114. }
  54115. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54116. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54117. }
  54118. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54122. /**
  54123. * Block used to multiply 2 vector4
  54124. */
  54125. export class MultiplyBlock extends NodeMaterialBlock {
  54126. /**
  54127. * Creates a new MultiplyBlock
  54128. * @param name defines the block name
  54129. */
  54130. constructor(name: string);
  54131. /**
  54132. * Gets the current class name
  54133. * @returns the class name
  54134. */
  54135. getClassName(): string;
  54136. /**
  54137. * Gets the left operand input component
  54138. */
  54139. readonly left: NodeMaterialConnectionPoint;
  54140. /**
  54141. * Gets the right operand input component
  54142. */
  54143. readonly right: NodeMaterialConnectionPoint;
  54144. protected _buildBlock(state: NodeMaterialBuildState): this;
  54145. }
  54146. }
  54147. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54151. /**
  54152. * Block used to add 2 vector4
  54153. */
  54154. export class AddBlock extends NodeMaterialBlock {
  54155. /**
  54156. * Creates a new AddBlock
  54157. * @param name defines the block name
  54158. */
  54159. constructor(name: string);
  54160. /**
  54161. * Gets the current class name
  54162. * @returns the class name
  54163. */
  54164. getClassName(): string;
  54165. /**
  54166. * Gets the left operand input component
  54167. */
  54168. readonly left: NodeMaterialConnectionPoint;
  54169. /**
  54170. * Gets the right operand input component
  54171. */
  54172. readonly right: NodeMaterialConnectionPoint;
  54173. protected _buildBlock(state: NodeMaterialBuildState): this;
  54174. }
  54175. }
  54176. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54180. /**
  54181. * Block used to clamp a float
  54182. */
  54183. export class ClampBlock extends NodeMaterialBlock {
  54184. /** Gets or sets the minimum range */
  54185. minimum: number;
  54186. /** Gets or sets the maximum range */
  54187. maximum: number;
  54188. /**
  54189. * Creates a new ClampBlock
  54190. * @param name defines the block name
  54191. */
  54192. constructor(name: string);
  54193. /**
  54194. * Gets the current class name
  54195. * @returns the class name
  54196. */
  54197. getClassName(): string;
  54198. /**
  54199. * Gets the value input component
  54200. */
  54201. readonly value: NodeMaterialConnectionPoint;
  54202. protected _buildBlock(state: NodeMaterialBuildState): this;
  54203. }
  54204. }
  54205. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54209. /**
  54210. * Block used to transform a vector2 with a matrix
  54211. */
  54212. export class Vector2TransformBlock extends NodeMaterialBlock {
  54213. /**
  54214. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54215. */
  54216. complementZ: number;
  54217. /**
  54218. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54219. */
  54220. complementW: number;
  54221. /**
  54222. * Creates a new Vector2TransformBlock
  54223. * @param name defines the block name
  54224. */
  54225. constructor(name: string);
  54226. /**
  54227. * Gets the vector input
  54228. */
  54229. readonly vector: NodeMaterialConnectionPoint;
  54230. /**
  54231. * Gets the matrix transform input
  54232. */
  54233. readonly transform: NodeMaterialConnectionPoint;
  54234. /**
  54235. * Gets the current class name
  54236. * @returns the class name
  54237. */
  54238. getClassName(): string;
  54239. protected _buildBlock(state: NodeMaterialBuildState): this;
  54240. }
  54241. }
  54242. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54246. /**
  54247. * Block used to transform a vector3 with a matrix
  54248. */
  54249. export class Vector3TransformBlock extends NodeMaterialBlock {
  54250. /**
  54251. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54252. */
  54253. complement: number;
  54254. /**
  54255. * Creates a new Vector3TransformBlock
  54256. * @param name defines the block name
  54257. */
  54258. constructor(name: string);
  54259. /**
  54260. * Gets the vector input
  54261. */
  54262. readonly vector: NodeMaterialConnectionPoint;
  54263. /**
  54264. * Gets the matrix transform input
  54265. */
  54266. readonly transform: NodeMaterialConnectionPoint;
  54267. /**
  54268. * Gets the current class name
  54269. * @returns the class name
  54270. */
  54271. getClassName(): string;
  54272. protected _buildBlock(state: NodeMaterialBuildState): this;
  54273. }
  54274. }
  54275. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54276. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54277. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54278. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54279. /**
  54280. * Block used to multiply two matrices
  54281. */
  54282. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54283. /**
  54284. * Creates a new MatrixMultiplicationBlock
  54285. * @param name defines the block name
  54286. */
  54287. constructor(name: string);
  54288. /**
  54289. * Gets the left operand
  54290. */
  54291. readonly left: NodeMaterialConnectionPoint;
  54292. /**
  54293. * Gets the right operand
  54294. */
  54295. readonly right: NodeMaterialConnectionPoint;
  54296. /**
  54297. * Gets the current class name
  54298. * @returns the class name
  54299. */
  54300. getClassName(): string;
  54301. protected _buildBlock(state: NodeMaterialBuildState): this;
  54302. }
  54303. }
  54304. declare module "babylonjs/Materials/Node/Blocks/index" {
  54305. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54306. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54307. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54308. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54309. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54310. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54311. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54312. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54313. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54314. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54315. }
  54316. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54317. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54318. }
  54319. declare module "babylonjs/Materials/Node/index" {
  54320. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54321. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54322. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54323. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54324. export * from "babylonjs/Materials/Node/nodeMaterial";
  54325. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54326. export * from "babylonjs/Materials/Node/Blocks/index";
  54327. export * from "babylonjs/Materials/Node/Optimizers/index";
  54328. }
  54329. declare module "babylonjs/Materials/index" {
  54330. export * from "babylonjs/Materials/Background/index";
  54331. export * from "babylonjs/Materials/colorCurves";
  54332. export * from "babylonjs/Materials/effect";
  54333. export * from "babylonjs/Materials/fresnelParameters";
  54334. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54335. export * from "babylonjs/Materials/material";
  54336. export * from "babylonjs/Materials/materialDefines";
  54337. export * from "babylonjs/Materials/materialHelper";
  54338. export * from "babylonjs/Materials/multiMaterial";
  54339. export * from "babylonjs/Materials/PBR/index";
  54340. export * from "babylonjs/Materials/pushMaterial";
  54341. export * from "babylonjs/Materials/shaderMaterial";
  54342. export * from "babylonjs/Materials/standardMaterial";
  54343. export * from "babylonjs/Materials/Textures/index";
  54344. export * from "babylonjs/Materials/uniformBuffer";
  54345. export * from "babylonjs/Materials/materialFlags";
  54346. export * from "babylonjs/Materials/Node/index";
  54347. }
  54348. declare module "babylonjs/Maths/index" {
  54349. export * from "babylonjs/Maths/math.scalar";
  54350. export * from "babylonjs/Maths/math";
  54351. export * from "babylonjs/Maths/sphericalPolynomial";
  54352. }
  54353. declare module "babylonjs/Misc/workerPool" {
  54354. import { IDisposable } from "babylonjs/scene";
  54355. /**
  54356. * Helper class to push actions to a pool of workers.
  54357. */
  54358. export class WorkerPool implements IDisposable {
  54359. private _workerInfos;
  54360. private _pendingActions;
  54361. /**
  54362. * Constructor
  54363. * @param workers Array of workers to use for actions
  54364. */
  54365. constructor(workers: Array<Worker>);
  54366. /**
  54367. * Terminates all workers and clears any pending actions.
  54368. */
  54369. dispose(): void;
  54370. /**
  54371. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54372. * pended until a worker has completed its action.
  54373. * @param action The action to perform. Call onComplete when the action is complete.
  54374. */
  54375. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54376. private _execute;
  54377. }
  54378. }
  54379. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54380. import { IDisposable } from "babylonjs/scene";
  54381. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54382. /**
  54383. * Configuration for Draco compression
  54384. */
  54385. export interface IDracoCompressionConfiguration {
  54386. /**
  54387. * Configuration for the decoder.
  54388. */
  54389. decoder: {
  54390. /**
  54391. * The url to the WebAssembly module.
  54392. */
  54393. wasmUrl?: string;
  54394. /**
  54395. * The url to the WebAssembly binary.
  54396. */
  54397. wasmBinaryUrl?: string;
  54398. /**
  54399. * The url to the fallback JavaScript module.
  54400. */
  54401. fallbackUrl?: string;
  54402. };
  54403. }
  54404. /**
  54405. * Draco compression (https://google.github.io/draco/)
  54406. *
  54407. * This class wraps the Draco module.
  54408. *
  54409. * **Encoder**
  54410. *
  54411. * The encoder is not currently implemented.
  54412. *
  54413. * **Decoder**
  54414. *
  54415. * 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.
  54416. *
  54417. * To update the configuration, use the following code:
  54418. * ```javascript
  54419. * DracoCompression.Configuration = {
  54420. * decoder: {
  54421. * wasmUrl: "<url to the WebAssembly library>",
  54422. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54423. * fallbackUrl: "<url to the fallback JavaScript library>",
  54424. * }
  54425. * };
  54426. * ```
  54427. *
  54428. * 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.
  54429. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54430. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54431. *
  54432. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54433. * ```javascript
  54434. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54435. * ```
  54436. *
  54437. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54438. */
  54439. export class DracoCompression implements IDisposable {
  54440. private _workerPoolPromise?;
  54441. private _decoderModulePromise?;
  54442. /**
  54443. * The configuration. Defaults to the following urls:
  54444. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54445. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54446. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54447. */
  54448. static Configuration: IDracoCompressionConfiguration;
  54449. /**
  54450. * Returns true if the decoder configuration is available.
  54451. */
  54452. static readonly DecoderAvailable: boolean;
  54453. /**
  54454. * Default number of workers to create when creating the draco compression object.
  54455. */
  54456. static DefaultNumWorkers: number;
  54457. private static GetDefaultNumWorkers;
  54458. private static _Default;
  54459. /**
  54460. * Default instance for the draco compression object.
  54461. */
  54462. static readonly Default: DracoCompression;
  54463. /**
  54464. * Constructor
  54465. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54466. */
  54467. constructor(numWorkers?: number);
  54468. /**
  54469. * Stop all async operations and release resources.
  54470. */
  54471. dispose(): void;
  54472. /**
  54473. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54474. * @returns a promise that resolves when ready
  54475. */
  54476. whenReadyAsync(): Promise<void>;
  54477. /**
  54478. * Decode Draco compressed mesh data to vertex data.
  54479. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54480. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54481. * @returns A promise that resolves with the decoded vertex data
  54482. */
  54483. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54484. [kind: string]: number;
  54485. }): Promise<VertexData>;
  54486. }
  54487. }
  54488. declare module "babylonjs/Meshes/Compression/index" {
  54489. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54490. }
  54491. declare module "babylonjs/Meshes/csg" {
  54492. import { Nullable } from "babylonjs/types";
  54493. import { Scene } from "babylonjs/scene";
  54494. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54495. import { Mesh } from "babylonjs/Meshes/mesh";
  54496. import { Material } from "babylonjs/Materials/material";
  54497. /**
  54498. * Class for building Constructive Solid Geometry
  54499. */
  54500. export class CSG {
  54501. private polygons;
  54502. /**
  54503. * The world matrix
  54504. */
  54505. matrix: Matrix;
  54506. /**
  54507. * Stores the position
  54508. */
  54509. position: Vector3;
  54510. /**
  54511. * Stores the rotation
  54512. */
  54513. rotation: Vector3;
  54514. /**
  54515. * Stores the rotation quaternion
  54516. */
  54517. rotationQuaternion: Nullable<Quaternion>;
  54518. /**
  54519. * Stores the scaling vector
  54520. */
  54521. scaling: Vector3;
  54522. /**
  54523. * Convert the Mesh to CSG
  54524. * @param mesh The Mesh to convert to CSG
  54525. * @returns A new CSG from the Mesh
  54526. */
  54527. static FromMesh(mesh: Mesh): CSG;
  54528. /**
  54529. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54530. * @param polygons Polygons used to construct a CSG solid
  54531. */
  54532. private static FromPolygons;
  54533. /**
  54534. * Clones, or makes a deep copy, of the CSG
  54535. * @returns A new CSG
  54536. */
  54537. clone(): CSG;
  54538. /**
  54539. * Unions this CSG with another CSG
  54540. * @param csg The CSG to union against this CSG
  54541. * @returns The unioned CSG
  54542. */
  54543. union(csg: CSG): CSG;
  54544. /**
  54545. * Unions this CSG with another CSG in place
  54546. * @param csg The CSG to union against this CSG
  54547. */
  54548. unionInPlace(csg: CSG): void;
  54549. /**
  54550. * Subtracts this CSG with another CSG
  54551. * @param csg The CSG to subtract against this CSG
  54552. * @returns A new CSG
  54553. */
  54554. subtract(csg: CSG): CSG;
  54555. /**
  54556. * Subtracts this CSG with another CSG in place
  54557. * @param csg The CSG to subtact against this CSG
  54558. */
  54559. subtractInPlace(csg: CSG): void;
  54560. /**
  54561. * Intersect this CSG with another CSG
  54562. * @param csg The CSG to intersect against this CSG
  54563. * @returns A new CSG
  54564. */
  54565. intersect(csg: CSG): CSG;
  54566. /**
  54567. * Intersects this CSG with another CSG in place
  54568. * @param csg The CSG to intersect against this CSG
  54569. */
  54570. intersectInPlace(csg: CSG): void;
  54571. /**
  54572. * Return a new CSG solid with solid and empty space switched. This solid is
  54573. * not modified.
  54574. * @returns A new CSG solid with solid and empty space switched
  54575. */
  54576. inverse(): CSG;
  54577. /**
  54578. * Inverses the CSG in place
  54579. */
  54580. inverseInPlace(): void;
  54581. /**
  54582. * This is used to keep meshes transformations so they can be restored
  54583. * when we build back a Babylon Mesh
  54584. * NB : All CSG operations are performed in world coordinates
  54585. * @param csg The CSG to copy the transform attributes from
  54586. * @returns This CSG
  54587. */
  54588. copyTransformAttributes(csg: CSG): CSG;
  54589. /**
  54590. * Build Raw mesh from CSG
  54591. * Coordinates here are in world space
  54592. * @param name The name of the mesh geometry
  54593. * @param scene The Scene
  54594. * @param keepSubMeshes Specifies if the submeshes should be kept
  54595. * @returns A new Mesh
  54596. */
  54597. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54598. /**
  54599. * Build Mesh from CSG taking material and transforms into account
  54600. * @param name The name of the Mesh
  54601. * @param material The material of the Mesh
  54602. * @param scene The Scene
  54603. * @param keepSubMeshes Specifies if submeshes should be kept
  54604. * @returns The new Mesh
  54605. */
  54606. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54607. }
  54608. }
  54609. declare module "babylonjs/Meshes/trailMesh" {
  54610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54611. import { Mesh } from "babylonjs/Meshes/mesh";
  54612. import { Scene } from "babylonjs/scene";
  54613. /**
  54614. * Class used to create a trail following a mesh
  54615. */
  54616. export class TrailMesh extends Mesh {
  54617. private _generator;
  54618. private _autoStart;
  54619. private _running;
  54620. private _diameter;
  54621. private _length;
  54622. private _sectionPolygonPointsCount;
  54623. private _sectionVectors;
  54624. private _sectionNormalVectors;
  54625. private _beforeRenderObserver;
  54626. /**
  54627. * @constructor
  54628. * @param name The value used by scene.getMeshByName() to do a lookup.
  54629. * @param generator The mesh to generate a trail.
  54630. * @param scene The scene to add this mesh to.
  54631. * @param diameter Diameter of trailing mesh. Default is 1.
  54632. * @param length Length of trailing mesh. Default is 60.
  54633. * @param autoStart Automatically start trailing mesh. Default true.
  54634. */
  54635. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54636. /**
  54637. * "TrailMesh"
  54638. * @returns "TrailMesh"
  54639. */
  54640. getClassName(): string;
  54641. private _createMesh;
  54642. /**
  54643. * Start trailing mesh.
  54644. */
  54645. start(): void;
  54646. /**
  54647. * Stop trailing mesh.
  54648. */
  54649. stop(): void;
  54650. /**
  54651. * Update trailing mesh geometry.
  54652. */
  54653. update(): void;
  54654. /**
  54655. * Returns a new TrailMesh object.
  54656. * @param name is a string, the name given to the new mesh
  54657. * @param newGenerator use new generator object for cloned trail mesh
  54658. * @returns a new mesh
  54659. */
  54660. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54661. /**
  54662. * Serializes this trail mesh
  54663. * @param serializationObject object to write serialization to
  54664. */
  54665. serialize(serializationObject: any): void;
  54666. /**
  54667. * Parses a serialized trail mesh
  54668. * @param parsedMesh the serialized mesh
  54669. * @param scene the scene to create the trail mesh in
  54670. * @returns the created trail mesh
  54671. */
  54672. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54673. }
  54674. }
  54675. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  54676. import { Nullable } from "babylonjs/types";
  54677. import { Scene } from "babylonjs/scene";
  54678. import { Vector4, Color4 } from "babylonjs/Maths/math";
  54679. import { Mesh } from "babylonjs/Meshes/mesh";
  54680. /**
  54681. * Class containing static functions to help procedurally build meshes
  54682. */
  54683. export class TiledBoxBuilder {
  54684. /**
  54685. * Creates a box mesh
  54686. * 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)
  54687. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54691. * @param name defines the name of the mesh
  54692. * @param options defines the options used to create the mesh
  54693. * @param scene defines the hosting scene
  54694. * @returns the box mesh
  54695. */
  54696. static CreateTiledBox(name: string, options: {
  54697. pattern?: number;
  54698. width?: number;
  54699. height?: number;
  54700. depth?: number;
  54701. tileSize?: number;
  54702. tileWidth?: number;
  54703. tileHeight?: number;
  54704. alignHorizontal?: number;
  54705. alignVertical?: number;
  54706. faceUV?: Vector4[];
  54707. faceColors?: Color4[];
  54708. sideOrientation?: number;
  54709. updatable?: boolean;
  54710. }, scene?: Nullable<Scene>): Mesh;
  54711. }
  54712. }
  54713. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  54714. import { Vector4 } from "babylonjs/Maths/math";
  54715. import { Mesh } from "babylonjs/Meshes/mesh";
  54716. /**
  54717. * Class containing static functions to help procedurally build meshes
  54718. */
  54719. export class TorusKnotBuilder {
  54720. /**
  54721. * Creates a torus knot mesh
  54722. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54723. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54724. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54725. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54729. * @param name defines the name of the mesh
  54730. * @param options defines the options used to create the mesh
  54731. * @param scene defines the hosting scene
  54732. * @returns the torus knot mesh
  54733. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54734. */
  54735. static CreateTorusKnot(name: string, options: {
  54736. radius?: number;
  54737. tube?: number;
  54738. radialSegments?: number;
  54739. tubularSegments?: number;
  54740. p?: number;
  54741. q?: number;
  54742. updatable?: boolean;
  54743. sideOrientation?: number;
  54744. frontUVs?: Vector4;
  54745. backUVs?: Vector4;
  54746. }, scene: any): Mesh;
  54747. }
  54748. }
  54749. declare module "babylonjs/Meshes/polygonMesh" {
  54750. import { Scene } from "babylonjs/scene";
  54751. import { Vector2, Path2 } from "babylonjs/Maths/math";
  54752. import { Mesh } from "babylonjs/Meshes/mesh";
  54753. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54754. /**
  54755. * Polygon
  54756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54757. */
  54758. export class Polygon {
  54759. /**
  54760. * Creates a rectangle
  54761. * @param xmin bottom X coord
  54762. * @param ymin bottom Y coord
  54763. * @param xmax top X coord
  54764. * @param ymax top Y coord
  54765. * @returns points that make the resulting rectation
  54766. */
  54767. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54768. /**
  54769. * Creates a circle
  54770. * @param radius radius of circle
  54771. * @param cx scale in x
  54772. * @param cy scale in y
  54773. * @param numberOfSides number of sides that make up the circle
  54774. * @returns points that make the resulting circle
  54775. */
  54776. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54777. /**
  54778. * Creates a polygon from input string
  54779. * @param input Input polygon data
  54780. * @returns the parsed points
  54781. */
  54782. static Parse(input: string): Vector2[];
  54783. /**
  54784. * Starts building a polygon from x and y coordinates
  54785. * @param x x coordinate
  54786. * @param y y coordinate
  54787. * @returns the started path2
  54788. */
  54789. static StartingAt(x: number, y: number): Path2;
  54790. }
  54791. /**
  54792. * Builds a polygon
  54793. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54794. */
  54795. export class PolygonMeshBuilder {
  54796. private _points;
  54797. private _outlinepoints;
  54798. private _holes;
  54799. private _name;
  54800. private _scene;
  54801. private _epoints;
  54802. private _eholes;
  54803. private _addToepoint;
  54804. /**
  54805. * Babylon reference to the earcut plugin.
  54806. */
  54807. bjsEarcut: any;
  54808. /**
  54809. * Creates a PolygonMeshBuilder
  54810. * @param name name of the builder
  54811. * @param contours Path of the polygon
  54812. * @param scene scene to add to when creating the mesh
  54813. * @param earcutInjection can be used to inject your own earcut reference
  54814. */
  54815. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54816. /**
  54817. * Adds a whole within the polygon
  54818. * @param hole Array of points defining the hole
  54819. * @returns this
  54820. */
  54821. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54822. /**
  54823. * Creates the polygon
  54824. * @param updatable If the mesh should be updatable
  54825. * @param depth The depth of the mesh created
  54826. * @returns the created mesh
  54827. */
  54828. build(updatable?: boolean, depth?: number): Mesh;
  54829. /**
  54830. * Creates the polygon
  54831. * @param depth The depth of the mesh created
  54832. * @returns the created VertexData
  54833. */
  54834. buildVertexData(depth?: number): VertexData;
  54835. /**
  54836. * Adds a side to the polygon
  54837. * @param positions points that make the polygon
  54838. * @param normals normals of the polygon
  54839. * @param uvs uvs of the polygon
  54840. * @param indices indices of the polygon
  54841. * @param bounds bounds of the polygon
  54842. * @param points points of the polygon
  54843. * @param depth depth of the polygon
  54844. * @param flip flip of the polygon
  54845. */
  54846. private addSide;
  54847. }
  54848. }
  54849. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  54850. import { Scene } from "babylonjs/scene";
  54851. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  54852. import { Mesh } from "babylonjs/Meshes/mesh";
  54853. import { Nullable } from "babylonjs/types";
  54854. /**
  54855. * Class containing static functions to help procedurally build meshes
  54856. */
  54857. export class PolygonBuilder {
  54858. /**
  54859. * Creates a polygon mesh
  54860. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54861. * * 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
  54862. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54865. * * Remember you can only change the shape positions, not their number when updating a polygon
  54866. * @param name defines the name of the mesh
  54867. * @param options defines the options used to create the mesh
  54868. * @param scene defines the hosting scene
  54869. * @param earcutInjection can be used to inject your own earcut reference
  54870. * @returns the polygon mesh
  54871. */
  54872. static CreatePolygon(name: string, options: {
  54873. shape: Vector3[];
  54874. holes?: Vector3[][];
  54875. depth?: number;
  54876. faceUV?: Vector4[];
  54877. faceColors?: Color4[];
  54878. updatable?: boolean;
  54879. sideOrientation?: number;
  54880. frontUVs?: Vector4;
  54881. backUVs?: Vector4;
  54882. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54883. /**
  54884. * Creates an extruded polygon mesh, with depth in the Y direction.
  54885. * * 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)
  54886. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54887. * @param name defines the name of the mesh
  54888. * @param options defines the options used to create the mesh
  54889. * @param scene defines the hosting scene
  54890. * @param earcutInjection can be used to inject your own earcut reference
  54891. * @returns the polygon mesh
  54892. */
  54893. static ExtrudePolygon(name: string, options: {
  54894. shape: Vector3[];
  54895. holes?: Vector3[][];
  54896. depth?: number;
  54897. faceUV?: Vector4[];
  54898. faceColors?: Color4[];
  54899. updatable?: boolean;
  54900. sideOrientation?: number;
  54901. frontUVs?: Vector4;
  54902. backUVs?: Vector4;
  54903. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54904. }
  54905. }
  54906. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  54907. import { Scene } from "babylonjs/scene";
  54908. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54909. import { Mesh } from "babylonjs/Meshes/mesh";
  54910. import { Nullable } from "babylonjs/types";
  54911. /**
  54912. * Class containing static functions to help procedurally build meshes
  54913. */
  54914. export class LatheBuilder {
  54915. /**
  54916. * Creates lathe mesh.
  54917. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54918. * * 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
  54919. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54920. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54921. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54922. * * 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
  54923. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54924. * * 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
  54925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54927. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54929. * @param name defines the name of the mesh
  54930. * @param options defines the options used to create the mesh
  54931. * @param scene defines the hosting scene
  54932. * @returns the lathe mesh
  54933. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54934. */
  54935. static CreateLathe(name: string, options: {
  54936. shape: Vector3[];
  54937. radius?: number;
  54938. tessellation?: number;
  54939. clip?: number;
  54940. arc?: number;
  54941. closed?: boolean;
  54942. updatable?: boolean;
  54943. sideOrientation?: number;
  54944. frontUVs?: Vector4;
  54945. backUVs?: Vector4;
  54946. cap?: number;
  54947. invertUV?: boolean;
  54948. }, scene?: Nullable<Scene>): Mesh;
  54949. }
  54950. }
  54951. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  54952. import { Nullable } from "babylonjs/types";
  54953. import { Scene } from "babylonjs/scene";
  54954. import { Vector4 } from "babylonjs/Maths/math";
  54955. import { Mesh } from "babylonjs/Meshes/mesh";
  54956. /**
  54957. * Class containing static functions to help procedurally build meshes
  54958. */
  54959. export class TiledPlaneBuilder {
  54960. /**
  54961. * Creates a tiled plane mesh
  54962. * * The parameter `pattern` will, depending on value, do nothing or
  54963. * * * flip (reflect about central vertical) alternate tiles across and up
  54964. * * * flip every tile on alternate rows
  54965. * * * rotate (180 degs) alternate tiles across and up
  54966. * * * rotate every tile on alternate rows
  54967. * * * flip and rotate alternate tiles across and up
  54968. * * * flip and rotate every tile on alternate rows
  54969. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54970. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54972. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54973. * * 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)
  54974. * * 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)
  54975. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54976. * @param name defines the name of the mesh
  54977. * @param options defines the options used to create the mesh
  54978. * @param scene defines the hosting scene
  54979. * @returns the box mesh
  54980. */
  54981. static CreateTiledPlane(name: string, options: {
  54982. pattern?: number;
  54983. tileSize?: number;
  54984. tileWidth?: number;
  54985. tileHeight?: number;
  54986. size?: number;
  54987. width?: number;
  54988. height?: number;
  54989. alignHorizontal?: number;
  54990. alignVertical?: number;
  54991. sideOrientation?: number;
  54992. frontUVs?: Vector4;
  54993. backUVs?: Vector4;
  54994. updatable?: boolean;
  54995. }, scene?: Nullable<Scene>): Mesh;
  54996. }
  54997. }
  54998. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  54999. import { Nullable } from "babylonjs/types";
  55000. import { Scene } from "babylonjs/scene";
  55001. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55002. import { Mesh } from "babylonjs/Meshes/mesh";
  55003. /**
  55004. * Class containing static functions to help procedurally build meshes
  55005. */
  55006. export class TubeBuilder {
  55007. /**
  55008. * Creates a tube mesh.
  55009. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55010. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55011. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55012. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55013. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55014. * * 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)
  55015. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55016. * * 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
  55017. * * 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
  55018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55019. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55020. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55022. * @param name defines the name of the mesh
  55023. * @param options defines the options used to create the mesh
  55024. * @param scene defines the hosting scene
  55025. * @returns the tube mesh
  55026. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55027. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55028. */
  55029. static CreateTube(name: string, options: {
  55030. path: Vector3[];
  55031. radius?: number;
  55032. tessellation?: number;
  55033. radiusFunction?: {
  55034. (i: number, distance: number): number;
  55035. };
  55036. cap?: number;
  55037. arc?: number;
  55038. updatable?: boolean;
  55039. sideOrientation?: number;
  55040. frontUVs?: Vector4;
  55041. backUVs?: Vector4;
  55042. instance?: Mesh;
  55043. invertUV?: boolean;
  55044. }, scene?: Nullable<Scene>): Mesh;
  55045. }
  55046. }
  55047. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55048. import { Scene } from "babylonjs/scene";
  55049. import { Vector4 } from "babylonjs/Maths/math";
  55050. import { Mesh } from "babylonjs/Meshes/mesh";
  55051. import { Nullable } from "babylonjs/types";
  55052. /**
  55053. * Class containing static functions to help procedurally build meshes
  55054. */
  55055. export class IcoSphereBuilder {
  55056. /**
  55057. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55058. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55059. * * 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`)
  55060. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55061. * * 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
  55062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55065. * @param name defines the name of the mesh
  55066. * @param options defines the options used to create the mesh
  55067. * @param scene defines the hosting scene
  55068. * @returns the icosahedron mesh
  55069. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55070. */
  55071. static CreateIcoSphere(name: string, options: {
  55072. radius?: number;
  55073. radiusX?: number;
  55074. radiusY?: number;
  55075. radiusZ?: number;
  55076. flat?: boolean;
  55077. subdivisions?: number;
  55078. sideOrientation?: number;
  55079. frontUVs?: Vector4;
  55080. backUVs?: Vector4;
  55081. updatable?: boolean;
  55082. }, scene?: Nullable<Scene>): Mesh;
  55083. }
  55084. }
  55085. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55086. import { Vector3 } from "babylonjs/Maths/math";
  55087. import { Mesh } from "babylonjs/Meshes/mesh";
  55088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55089. /**
  55090. * Class containing static functions to help procedurally build meshes
  55091. */
  55092. export class DecalBuilder {
  55093. /**
  55094. * Creates a decal mesh.
  55095. * 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
  55096. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55097. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55098. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55099. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55100. * @param name defines the name of the mesh
  55101. * @param sourceMesh defines the mesh where the decal must be applied
  55102. * @param options defines the options used to create the mesh
  55103. * @param scene defines the hosting scene
  55104. * @returns the decal mesh
  55105. * @see https://doc.babylonjs.com/how_to/decals
  55106. */
  55107. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55108. position?: Vector3;
  55109. normal?: Vector3;
  55110. size?: Vector3;
  55111. angle?: number;
  55112. }): Mesh;
  55113. }
  55114. }
  55115. declare module "babylonjs/Meshes/meshBuilder" {
  55116. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55117. import { Nullable } from "babylonjs/types";
  55118. import { Scene } from "babylonjs/scene";
  55119. import { Mesh } from "babylonjs/Meshes/mesh";
  55120. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55121. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55123. /**
  55124. * Class containing static functions to help procedurally build meshes
  55125. */
  55126. export class MeshBuilder {
  55127. /**
  55128. * Creates a box mesh
  55129. * * The parameter `size` sets the size (float) of each box side (default 1)
  55130. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55131. * * 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)
  55132. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55136. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55137. * @param name defines the name of the mesh
  55138. * @param options defines the options used to create the mesh
  55139. * @param scene defines the hosting scene
  55140. * @returns the box mesh
  55141. */
  55142. static CreateBox(name: string, options: {
  55143. size?: number;
  55144. width?: number;
  55145. height?: number;
  55146. depth?: number;
  55147. faceUV?: Vector4[];
  55148. faceColors?: Color4[];
  55149. sideOrientation?: number;
  55150. frontUVs?: Vector4;
  55151. backUVs?: Vector4;
  55152. updatable?: boolean;
  55153. }, scene?: Nullable<Scene>): Mesh;
  55154. /**
  55155. * Creates a tiled box mesh
  55156. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55158. * @param name defines the name of the mesh
  55159. * @param options defines the options used to create the mesh
  55160. * @param scene defines the hosting scene
  55161. * @returns the tiled box mesh
  55162. */
  55163. static CreateTiledBox(name: string, options: {
  55164. pattern?: number;
  55165. size?: number;
  55166. width?: number;
  55167. height?: number;
  55168. depth: number;
  55169. tileSize?: number;
  55170. tileWidth?: number;
  55171. tileHeight?: number;
  55172. faceUV?: Vector4[];
  55173. faceColors?: Color4[];
  55174. alignHorizontal?: number;
  55175. alignVertical?: number;
  55176. sideOrientation?: number;
  55177. updatable?: boolean;
  55178. }, scene?: Nullable<Scene>): Mesh;
  55179. /**
  55180. * Creates a sphere mesh
  55181. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55182. * * 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`)
  55183. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55184. * * 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
  55185. * * 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)
  55186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55189. * @param name defines the name of the mesh
  55190. * @param options defines the options used to create the mesh
  55191. * @param scene defines the hosting scene
  55192. * @returns the sphere mesh
  55193. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55194. */
  55195. static CreateSphere(name: string, options: {
  55196. segments?: number;
  55197. diameter?: number;
  55198. diameterX?: number;
  55199. diameterY?: number;
  55200. diameterZ?: number;
  55201. arc?: number;
  55202. slice?: number;
  55203. sideOrientation?: number;
  55204. frontUVs?: Vector4;
  55205. backUVs?: Vector4;
  55206. updatable?: boolean;
  55207. }, scene?: Nullable<Scene>): Mesh;
  55208. /**
  55209. * Creates a plane polygonal mesh. By default, this is a disc
  55210. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55211. * * 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
  55212. * * 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
  55213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55216. * @param name defines the name of the mesh
  55217. * @param options defines the options used to create the mesh
  55218. * @param scene defines the hosting scene
  55219. * @returns the plane polygonal mesh
  55220. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55221. */
  55222. static CreateDisc(name: string, options: {
  55223. radius?: number;
  55224. tessellation?: number;
  55225. arc?: number;
  55226. updatable?: boolean;
  55227. sideOrientation?: number;
  55228. frontUVs?: Vector4;
  55229. backUVs?: Vector4;
  55230. }, scene?: Nullable<Scene>): Mesh;
  55231. /**
  55232. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55233. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55234. * * 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`)
  55235. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55236. * * 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
  55237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55240. * @param name defines the name of the mesh
  55241. * @param options defines the options used to create the mesh
  55242. * @param scene defines the hosting scene
  55243. * @returns the icosahedron mesh
  55244. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55245. */
  55246. static CreateIcoSphere(name: string, options: {
  55247. radius?: number;
  55248. radiusX?: number;
  55249. radiusY?: number;
  55250. radiusZ?: number;
  55251. flat?: boolean;
  55252. subdivisions?: number;
  55253. sideOrientation?: number;
  55254. frontUVs?: Vector4;
  55255. backUVs?: Vector4;
  55256. updatable?: boolean;
  55257. }, scene?: Nullable<Scene>): Mesh;
  55258. /**
  55259. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55260. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55261. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55262. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55263. * * 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
  55264. * * 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
  55265. * * 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
  55266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55268. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55269. * * 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
  55270. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55271. * * 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
  55272. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55274. * @param name defines the name of the mesh
  55275. * @param options defines the options used to create the mesh
  55276. * @param scene defines the hosting scene
  55277. * @returns the ribbon mesh
  55278. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55280. */
  55281. static CreateRibbon(name: string, options: {
  55282. pathArray: Vector3[][];
  55283. closeArray?: boolean;
  55284. closePath?: boolean;
  55285. offset?: number;
  55286. updatable?: boolean;
  55287. sideOrientation?: number;
  55288. frontUVs?: Vector4;
  55289. backUVs?: Vector4;
  55290. instance?: Mesh;
  55291. invertUV?: boolean;
  55292. uvs?: Vector2[];
  55293. colors?: Color4[];
  55294. }, scene?: Nullable<Scene>): Mesh;
  55295. /**
  55296. * Creates a cylinder or a cone mesh
  55297. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55298. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55299. * * 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.
  55300. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55301. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55302. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55303. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55304. * * 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).
  55305. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55306. * * 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).
  55307. * * 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
  55308. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55309. * * 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
  55310. * * 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.
  55311. * * If `enclose` is false, a ring surface is one element.
  55312. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55313. * * 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
  55314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55317. * @param name defines the name of the mesh
  55318. * @param options defines the options used to create the mesh
  55319. * @param scene defines the hosting scene
  55320. * @returns the cylinder mesh
  55321. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55322. */
  55323. static CreateCylinder(name: string, options: {
  55324. height?: number;
  55325. diameterTop?: number;
  55326. diameterBottom?: number;
  55327. diameter?: number;
  55328. tessellation?: number;
  55329. subdivisions?: number;
  55330. arc?: number;
  55331. faceColors?: Color4[];
  55332. faceUV?: Vector4[];
  55333. updatable?: boolean;
  55334. hasRings?: boolean;
  55335. enclose?: boolean;
  55336. cap?: number;
  55337. sideOrientation?: number;
  55338. frontUVs?: Vector4;
  55339. backUVs?: Vector4;
  55340. }, scene?: Nullable<Scene>): Mesh;
  55341. /**
  55342. * Creates a torus mesh
  55343. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55344. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55345. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55349. * @param name defines the name of the mesh
  55350. * @param options defines the options used to create the mesh
  55351. * @param scene defines the hosting scene
  55352. * @returns the torus mesh
  55353. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55354. */
  55355. static CreateTorus(name: string, options: {
  55356. diameter?: number;
  55357. thickness?: number;
  55358. tessellation?: number;
  55359. updatable?: boolean;
  55360. sideOrientation?: number;
  55361. frontUVs?: Vector4;
  55362. backUVs?: Vector4;
  55363. }, scene?: Nullable<Scene>): Mesh;
  55364. /**
  55365. * Creates a torus knot mesh
  55366. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55367. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55368. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55369. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55373. * @param name defines the name of the mesh
  55374. * @param options defines the options used to create the mesh
  55375. * @param scene defines the hosting scene
  55376. * @returns the torus knot mesh
  55377. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55378. */
  55379. static CreateTorusKnot(name: string, options: {
  55380. radius?: number;
  55381. tube?: number;
  55382. radialSegments?: number;
  55383. tubularSegments?: number;
  55384. p?: number;
  55385. q?: number;
  55386. updatable?: boolean;
  55387. sideOrientation?: number;
  55388. frontUVs?: Vector4;
  55389. backUVs?: Vector4;
  55390. }, scene?: Nullable<Scene>): Mesh;
  55391. /**
  55392. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55393. * * 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
  55394. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55395. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55396. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55397. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55398. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55399. * * 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
  55400. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55403. * @param name defines the name of the new line system
  55404. * @param options defines the options used to create the line system
  55405. * @param scene defines the hosting scene
  55406. * @returns a new line system mesh
  55407. */
  55408. static CreateLineSystem(name: string, options: {
  55409. lines: Vector3[][];
  55410. updatable?: boolean;
  55411. instance?: Nullable<LinesMesh>;
  55412. colors?: Nullable<Color4[][]>;
  55413. useVertexAlpha?: boolean;
  55414. }, scene: Nullable<Scene>): LinesMesh;
  55415. /**
  55416. * Creates a line mesh
  55417. * 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
  55418. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55419. * * The parameter `points` is an array successive Vector3
  55420. * * 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
  55421. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55422. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55423. * * When updating an instance, remember that only point positions can change, not the number of points
  55424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55426. * @param name defines the name of the new line system
  55427. * @param options defines the options used to create the line system
  55428. * @param scene defines the hosting scene
  55429. * @returns a new line mesh
  55430. */
  55431. static CreateLines(name: string, options: {
  55432. points: Vector3[];
  55433. updatable?: boolean;
  55434. instance?: Nullable<LinesMesh>;
  55435. colors?: Color4[];
  55436. useVertexAlpha?: boolean;
  55437. }, scene?: Nullable<Scene>): LinesMesh;
  55438. /**
  55439. * Creates a dashed line mesh
  55440. * * 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
  55441. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55442. * * The parameter `points` is an array successive Vector3
  55443. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55444. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55445. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55446. * * 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
  55447. * * When updating an instance, remember that only point positions can change, not the number of points
  55448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55449. * @param name defines the name of the mesh
  55450. * @param options defines the options used to create the mesh
  55451. * @param scene defines the hosting scene
  55452. * @returns the dashed line mesh
  55453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55454. */
  55455. static CreateDashedLines(name: string, options: {
  55456. points: Vector3[];
  55457. dashSize?: number;
  55458. gapSize?: number;
  55459. dashNb?: number;
  55460. updatable?: boolean;
  55461. instance?: LinesMesh;
  55462. }, scene?: Nullable<Scene>): LinesMesh;
  55463. /**
  55464. * 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.
  55465. * * 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.
  55466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55467. * * 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.
  55468. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55469. * * 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
  55470. * * 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
  55471. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55476. * @param name defines the name of the mesh
  55477. * @param options defines the options used to create the mesh
  55478. * @param scene defines the hosting scene
  55479. * @returns the extruded shape mesh
  55480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55482. */
  55483. static ExtrudeShape(name: string, options: {
  55484. shape: Vector3[];
  55485. path: Vector3[];
  55486. scale?: number;
  55487. rotation?: number;
  55488. cap?: number;
  55489. updatable?: boolean;
  55490. sideOrientation?: number;
  55491. frontUVs?: Vector4;
  55492. backUVs?: Vector4;
  55493. instance?: Mesh;
  55494. invertUV?: boolean;
  55495. }, scene?: Nullable<Scene>): Mesh;
  55496. /**
  55497. * Creates an custom extruded shape mesh.
  55498. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55499. * * 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.
  55500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55501. * * 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
  55502. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55503. * * 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
  55504. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55505. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55506. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55507. * * 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
  55508. * * 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
  55509. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55514. * @param name defines the name of the mesh
  55515. * @param options defines the options used to create the mesh
  55516. * @param scene defines the hosting scene
  55517. * @returns the custom extruded shape mesh
  55518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55521. */
  55522. static ExtrudeShapeCustom(name: string, options: {
  55523. shape: Vector3[];
  55524. path: Vector3[];
  55525. scaleFunction?: any;
  55526. rotationFunction?: any;
  55527. ribbonCloseArray?: boolean;
  55528. ribbonClosePath?: boolean;
  55529. cap?: number;
  55530. updatable?: boolean;
  55531. sideOrientation?: number;
  55532. frontUVs?: Vector4;
  55533. backUVs?: Vector4;
  55534. instance?: Mesh;
  55535. invertUV?: boolean;
  55536. }, scene?: Nullable<Scene>): Mesh;
  55537. /**
  55538. * Creates lathe mesh.
  55539. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55540. * * 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
  55541. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55542. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55543. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55544. * * 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
  55545. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55546. * * 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
  55547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55551. * @param name defines the name of the mesh
  55552. * @param options defines the options used to create the mesh
  55553. * @param scene defines the hosting scene
  55554. * @returns the lathe mesh
  55555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55556. */
  55557. static CreateLathe(name: string, options: {
  55558. shape: Vector3[];
  55559. radius?: number;
  55560. tessellation?: number;
  55561. clip?: number;
  55562. arc?: number;
  55563. closed?: boolean;
  55564. updatable?: boolean;
  55565. sideOrientation?: number;
  55566. frontUVs?: Vector4;
  55567. backUVs?: Vector4;
  55568. cap?: number;
  55569. invertUV?: boolean;
  55570. }, scene?: Nullable<Scene>): Mesh;
  55571. /**
  55572. * Creates a tiled plane mesh
  55573. * * You can set a limited pattern arrangement with the tiles
  55574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55577. * @param name defines the name of the mesh
  55578. * @param options defines the options used to create the mesh
  55579. * @param scene defines the hosting scene
  55580. * @returns the plane mesh
  55581. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55582. */
  55583. static CreateTiledPlane(name: string, options: {
  55584. pattern?: number;
  55585. tileSize?: number;
  55586. tileWidth?: number;
  55587. tileHeight?: number;
  55588. size?: number;
  55589. width?: number;
  55590. height?: number;
  55591. alignHorizontal?: number;
  55592. alignVertical?: number;
  55593. sideOrientation?: number;
  55594. frontUVs?: Vector4;
  55595. backUVs?: Vector4;
  55596. updatable?: boolean;
  55597. }, scene?: Nullable<Scene>): Mesh;
  55598. /**
  55599. * Creates a plane mesh
  55600. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55601. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55602. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55606. * @param name defines the name of the mesh
  55607. * @param options defines the options used to create the mesh
  55608. * @param scene defines the hosting scene
  55609. * @returns the plane mesh
  55610. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55611. */
  55612. static CreatePlane(name: string, options: {
  55613. size?: number;
  55614. width?: number;
  55615. height?: number;
  55616. sideOrientation?: number;
  55617. frontUVs?: Vector4;
  55618. backUVs?: Vector4;
  55619. updatable?: boolean;
  55620. sourcePlane?: Plane;
  55621. }, scene?: Nullable<Scene>): Mesh;
  55622. /**
  55623. * Creates a ground mesh
  55624. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55625. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55627. * @param name defines the name of the mesh
  55628. * @param options defines the options used to create the mesh
  55629. * @param scene defines the hosting scene
  55630. * @returns the ground mesh
  55631. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55632. */
  55633. static CreateGround(name: string, options: {
  55634. width?: number;
  55635. height?: number;
  55636. subdivisions?: number;
  55637. subdivisionsX?: number;
  55638. subdivisionsY?: number;
  55639. updatable?: boolean;
  55640. }, scene?: Nullable<Scene>): Mesh;
  55641. /**
  55642. * Creates a tiled ground mesh
  55643. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55644. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55645. * * 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
  55646. * * 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
  55647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55648. * @param name defines the name of the mesh
  55649. * @param options defines the options used to create the mesh
  55650. * @param scene defines the hosting scene
  55651. * @returns the tiled ground mesh
  55652. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55653. */
  55654. static CreateTiledGround(name: string, options: {
  55655. xmin: number;
  55656. zmin: number;
  55657. xmax: number;
  55658. zmax: number;
  55659. subdivisions?: {
  55660. w: number;
  55661. h: number;
  55662. };
  55663. precision?: {
  55664. w: number;
  55665. h: number;
  55666. };
  55667. updatable?: boolean;
  55668. }, scene?: Nullable<Scene>): Mesh;
  55669. /**
  55670. * Creates a ground mesh from a height map
  55671. * * The parameter `url` sets the URL of the height map image resource.
  55672. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55673. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55674. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55675. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55676. * * 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.
  55677. * * 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).
  55678. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55680. * @param name defines the name of the mesh
  55681. * @param url defines the url to the height map
  55682. * @param options defines the options used to create the mesh
  55683. * @param scene defines the hosting scene
  55684. * @returns the ground mesh
  55685. * @see https://doc.babylonjs.com/babylon101/height_map
  55686. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55687. */
  55688. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55689. width?: number;
  55690. height?: number;
  55691. subdivisions?: number;
  55692. minHeight?: number;
  55693. maxHeight?: number;
  55694. colorFilter?: Color3;
  55695. alphaFilter?: number;
  55696. updatable?: boolean;
  55697. onReady?: (mesh: GroundMesh) => void;
  55698. }, scene?: Nullable<Scene>): GroundMesh;
  55699. /**
  55700. * Creates a polygon mesh
  55701. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55702. * * 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
  55703. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55706. * * Remember you can only change the shape positions, not their number when updating a polygon
  55707. * @param name defines the name of the mesh
  55708. * @param options defines the options used to create the mesh
  55709. * @param scene defines the hosting scene
  55710. * @param earcutInjection can be used to inject your own earcut reference
  55711. * @returns the polygon mesh
  55712. */
  55713. static CreatePolygon(name: string, options: {
  55714. shape: Vector3[];
  55715. holes?: Vector3[][];
  55716. depth?: number;
  55717. faceUV?: Vector4[];
  55718. faceColors?: Color4[];
  55719. updatable?: boolean;
  55720. sideOrientation?: number;
  55721. frontUVs?: Vector4;
  55722. backUVs?: Vector4;
  55723. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55724. /**
  55725. * Creates an extruded polygon mesh, with depth in the Y direction.
  55726. * * 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)
  55727. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55728. * @param name defines the name of the mesh
  55729. * @param options defines the options used to create the mesh
  55730. * @param scene defines the hosting scene
  55731. * @param earcutInjection can be used to inject your own earcut reference
  55732. * @returns the polygon mesh
  55733. */
  55734. static ExtrudePolygon(name: string, options: {
  55735. shape: Vector3[];
  55736. holes?: Vector3[][];
  55737. depth?: number;
  55738. faceUV?: Vector4[];
  55739. faceColors?: Color4[];
  55740. updatable?: boolean;
  55741. sideOrientation?: number;
  55742. frontUVs?: Vector4;
  55743. backUVs?: Vector4;
  55744. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55745. /**
  55746. * Creates a tube mesh.
  55747. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55748. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55749. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55750. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55751. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55752. * * 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)
  55753. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55754. * * 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
  55755. * * 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
  55756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55760. * @param name defines the name of the mesh
  55761. * @param options defines the options used to create the mesh
  55762. * @param scene defines the hosting scene
  55763. * @returns the tube mesh
  55764. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55765. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55766. */
  55767. static CreateTube(name: string, options: {
  55768. path: Vector3[];
  55769. radius?: number;
  55770. tessellation?: number;
  55771. radiusFunction?: {
  55772. (i: number, distance: number): number;
  55773. };
  55774. cap?: number;
  55775. arc?: number;
  55776. updatable?: boolean;
  55777. sideOrientation?: number;
  55778. frontUVs?: Vector4;
  55779. backUVs?: Vector4;
  55780. instance?: Mesh;
  55781. invertUV?: boolean;
  55782. }, scene?: Nullable<Scene>): Mesh;
  55783. /**
  55784. * Creates a polyhedron mesh
  55785. * * 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
  55786. * * The parameter `size` (positive float, default 1) sets the polygon size
  55787. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55788. * * 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`
  55789. * * 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
  55790. * * 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)`)
  55791. * * 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
  55792. * * 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
  55793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55796. * @param name defines the name of the mesh
  55797. * @param options defines the options used to create the mesh
  55798. * @param scene defines the hosting scene
  55799. * @returns the polyhedron mesh
  55800. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55801. */
  55802. static CreatePolyhedron(name: string, options: {
  55803. type?: number;
  55804. size?: number;
  55805. sizeX?: number;
  55806. sizeY?: number;
  55807. sizeZ?: number;
  55808. custom?: any;
  55809. faceUV?: Vector4[];
  55810. faceColors?: Color4[];
  55811. flat?: boolean;
  55812. updatable?: boolean;
  55813. sideOrientation?: number;
  55814. frontUVs?: Vector4;
  55815. backUVs?: Vector4;
  55816. }, scene?: Nullable<Scene>): Mesh;
  55817. /**
  55818. * Creates a decal mesh.
  55819. * 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
  55820. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55821. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55822. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55823. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55824. * @param name defines the name of the mesh
  55825. * @param sourceMesh defines the mesh where the decal must be applied
  55826. * @param options defines the options used to create the mesh
  55827. * @param scene defines the hosting scene
  55828. * @returns the decal mesh
  55829. * @see https://doc.babylonjs.com/how_to/decals
  55830. */
  55831. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55832. position?: Vector3;
  55833. normal?: Vector3;
  55834. size?: Vector3;
  55835. angle?: number;
  55836. }): Mesh;
  55837. }
  55838. }
  55839. declare module "babylonjs/Meshes/meshSimplification" {
  55840. import { Mesh } from "babylonjs/Meshes/mesh";
  55841. /**
  55842. * A simplifier interface for future simplification implementations
  55843. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55844. */
  55845. export interface ISimplifier {
  55846. /**
  55847. * Simplification of a given mesh according to the given settings.
  55848. * Since this requires computation, it is assumed that the function runs async.
  55849. * @param settings The settings of the simplification, including quality and distance
  55850. * @param successCallback A callback that will be called after the mesh was simplified.
  55851. * @param errorCallback in case of an error, this callback will be called. optional.
  55852. */
  55853. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55854. }
  55855. /**
  55856. * Expected simplification settings.
  55857. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55858. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55859. */
  55860. export interface ISimplificationSettings {
  55861. /**
  55862. * Gets or sets the expected quality
  55863. */
  55864. quality: number;
  55865. /**
  55866. * Gets or sets the distance when this optimized version should be used
  55867. */
  55868. distance: number;
  55869. /**
  55870. * Gets an already optimized mesh
  55871. */
  55872. optimizeMesh?: boolean;
  55873. }
  55874. /**
  55875. * Class used to specify simplification options
  55876. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55877. */
  55878. export class SimplificationSettings implements ISimplificationSettings {
  55879. /** expected quality */
  55880. quality: number;
  55881. /** distance when this optimized version should be used */
  55882. distance: number;
  55883. /** already optimized mesh */
  55884. optimizeMesh?: boolean | undefined;
  55885. /**
  55886. * Creates a SimplificationSettings
  55887. * @param quality expected quality
  55888. * @param distance distance when this optimized version should be used
  55889. * @param optimizeMesh already optimized mesh
  55890. */
  55891. constructor(
  55892. /** expected quality */
  55893. quality: number,
  55894. /** distance when this optimized version should be used */
  55895. distance: number,
  55896. /** already optimized mesh */
  55897. optimizeMesh?: boolean | undefined);
  55898. }
  55899. /**
  55900. * Interface used to define a simplification task
  55901. */
  55902. export interface ISimplificationTask {
  55903. /**
  55904. * Array of settings
  55905. */
  55906. settings: Array<ISimplificationSettings>;
  55907. /**
  55908. * Simplification type
  55909. */
  55910. simplificationType: SimplificationType;
  55911. /**
  55912. * Mesh to simplify
  55913. */
  55914. mesh: Mesh;
  55915. /**
  55916. * Callback called on success
  55917. */
  55918. successCallback?: () => void;
  55919. /**
  55920. * Defines if parallel processing can be used
  55921. */
  55922. parallelProcessing: boolean;
  55923. }
  55924. /**
  55925. * Queue used to order the simplification tasks
  55926. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55927. */
  55928. export class SimplificationQueue {
  55929. private _simplificationArray;
  55930. /**
  55931. * Gets a boolean indicating that the process is still running
  55932. */
  55933. running: boolean;
  55934. /**
  55935. * Creates a new queue
  55936. */
  55937. constructor();
  55938. /**
  55939. * Adds a new simplification task
  55940. * @param task defines a task to add
  55941. */
  55942. addTask(task: ISimplificationTask): void;
  55943. /**
  55944. * Execute next task
  55945. */
  55946. executeNext(): void;
  55947. /**
  55948. * Execute a simplification task
  55949. * @param task defines the task to run
  55950. */
  55951. runSimplification(task: ISimplificationTask): void;
  55952. private getSimplifier;
  55953. }
  55954. /**
  55955. * The implemented types of simplification
  55956. * At the moment only Quadratic Error Decimation is implemented
  55957. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55958. */
  55959. export enum SimplificationType {
  55960. /** Quadratic error decimation */
  55961. QUADRATIC = 0
  55962. }
  55963. }
  55964. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  55965. import { Scene } from "babylonjs/scene";
  55966. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  55967. import { ISceneComponent } from "babylonjs/sceneComponent";
  55968. module "babylonjs/scene" {
  55969. interface Scene {
  55970. /** @hidden (Backing field) */
  55971. _simplificationQueue: SimplificationQueue;
  55972. /**
  55973. * Gets or sets the simplification queue attached to the scene
  55974. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55975. */
  55976. simplificationQueue: SimplificationQueue;
  55977. }
  55978. }
  55979. module "babylonjs/Meshes/mesh" {
  55980. interface Mesh {
  55981. /**
  55982. * Simplify the mesh according to the given array of settings.
  55983. * Function will return immediately and will simplify async
  55984. * @param settings a collection of simplification settings
  55985. * @param parallelProcessing should all levels calculate parallel or one after the other
  55986. * @param simplificationType the type of simplification to run
  55987. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55988. * @returns the current mesh
  55989. */
  55990. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55991. }
  55992. }
  55993. /**
  55994. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55995. * created in a scene
  55996. */
  55997. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55998. /**
  55999. * The component name helpfull to identify the component in the list of scene components.
  56000. */
  56001. readonly name: string;
  56002. /**
  56003. * The scene the component belongs to.
  56004. */
  56005. scene: Scene;
  56006. /**
  56007. * Creates a new instance of the component for the given scene
  56008. * @param scene Defines the scene to register the component in
  56009. */
  56010. constructor(scene: Scene);
  56011. /**
  56012. * Registers the component in a given scene
  56013. */
  56014. register(): void;
  56015. /**
  56016. * Rebuilds the elements related to this component in case of
  56017. * context lost for instance.
  56018. */
  56019. rebuild(): void;
  56020. /**
  56021. * Disposes the component and the associated ressources
  56022. */
  56023. dispose(): void;
  56024. private _beforeCameraUpdate;
  56025. }
  56026. }
  56027. declare module "babylonjs/Meshes/Builders/index" {
  56028. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56029. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56030. export * from "babylonjs/Meshes/Builders/discBuilder";
  56031. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56032. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56033. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56034. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56035. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56036. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56037. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56038. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56039. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56040. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56041. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56042. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56043. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56044. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56045. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56046. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56047. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56048. }
  56049. declare module "babylonjs/Meshes/index" {
  56050. export * from "babylonjs/Meshes/abstractMesh";
  56051. export * from "babylonjs/Meshes/buffer";
  56052. export * from "babylonjs/Meshes/Compression/index";
  56053. export * from "babylonjs/Meshes/csg";
  56054. export * from "babylonjs/Meshes/geometry";
  56055. export * from "babylonjs/Meshes/groundMesh";
  56056. export * from "babylonjs/Meshes/trailMesh";
  56057. export * from "babylonjs/Meshes/instancedMesh";
  56058. export * from "babylonjs/Meshes/linesMesh";
  56059. export * from "babylonjs/Meshes/mesh";
  56060. export * from "babylonjs/Meshes/mesh.vertexData";
  56061. export * from "babylonjs/Meshes/meshBuilder";
  56062. export * from "babylonjs/Meshes/meshSimplification";
  56063. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56064. export * from "babylonjs/Meshes/polygonMesh";
  56065. export * from "babylonjs/Meshes/subMesh";
  56066. export * from "babylonjs/Meshes/meshLODLevel";
  56067. export * from "babylonjs/Meshes/transformNode";
  56068. export * from "babylonjs/Meshes/Builders/index";
  56069. export * from "babylonjs/Meshes/dataBuffer";
  56070. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56071. }
  56072. declare module "babylonjs/Morph/index" {
  56073. export * from "babylonjs/Morph/morphTarget";
  56074. export * from "babylonjs/Morph/morphTargetManager";
  56075. }
  56076. declare module "babylonjs/Offline/database" {
  56077. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56078. /**
  56079. * Class used to enable access to IndexedDB
  56080. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56081. */
  56082. export class Database implements IOfflineProvider {
  56083. private _callbackManifestChecked;
  56084. private _currentSceneUrl;
  56085. private _db;
  56086. private _enableSceneOffline;
  56087. private _enableTexturesOffline;
  56088. private _manifestVersionFound;
  56089. private _mustUpdateRessources;
  56090. private _hasReachedQuota;
  56091. private _isSupported;
  56092. private _idbFactory;
  56093. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56094. private static IsUASupportingBlobStorage;
  56095. /**
  56096. * Gets a boolean indicating if Database storate is enabled (off by default)
  56097. */
  56098. static IDBStorageEnabled: boolean;
  56099. /**
  56100. * Gets a boolean indicating if scene must be saved in the database
  56101. */
  56102. readonly enableSceneOffline: boolean;
  56103. /**
  56104. * Gets a boolean indicating if textures must be saved in the database
  56105. */
  56106. readonly enableTexturesOffline: boolean;
  56107. /**
  56108. * Creates a new Database
  56109. * @param urlToScene defines the url to load the scene
  56110. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56111. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56112. */
  56113. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56114. private static _ParseURL;
  56115. private static _ReturnFullUrlLocation;
  56116. private _checkManifestFile;
  56117. /**
  56118. * Open the database and make it available
  56119. * @param successCallback defines the callback to call on success
  56120. * @param errorCallback defines the callback to call on error
  56121. */
  56122. open(successCallback: () => void, errorCallback: () => void): void;
  56123. /**
  56124. * Loads an image from the database
  56125. * @param url defines the url to load from
  56126. * @param image defines the target DOM image
  56127. */
  56128. loadImage(url: string, image: HTMLImageElement): void;
  56129. private _loadImageFromDBAsync;
  56130. private _saveImageIntoDBAsync;
  56131. private _checkVersionFromDB;
  56132. private _loadVersionFromDBAsync;
  56133. private _saveVersionIntoDBAsync;
  56134. /**
  56135. * Loads a file from database
  56136. * @param url defines the URL to load from
  56137. * @param sceneLoaded defines a callback to call on success
  56138. * @param progressCallBack defines a callback to call when progress changed
  56139. * @param errorCallback defines a callback to call on error
  56140. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56141. */
  56142. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56143. private _loadFileAsync;
  56144. private _saveFileAsync;
  56145. /**
  56146. * Validates if xhr data is correct
  56147. * @param xhr defines the request to validate
  56148. * @param dataType defines the expected data type
  56149. * @returns true if data is correct
  56150. */
  56151. private static _ValidateXHRData;
  56152. }
  56153. }
  56154. declare module "babylonjs/Offline/index" {
  56155. export * from "babylonjs/Offline/database";
  56156. export * from "babylonjs/Offline/IOfflineProvider";
  56157. }
  56158. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56159. /** @hidden */
  56160. export var gpuUpdateParticlesPixelShader: {
  56161. name: string;
  56162. shader: string;
  56163. };
  56164. }
  56165. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56166. /** @hidden */
  56167. export var gpuUpdateParticlesVertexShader: {
  56168. name: string;
  56169. shader: string;
  56170. };
  56171. }
  56172. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56173. /** @hidden */
  56174. export var clipPlaneFragmentDeclaration2: {
  56175. name: string;
  56176. shader: string;
  56177. };
  56178. }
  56179. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56180. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56181. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56182. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56183. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56184. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56185. /** @hidden */
  56186. export var gpuRenderParticlesPixelShader: {
  56187. name: string;
  56188. shader: string;
  56189. };
  56190. }
  56191. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56192. /** @hidden */
  56193. export var clipPlaneVertexDeclaration2: {
  56194. name: string;
  56195. shader: string;
  56196. };
  56197. }
  56198. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56199. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56200. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56201. /** @hidden */
  56202. export var gpuRenderParticlesVertexShader: {
  56203. name: string;
  56204. shader: string;
  56205. };
  56206. }
  56207. declare module "babylonjs/Particles/gpuParticleSystem" {
  56208. import { Nullable } from "babylonjs/types";
  56209. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56210. import { Observable } from "babylonjs/Misc/observable";
  56211. import { Color4, Color3 } from "babylonjs/Maths/math";
  56212. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56213. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56214. import { Scene, IDisposable } from "babylonjs/scene";
  56215. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56216. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56217. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56218. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56219. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56220. /**
  56221. * This represents a GPU particle system in Babylon
  56222. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56223. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56224. */
  56225. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56226. /**
  56227. * The layer mask we are rendering the particles through.
  56228. */
  56229. layerMask: number;
  56230. private _capacity;
  56231. private _activeCount;
  56232. private _currentActiveCount;
  56233. private _accumulatedCount;
  56234. private _renderEffect;
  56235. private _updateEffect;
  56236. private _buffer0;
  56237. private _buffer1;
  56238. private _spriteBuffer;
  56239. private _updateVAO;
  56240. private _renderVAO;
  56241. private _targetIndex;
  56242. private _sourceBuffer;
  56243. private _targetBuffer;
  56244. private _engine;
  56245. private _currentRenderId;
  56246. private _started;
  56247. private _stopped;
  56248. private _timeDelta;
  56249. private _randomTexture;
  56250. private _randomTexture2;
  56251. private _attributesStrideSize;
  56252. private _updateEffectOptions;
  56253. private _randomTextureSize;
  56254. private _actualFrame;
  56255. private readonly _rawTextureWidth;
  56256. /**
  56257. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56258. */
  56259. static readonly IsSupported: boolean;
  56260. /**
  56261. * An event triggered when the system is disposed.
  56262. */
  56263. onDisposeObservable: Observable<GPUParticleSystem>;
  56264. /**
  56265. * Gets the maximum number of particles active at the same time.
  56266. * @returns The max number of active particles.
  56267. */
  56268. getCapacity(): number;
  56269. /**
  56270. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56271. * to override the particles.
  56272. */
  56273. forceDepthWrite: boolean;
  56274. /**
  56275. * Gets or set the number of active particles
  56276. */
  56277. activeParticleCount: number;
  56278. private _preWarmDone;
  56279. /**
  56280. * Is this system ready to be used/rendered
  56281. * @return true if the system is ready
  56282. */
  56283. isReady(): boolean;
  56284. /**
  56285. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56286. * @returns True if it has been started, otherwise false.
  56287. */
  56288. isStarted(): boolean;
  56289. /**
  56290. * Starts the particle system and begins to emit
  56291. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56292. */
  56293. start(delay?: number): void;
  56294. /**
  56295. * Stops the particle system.
  56296. */
  56297. stop(): void;
  56298. /**
  56299. * Remove all active particles
  56300. */
  56301. reset(): void;
  56302. /**
  56303. * Returns the string "GPUParticleSystem"
  56304. * @returns a string containing the class name
  56305. */
  56306. getClassName(): string;
  56307. private _colorGradientsTexture;
  56308. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56309. /**
  56310. * Adds a new color gradient
  56311. * @param gradient defines the gradient to use (between 0 and 1)
  56312. * @param color1 defines the color to affect to the specified gradient
  56313. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56314. * @returns the current particle system
  56315. */
  56316. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56317. /**
  56318. * Remove a specific color gradient
  56319. * @param gradient defines the gradient to remove
  56320. * @returns the current particle system
  56321. */
  56322. removeColorGradient(gradient: number): GPUParticleSystem;
  56323. private _angularSpeedGradientsTexture;
  56324. private _sizeGradientsTexture;
  56325. private _velocityGradientsTexture;
  56326. private _limitVelocityGradientsTexture;
  56327. private _dragGradientsTexture;
  56328. private _addFactorGradient;
  56329. /**
  56330. * Adds a new size gradient
  56331. * @param gradient defines the gradient to use (between 0 and 1)
  56332. * @param factor defines the size factor to affect to the specified gradient
  56333. * @returns the current particle system
  56334. */
  56335. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56336. /**
  56337. * Remove a specific size gradient
  56338. * @param gradient defines the gradient to remove
  56339. * @returns the current particle system
  56340. */
  56341. removeSizeGradient(gradient: number): GPUParticleSystem;
  56342. /**
  56343. * Adds a new angular speed gradient
  56344. * @param gradient defines the gradient to use (between 0 and 1)
  56345. * @param factor defines the angular speed to affect to the specified gradient
  56346. * @returns the current particle system
  56347. */
  56348. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56349. /**
  56350. * Remove a specific angular speed gradient
  56351. * @param gradient defines the gradient to remove
  56352. * @returns the current particle system
  56353. */
  56354. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56355. /**
  56356. * Adds a new velocity gradient
  56357. * @param gradient defines the gradient to use (between 0 and 1)
  56358. * @param factor defines the velocity to affect to the specified gradient
  56359. * @returns the current particle system
  56360. */
  56361. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56362. /**
  56363. * Remove a specific velocity gradient
  56364. * @param gradient defines the gradient to remove
  56365. * @returns the current particle system
  56366. */
  56367. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56368. /**
  56369. * Adds a new limit velocity gradient
  56370. * @param gradient defines the gradient to use (between 0 and 1)
  56371. * @param factor defines the limit velocity value to affect to the specified gradient
  56372. * @returns the current particle system
  56373. */
  56374. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56375. /**
  56376. * Remove a specific limit velocity gradient
  56377. * @param gradient defines the gradient to remove
  56378. * @returns the current particle system
  56379. */
  56380. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56381. /**
  56382. * Adds a new drag gradient
  56383. * @param gradient defines the gradient to use (between 0 and 1)
  56384. * @param factor defines the drag value to affect to the specified gradient
  56385. * @returns the current particle system
  56386. */
  56387. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56388. /**
  56389. * Remove a specific drag gradient
  56390. * @param gradient defines the gradient to remove
  56391. * @returns the current particle system
  56392. */
  56393. removeDragGradient(gradient: number): GPUParticleSystem;
  56394. /**
  56395. * Not supported by GPUParticleSystem
  56396. * @param gradient defines the gradient to use (between 0 and 1)
  56397. * @param factor defines the emit rate value to affect to the specified gradient
  56398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56399. * @returns the current particle system
  56400. */
  56401. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56402. /**
  56403. * Not supported by GPUParticleSystem
  56404. * @param gradient defines the gradient to remove
  56405. * @returns the current particle system
  56406. */
  56407. removeEmitRateGradient(gradient: number): IParticleSystem;
  56408. /**
  56409. * Not supported by GPUParticleSystem
  56410. * @param gradient defines the gradient to use (between 0 and 1)
  56411. * @param factor defines the start size value to affect to the specified gradient
  56412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56413. * @returns the current particle system
  56414. */
  56415. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56416. /**
  56417. * Not supported by GPUParticleSystem
  56418. * @param gradient defines the gradient to remove
  56419. * @returns the current particle system
  56420. */
  56421. removeStartSizeGradient(gradient: number): IParticleSystem;
  56422. /**
  56423. * Not supported by GPUParticleSystem
  56424. * @param gradient defines the gradient to use (between 0 and 1)
  56425. * @param min defines the color remap minimal range
  56426. * @param max defines the color remap maximal range
  56427. * @returns the current particle system
  56428. */
  56429. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56430. /**
  56431. * Not supported by GPUParticleSystem
  56432. * @param gradient defines the gradient to remove
  56433. * @returns the current particle system
  56434. */
  56435. removeColorRemapGradient(): IParticleSystem;
  56436. /**
  56437. * Not supported by GPUParticleSystem
  56438. * @param gradient defines the gradient to use (between 0 and 1)
  56439. * @param min defines the alpha remap minimal range
  56440. * @param max defines the alpha remap maximal range
  56441. * @returns the current particle system
  56442. */
  56443. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56444. /**
  56445. * Not supported by GPUParticleSystem
  56446. * @param gradient defines the gradient to remove
  56447. * @returns the current particle system
  56448. */
  56449. removeAlphaRemapGradient(): IParticleSystem;
  56450. /**
  56451. * Not supported by GPUParticleSystem
  56452. * @param gradient defines the gradient to use (between 0 and 1)
  56453. * @param color defines the color to affect to the specified gradient
  56454. * @returns the current particle system
  56455. */
  56456. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56457. /**
  56458. * Not supported by GPUParticleSystem
  56459. * @param gradient defines the gradient to remove
  56460. * @returns the current particle system
  56461. */
  56462. removeRampGradient(): IParticleSystem;
  56463. /**
  56464. * Not supported by GPUParticleSystem
  56465. * @returns the list of ramp gradients
  56466. */
  56467. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56468. /**
  56469. * Not supported by GPUParticleSystem
  56470. * Gets or sets a boolean indicating that ramp gradients must be used
  56471. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56472. */
  56473. useRampGradients: boolean;
  56474. /**
  56475. * Not supported by GPUParticleSystem
  56476. * @param gradient defines the gradient to use (between 0 and 1)
  56477. * @param factor defines the life time factor to affect to the specified gradient
  56478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56479. * @returns the current particle system
  56480. */
  56481. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56482. /**
  56483. * Not supported by GPUParticleSystem
  56484. * @param gradient defines the gradient to remove
  56485. * @returns the current particle system
  56486. */
  56487. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56488. /**
  56489. * Instantiates a GPU particle system.
  56490. * 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.
  56491. * @param name The name of the particle system
  56492. * @param options The options used to create the system
  56493. * @param scene The scene the particle system belongs to
  56494. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56495. */
  56496. constructor(name: string, options: Partial<{
  56497. capacity: number;
  56498. randomTextureSize: number;
  56499. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56500. protected _reset(): void;
  56501. private _createUpdateVAO;
  56502. private _createRenderVAO;
  56503. private _initialize;
  56504. /** @hidden */
  56505. _recreateUpdateEffect(): void;
  56506. /** @hidden */
  56507. _recreateRenderEffect(): void;
  56508. /**
  56509. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56510. * @param preWarm defines if we are in the pre-warmimg phase
  56511. */
  56512. animate(preWarm?: boolean): void;
  56513. private _createFactorGradientTexture;
  56514. private _createSizeGradientTexture;
  56515. private _createAngularSpeedGradientTexture;
  56516. private _createVelocityGradientTexture;
  56517. private _createLimitVelocityGradientTexture;
  56518. private _createDragGradientTexture;
  56519. private _createColorGradientTexture;
  56520. /**
  56521. * Renders the particle system in its current state
  56522. * @param preWarm defines if the system should only update the particles but not render them
  56523. * @returns the current number of particles
  56524. */
  56525. render(preWarm?: boolean): number;
  56526. /**
  56527. * Rebuilds the particle system
  56528. */
  56529. rebuild(): void;
  56530. private _releaseBuffers;
  56531. private _releaseVAOs;
  56532. /**
  56533. * Disposes the particle system and free the associated resources
  56534. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56535. */
  56536. dispose(disposeTexture?: boolean): void;
  56537. /**
  56538. * Clones the particle system.
  56539. * @param name The name of the cloned object
  56540. * @param newEmitter The new emitter to use
  56541. * @returns the cloned particle system
  56542. */
  56543. clone(name: string, newEmitter: any): GPUParticleSystem;
  56544. /**
  56545. * Serializes the particle system to a JSON object.
  56546. * @returns the JSON object
  56547. */
  56548. serialize(): any;
  56549. /**
  56550. * Parses a JSON object to create a GPU particle system.
  56551. * @param parsedParticleSystem The JSON object to parse
  56552. * @param scene The scene to create the particle system in
  56553. * @param rootUrl The root url to use to load external dependencies like texture
  56554. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56555. * @returns the parsed GPU particle system
  56556. */
  56557. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56558. }
  56559. }
  56560. declare module "babylonjs/Particles/particleSystemSet" {
  56561. import { Nullable } from "babylonjs/types";
  56562. import { Color3 } from "babylonjs/Maths/math";
  56563. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56565. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56566. import { Scene, IDisposable } from "babylonjs/scene";
  56567. /**
  56568. * Represents a set of particle systems working together to create a specific effect
  56569. */
  56570. export class ParticleSystemSet implements IDisposable {
  56571. private _emitterCreationOptions;
  56572. private _emitterNode;
  56573. /**
  56574. * Gets the particle system list
  56575. */
  56576. systems: IParticleSystem[];
  56577. /**
  56578. * Gets the emitter node used with this set
  56579. */
  56580. readonly emitterNode: Nullable<TransformNode>;
  56581. /**
  56582. * Creates a new emitter mesh as a sphere
  56583. * @param options defines the options used to create the sphere
  56584. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56585. * @param scene defines the hosting scene
  56586. */
  56587. setEmitterAsSphere(options: {
  56588. diameter: number;
  56589. segments: number;
  56590. color: Color3;
  56591. }, renderingGroupId: number, scene: Scene): void;
  56592. /**
  56593. * Starts all particle systems of the set
  56594. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56595. */
  56596. start(emitter?: AbstractMesh): void;
  56597. /**
  56598. * Release all associated resources
  56599. */
  56600. dispose(): void;
  56601. /**
  56602. * Serialize the set into a JSON compatible object
  56603. * @returns a JSON compatible representation of the set
  56604. */
  56605. serialize(): any;
  56606. /**
  56607. * Parse a new ParticleSystemSet from a serialized source
  56608. * @param data defines a JSON compatible representation of the set
  56609. * @param scene defines the hosting scene
  56610. * @param gpu defines if we want GPU particles or CPU particles
  56611. * @returns a new ParticleSystemSet
  56612. */
  56613. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56614. }
  56615. }
  56616. declare module "babylonjs/Particles/particleHelper" {
  56617. import { Nullable } from "babylonjs/types";
  56618. import { Scene } from "babylonjs/scene";
  56619. import { Vector3 } from "babylonjs/Maths/math";
  56620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56621. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56622. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56623. /**
  56624. * This class is made for on one-liner static method to help creating particle system set.
  56625. */
  56626. export class ParticleHelper {
  56627. /**
  56628. * Gets or sets base Assets URL
  56629. */
  56630. static BaseAssetsUrl: string;
  56631. /**
  56632. * Create a default particle system that you can tweak
  56633. * @param emitter defines the emitter to use
  56634. * @param capacity defines the system capacity (default is 500 particles)
  56635. * @param scene defines the hosting scene
  56636. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56637. * @returns the new Particle system
  56638. */
  56639. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56640. /**
  56641. * This is the main static method (one-liner) of this helper to create different particle systems
  56642. * @param type This string represents the type to the particle system to create
  56643. * @param scene The scene where the particle system should live
  56644. * @param gpu If the system will use gpu
  56645. * @returns the ParticleSystemSet created
  56646. */
  56647. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56648. /**
  56649. * Static function used to export a particle system to a ParticleSystemSet variable.
  56650. * Please note that the emitter shape is not exported
  56651. * @param systems defines the particle systems to export
  56652. * @returns the created particle system set
  56653. */
  56654. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56655. }
  56656. }
  56657. declare module "babylonjs/Particles/particleSystemComponent" {
  56658. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56659. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  56660. import "babylonjs/Shaders/particles.vertex";
  56661. module "babylonjs/Engines/engine" {
  56662. interface Engine {
  56663. /**
  56664. * Create an effect to use with particle systems.
  56665. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56666. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56667. * @param uniformsNames defines a list of attribute names
  56668. * @param samplers defines an array of string used to represent textures
  56669. * @param defines defines the string containing the defines to use to compile the shaders
  56670. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56671. * @param onCompiled defines a function to call when the effect creation is successful
  56672. * @param onError defines a function to call when the effect creation has failed
  56673. * @returns the new Effect
  56674. */
  56675. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56676. }
  56677. }
  56678. module "babylonjs/Meshes/mesh" {
  56679. interface Mesh {
  56680. /**
  56681. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56682. * @returns an array of IParticleSystem
  56683. */
  56684. getEmittedParticleSystems(): IParticleSystem[];
  56685. /**
  56686. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56687. * @returns an array of IParticleSystem
  56688. */
  56689. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56690. }
  56691. }
  56692. /**
  56693. * @hidden
  56694. */
  56695. export var _IDoNeedToBeInTheBuild: number;
  56696. }
  56697. declare module "babylonjs/Particles/index" {
  56698. export * from "babylonjs/Particles/baseParticleSystem";
  56699. export * from "babylonjs/Particles/EmitterTypes/index";
  56700. export * from "babylonjs/Particles/gpuParticleSystem";
  56701. export * from "babylonjs/Particles/IParticleSystem";
  56702. export * from "babylonjs/Particles/particle";
  56703. export * from "babylonjs/Particles/particleHelper";
  56704. export * from "babylonjs/Particles/particleSystem";
  56705. export * from "babylonjs/Particles/particleSystemComponent";
  56706. export * from "babylonjs/Particles/particleSystemSet";
  56707. export * from "babylonjs/Particles/solidParticle";
  56708. export * from "babylonjs/Particles/solidParticleSystem";
  56709. export * from "babylonjs/Particles/subEmitter";
  56710. }
  56711. declare module "babylonjs/Physics/physicsEngineComponent" {
  56712. import { Nullable } from "babylonjs/types";
  56713. import { Observable, Observer } from "babylonjs/Misc/observable";
  56714. import { Vector3 } from "babylonjs/Maths/math";
  56715. import { Mesh } from "babylonjs/Meshes/mesh";
  56716. import { ISceneComponent } from "babylonjs/sceneComponent";
  56717. import { Scene } from "babylonjs/scene";
  56718. import { Node } from "babylonjs/node";
  56719. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56720. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56721. module "babylonjs/scene" {
  56722. interface Scene {
  56723. /** @hidden (Backing field) */
  56724. _physicsEngine: Nullable<IPhysicsEngine>;
  56725. /**
  56726. * Gets the current physics engine
  56727. * @returns a IPhysicsEngine or null if none attached
  56728. */
  56729. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56730. /**
  56731. * Enables physics to the current scene
  56732. * @param gravity defines the scene's gravity for the physics engine
  56733. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56734. * @return a boolean indicating if the physics engine was initialized
  56735. */
  56736. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56737. /**
  56738. * Disables and disposes the physics engine associated with the scene
  56739. */
  56740. disablePhysicsEngine(): void;
  56741. /**
  56742. * Gets a boolean indicating if there is an active physics engine
  56743. * @returns a boolean indicating if there is an active physics engine
  56744. */
  56745. isPhysicsEnabled(): boolean;
  56746. /**
  56747. * Deletes a physics compound impostor
  56748. * @param compound defines the compound to delete
  56749. */
  56750. deleteCompoundImpostor(compound: any): void;
  56751. /**
  56752. * An event triggered when physic simulation is about to be run
  56753. */
  56754. onBeforePhysicsObservable: Observable<Scene>;
  56755. /**
  56756. * An event triggered when physic simulation has been done
  56757. */
  56758. onAfterPhysicsObservable: Observable<Scene>;
  56759. }
  56760. }
  56761. module "babylonjs/Meshes/abstractMesh" {
  56762. interface AbstractMesh {
  56763. /** @hidden */
  56764. _physicsImpostor: Nullable<PhysicsImpostor>;
  56765. /**
  56766. * Gets or sets impostor used for physic simulation
  56767. * @see http://doc.babylonjs.com/features/physics_engine
  56768. */
  56769. physicsImpostor: Nullable<PhysicsImpostor>;
  56770. /**
  56771. * Gets the current physics impostor
  56772. * @see http://doc.babylonjs.com/features/physics_engine
  56773. * @returns a physics impostor or null
  56774. */
  56775. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56776. /** Apply a physic impulse to the mesh
  56777. * @param force defines the force to apply
  56778. * @param contactPoint defines where to apply the force
  56779. * @returns the current mesh
  56780. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56781. */
  56782. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56783. /**
  56784. * Creates a physic joint between two meshes
  56785. * @param otherMesh defines the other mesh to use
  56786. * @param pivot1 defines the pivot to use on this mesh
  56787. * @param pivot2 defines the pivot to use on the other mesh
  56788. * @param options defines additional options (can be plugin dependent)
  56789. * @returns the current mesh
  56790. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56791. */
  56792. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56793. /** @hidden */
  56794. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56795. }
  56796. }
  56797. /**
  56798. * Defines the physics engine scene component responsible to manage a physics engine
  56799. */
  56800. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56801. /**
  56802. * The component name helpful to identify the component in the list of scene components.
  56803. */
  56804. readonly name: string;
  56805. /**
  56806. * The scene the component belongs to.
  56807. */
  56808. scene: Scene;
  56809. /**
  56810. * Creates a new instance of the component for the given scene
  56811. * @param scene Defines the scene to register the component in
  56812. */
  56813. constructor(scene: Scene);
  56814. /**
  56815. * Registers the component in a given scene
  56816. */
  56817. register(): void;
  56818. /**
  56819. * Rebuilds the elements related to this component in case of
  56820. * context lost for instance.
  56821. */
  56822. rebuild(): void;
  56823. /**
  56824. * Disposes the component and the associated ressources
  56825. */
  56826. dispose(): void;
  56827. }
  56828. }
  56829. declare module "babylonjs/Physics/physicsHelper" {
  56830. import { Nullable } from "babylonjs/types";
  56831. import { Vector3 } from "babylonjs/Maths/math";
  56832. import { Mesh } from "babylonjs/Meshes/mesh";
  56833. import { Scene } from "babylonjs/scene";
  56834. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56835. /**
  56836. * A helper for physics simulations
  56837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56838. */
  56839. export class PhysicsHelper {
  56840. private _scene;
  56841. private _physicsEngine;
  56842. /**
  56843. * Initializes the Physics helper
  56844. * @param scene Babylon.js scene
  56845. */
  56846. constructor(scene: Scene);
  56847. /**
  56848. * Applies a radial explosion impulse
  56849. * @param origin the origin of the explosion
  56850. * @param radiusOrEventOptions the radius or the options of radial explosion
  56851. * @param strength the explosion strength
  56852. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56853. * @returns A physics radial explosion event, or null
  56854. */
  56855. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56856. /**
  56857. * Applies a radial explosion force
  56858. * @param origin the origin of the explosion
  56859. * @param radiusOrEventOptions the radius or the options of radial explosion
  56860. * @param strength the explosion strength
  56861. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56862. * @returns A physics radial explosion event, or null
  56863. */
  56864. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56865. /**
  56866. * Creates a gravitational field
  56867. * @param origin the origin of the explosion
  56868. * @param radiusOrEventOptions the radius or the options of radial explosion
  56869. * @param strength the explosion strength
  56870. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56871. * @returns A physics gravitational field event, or null
  56872. */
  56873. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56874. /**
  56875. * Creates a physics updraft event
  56876. * @param origin the origin of the updraft
  56877. * @param radiusOrEventOptions the radius or the options of the updraft
  56878. * @param strength the strength of the updraft
  56879. * @param height the height of the updraft
  56880. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56881. * @returns A physics updraft event, or null
  56882. */
  56883. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56884. /**
  56885. * Creates a physics vortex event
  56886. * @param origin the of the vortex
  56887. * @param radiusOrEventOptions the radius or the options of the vortex
  56888. * @param strength the strength of the vortex
  56889. * @param height the height of the vortex
  56890. * @returns a Physics vortex event, or null
  56891. * A physics vortex event or null
  56892. */
  56893. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56894. }
  56895. /**
  56896. * Represents a physics radial explosion event
  56897. */
  56898. class PhysicsRadialExplosionEvent {
  56899. private _scene;
  56900. private _options;
  56901. private _sphere;
  56902. private _dataFetched;
  56903. /**
  56904. * Initializes a radial explosioin event
  56905. * @param _scene BabylonJS scene
  56906. * @param _options The options for the vortex event
  56907. */
  56908. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56909. /**
  56910. * Returns the data related to the radial explosion event (sphere).
  56911. * @returns The radial explosion event data
  56912. */
  56913. getData(): PhysicsRadialExplosionEventData;
  56914. /**
  56915. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56916. * @param impostor A physics imposter
  56917. * @param origin the origin of the explosion
  56918. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56919. */
  56920. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56921. /**
  56922. * Triggers affecterd impostors callbacks
  56923. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56924. */
  56925. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56926. /**
  56927. * Disposes the sphere.
  56928. * @param force Specifies if the sphere should be disposed by force
  56929. */
  56930. dispose(force?: boolean): void;
  56931. /*** Helpers ***/
  56932. private _prepareSphere;
  56933. private _intersectsWithSphere;
  56934. }
  56935. /**
  56936. * Represents a gravitational field event
  56937. */
  56938. class PhysicsGravitationalFieldEvent {
  56939. private _physicsHelper;
  56940. private _scene;
  56941. private _origin;
  56942. private _options;
  56943. private _tickCallback;
  56944. private _sphere;
  56945. private _dataFetched;
  56946. /**
  56947. * Initializes the physics gravitational field event
  56948. * @param _physicsHelper A physics helper
  56949. * @param _scene BabylonJS scene
  56950. * @param _origin The origin position of the gravitational field event
  56951. * @param _options The options for the vortex event
  56952. */
  56953. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56954. /**
  56955. * Returns the data related to the gravitational field event (sphere).
  56956. * @returns A gravitational field event
  56957. */
  56958. getData(): PhysicsGravitationalFieldEventData;
  56959. /**
  56960. * Enables the gravitational field.
  56961. */
  56962. enable(): void;
  56963. /**
  56964. * Disables the gravitational field.
  56965. */
  56966. disable(): void;
  56967. /**
  56968. * Disposes the sphere.
  56969. * @param force The force to dispose from the gravitational field event
  56970. */
  56971. dispose(force?: boolean): void;
  56972. private _tick;
  56973. }
  56974. /**
  56975. * Represents a physics updraft event
  56976. */
  56977. class PhysicsUpdraftEvent {
  56978. private _scene;
  56979. private _origin;
  56980. private _options;
  56981. private _physicsEngine;
  56982. private _originTop;
  56983. private _originDirection;
  56984. private _tickCallback;
  56985. private _cylinder;
  56986. private _cylinderPosition;
  56987. private _dataFetched;
  56988. /**
  56989. * Initializes the physics updraft event
  56990. * @param _scene BabylonJS scene
  56991. * @param _origin The origin position of the updraft
  56992. * @param _options The options for the updraft event
  56993. */
  56994. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56995. /**
  56996. * Returns the data related to the updraft event (cylinder).
  56997. * @returns A physics updraft event
  56998. */
  56999. getData(): PhysicsUpdraftEventData;
  57000. /**
  57001. * Enables the updraft.
  57002. */
  57003. enable(): void;
  57004. /**
  57005. * Disables the updraft.
  57006. */
  57007. disable(): void;
  57008. /**
  57009. * Disposes the cylinder.
  57010. * @param force Specifies if the updraft should be disposed by force
  57011. */
  57012. dispose(force?: boolean): void;
  57013. private getImpostorHitData;
  57014. private _tick;
  57015. /*** Helpers ***/
  57016. private _prepareCylinder;
  57017. private _intersectsWithCylinder;
  57018. }
  57019. /**
  57020. * Represents a physics vortex event
  57021. */
  57022. class PhysicsVortexEvent {
  57023. private _scene;
  57024. private _origin;
  57025. private _options;
  57026. private _physicsEngine;
  57027. private _originTop;
  57028. private _tickCallback;
  57029. private _cylinder;
  57030. private _cylinderPosition;
  57031. private _dataFetched;
  57032. /**
  57033. * Initializes the physics vortex event
  57034. * @param _scene The BabylonJS scene
  57035. * @param _origin The origin position of the vortex
  57036. * @param _options The options for the vortex event
  57037. */
  57038. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57039. /**
  57040. * Returns the data related to the vortex event (cylinder).
  57041. * @returns The physics vortex event data
  57042. */
  57043. getData(): PhysicsVortexEventData;
  57044. /**
  57045. * Enables the vortex.
  57046. */
  57047. enable(): void;
  57048. /**
  57049. * Disables the cortex.
  57050. */
  57051. disable(): void;
  57052. /**
  57053. * Disposes the sphere.
  57054. * @param force
  57055. */
  57056. dispose(force?: boolean): void;
  57057. private getImpostorHitData;
  57058. private _tick;
  57059. /*** Helpers ***/
  57060. private _prepareCylinder;
  57061. private _intersectsWithCylinder;
  57062. }
  57063. /**
  57064. * Options fot the radial explosion event
  57065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57066. */
  57067. export class PhysicsRadialExplosionEventOptions {
  57068. /**
  57069. * The radius of the sphere for the radial explosion.
  57070. */
  57071. radius: number;
  57072. /**
  57073. * The strenth of the explosion.
  57074. */
  57075. strength: number;
  57076. /**
  57077. * The strenght of the force in correspondence to the distance of the affected object
  57078. */
  57079. falloff: PhysicsRadialImpulseFalloff;
  57080. /**
  57081. * Sphere options for the radial explosion.
  57082. */
  57083. sphere: {
  57084. segments: number;
  57085. diameter: number;
  57086. };
  57087. /**
  57088. * Sphere options for the radial explosion.
  57089. */
  57090. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57091. }
  57092. /**
  57093. * Options fot the updraft event
  57094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57095. */
  57096. export class PhysicsUpdraftEventOptions {
  57097. /**
  57098. * The radius of the cylinder for the vortex
  57099. */
  57100. radius: number;
  57101. /**
  57102. * The strenth of the updraft.
  57103. */
  57104. strength: number;
  57105. /**
  57106. * The height of the cylinder for the updraft.
  57107. */
  57108. height: number;
  57109. /**
  57110. * The mode for the the updraft.
  57111. */
  57112. updraftMode: PhysicsUpdraftMode;
  57113. }
  57114. /**
  57115. * Options fot the vortex event
  57116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57117. */
  57118. export class PhysicsVortexEventOptions {
  57119. /**
  57120. * The radius of the cylinder for the vortex
  57121. */
  57122. radius: number;
  57123. /**
  57124. * The strenth of the vortex.
  57125. */
  57126. strength: number;
  57127. /**
  57128. * The height of the cylinder for the vortex.
  57129. */
  57130. height: number;
  57131. /**
  57132. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57133. */
  57134. centripetalForceThreshold: number;
  57135. /**
  57136. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57137. */
  57138. centripetalForceMultiplier: number;
  57139. /**
  57140. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57141. */
  57142. centrifugalForceMultiplier: number;
  57143. /**
  57144. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57145. */
  57146. updraftForceMultiplier: number;
  57147. }
  57148. /**
  57149. * The strenght of the force in correspondence to the distance of the affected object
  57150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57151. */
  57152. export enum PhysicsRadialImpulseFalloff {
  57153. /** Defines that impulse is constant in strength across it's whole radius */
  57154. Constant = 0,
  57155. /** Defines that impulse gets weaker if it's further from the origin */
  57156. Linear = 1
  57157. }
  57158. /**
  57159. * The strength of the force in correspondence to the distance of the affected object
  57160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57161. */
  57162. export enum PhysicsUpdraftMode {
  57163. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57164. Center = 0,
  57165. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57166. Perpendicular = 1
  57167. }
  57168. /**
  57169. * Interface for a physics hit data
  57170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57171. */
  57172. export interface PhysicsHitData {
  57173. /**
  57174. * The force applied at the contact point
  57175. */
  57176. force: Vector3;
  57177. /**
  57178. * The contact point
  57179. */
  57180. contactPoint: Vector3;
  57181. /**
  57182. * The distance from the origin to the contact point
  57183. */
  57184. distanceFromOrigin: number;
  57185. }
  57186. /**
  57187. * Interface for radial explosion event data
  57188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57189. */
  57190. export interface PhysicsRadialExplosionEventData {
  57191. /**
  57192. * A sphere used for the radial explosion event
  57193. */
  57194. sphere: Mesh;
  57195. }
  57196. /**
  57197. * Interface for gravitational field event data
  57198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57199. */
  57200. export interface PhysicsGravitationalFieldEventData {
  57201. /**
  57202. * A sphere mesh used for the gravitational field event
  57203. */
  57204. sphere: Mesh;
  57205. }
  57206. /**
  57207. * Interface for updraft event data
  57208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57209. */
  57210. export interface PhysicsUpdraftEventData {
  57211. /**
  57212. * A cylinder used for the updraft event
  57213. */
  57214. cylinder: Mesh;
  57215. }
  57216. /**
  57217. * Interface for vortex event data
  57218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57219. */
  57220. export interface PhysicsVortexEventData {
  57221. /**
  57222. * A cylinder used for the vortex event
  57223. */
  57224. cylinder: Mesh;
  57225. }
  57226. /**
  57227. * Interface for an affected physics impostor
  57228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57229. */
  57230. export interface PhysicsAffectedImpostorWithData {
  57231. /**
  57232. * The impostor affected by the effect
  57233. */
  57234. impostor: PhysicsImpostor;
  57235. /**
  57236. * The data about the hit/horce from the explosion
  57237. */
  57238. hitData: PhysicsHitData;
  57239. }
  57240. }
  57241. declare module "babylonjs/Physics/Plugins/index" {
  57242. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57243. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57244. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57245. }
  57246. declare module "babylonjs/Physics/index" {
  57247. export * from "babylonjs/Physics/IPhysicsEngine";
  57248. export * from "babylonjs/Physics/physicsEngine";
  57249. export * from "babylonjs/Physics/physicsEngineComponent";
  57250. export * from "babylonjs/Physics/physicsHelper";
  57251. export * from "babylonjs/Physics/physicsImpostor";
  57252. export * from "babylonjs/Physics/physicsJoint";
  57253. export * from "babylonjs/Physics/Plugins/index";
  57254. }
  57255. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57256. /** @hidden */
  57257. export var blackAndWhitePixelShader: {
  57258. name: string;
  57259. shader: string;
  57260. };
  57261. }
  57262. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57263. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57264. import { Camera } from "babylonjs/Cameras/camera";
  57265. import { Engine } from "babylonjs/Engines/engine";
  57266. import "babylonjs/Shaders/blackAndWhite.fragment";
  57267. /**
  57268. * Post process used to render in black and white
  57269. */
  57270. export class BlackAndWhitePostProcess extends PostProcess {
  57271. /**
  57272. * Linear about to convert he result to black and white (default: 1)
  57273. */
  57274. degree: number;
  57275. /**
  57276. * Creates a black and white post process
  57277. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57278. * @param name The name of the effect.
  57279. * @param options The required width/height ratio to downsize to before computing the render pass.
  57280. * @param camera The camera to apply the render pass to.
  57281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57282. * @param engine The engine which the post process will be applied. (default: current engine)
  57283. * @param reusable If the post process can be reused on the same frame. (default: false)
  57284. */
  57285. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57286. }
  57287. }
  57288. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57289. import { Nullable } from "babylonjs/types";
  57290. import { Camera } from "babylonjs/Cameras/camera";
  57291. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57292. import { Engine } from "babylonjs/Engines/engine";
  57293. /**
  57294. * This represents a set of one or more post processes in Babylon.
  57295. * A post process can be used to apply a shader to a texture after it is rendered.
  57296. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57297. */
  57298. export class PostProcessRenderEffect {
  57299. private _postProcesses;
  57300. private _getPostProcesses;
  57301. private _singleInstance;
  57302. private _cameras;
  57303. private _indicesForCamera;
  57304. /**
  57305. * Name of the effect
  57306. * @hidden
  57307. */
  57308. _name: string;
  57309. /**
  57310. * Instantiates a post process render effect.
  57311. * A post process can be used to apply a shader to a texture after it is rendered.
  57312. * @param engine The engine the effect is tied to
  57313. * @param name The name of the effect
  57314. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57315. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57316. */
  57317. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57318. /**
  57319. * Checks if all the post processes in the effect are supported.
  57320. */
  57321. readonly isSupported: boolean;
  57322. /**
  57323. * Updates the current state of the effect
  57324. * @hidden
  57325. */
  57326. _update(): void;
  57327. /**
  57328. * Attaches the effect on cameras
  57329. * @param cameras The camera to attach to.
  57330. * @hidden
  57331. */
  57332. _attachCameras(cameras: Camera): void;
  57333. /**
  57334. * Attaches the effect on cameras
  57335. * @param cameras The camera to attach to.
  57336. * @hidden
  57337. */
  57338. _attachCameras(cameras: Camera[]): void;
  57339. /**
  57340. * Detaches the effect on cameras
  57341. * @param cameras The camera to detatch from.
  57342. * @hidden
  57343. */
  57344. _detachCameras(cameras: Camera): void;
  57345. /**
  57346. * Detatches the effect on cameras
  57347. * @param cameras The camera to detatch from.
  57348. * @hidden
  57349. */
  57350. _detachCameras(cameras: Camera[]): void;
  57351. /**
  57352. * Enables the effect on given cameras
  57353. * @param cameras The camera to enable.
  57354. * @hidden
  57355. */
  57356. _enable(cameras: Camera): void;
  57357. /**
  57358. * Enables the effect on given cameras
  57359. * @param cameras The camera to enable.
  57360. * @hidden
  57361. */
  57362. _enable(cameras: Nullable<Camera[]>): void;
  57363. /**
  57364. * Disables the effect on the given cameras
  57365. * @param cameras The camera to disable.
  57366. * @hidden
  57367. */
  57368. _disable(cameras: Camera): void;
  57369. /**
  57370. * Disables the effect on the given cameras
  57371. * @param cameras The camera to disable.
  57372. * @hidden
  57373. */
  57374. _disable(cameras: Nullable<Camera[]>): void;
  57375. /**
  57376. * Gets a list of the post processes contained in the effect.
  57377. * @param camera The camera to get the post processes on.
  57378. * @returns The list of the post processes in the effect.
  57379. */
  57380. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57381. }
  57382. }
  57383. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57384. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57385. /** @hidden */
  57386. export var extractHighlightsPixelShader: {
  57387. name: string;
  57388. shader: string;
  57389. };
  57390. }
  57391. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57392. import { Nullable } from "babylonjs/types";
  57393. import { Camera } from "babylonjs/Cameras/camera";
  57394. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57395. import { Engine } from "babylonjs/Engines/engine";
  57396. import "babylonjs/Shaders/extractHighlights.fragment";
  57397. /**
  57398. * 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.
  57399. */
  57400. export class ExtractHighlightsPostProcess extends PostProcess {
  57401. /**
  57402. * The luminance threshold, pixels below this value will be set to black.
  57403. */
  57404. threshold: number;
  57405. /** @hidden */
  57406. _exposure: number;
  57407. /**
  57408. * Post process which has the input texture to be used when performing highlight extraction
  57409. * @hidden
  57410. */
  57411. _inputPostProcess: Nullable<PostProcess>;
  57412. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57413. }
  57414. }
  57415. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57416. /** @hidden */
  57417. export var bloomMergePixelShader: {
  57418. name: string;
  57419. shader: string;
  57420. };
  57421. }
  57422. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57423. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57424. import { Nullable } from "babylonjs/types";
  57425. import { Engine } from "babylonjs/Engines/engine";
  57426. import { Camera } from "babylonjs/Cameras/camera";
  57427. import "babylonjs/Shaders/bloomMerge.fragment";
  57428. /**
  57429. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57430. */
  57431. export class BloomMergePostProcess extends PostProcess {
  57432. /** Weight of the bloom to be added to the original input. */
  57433. weight: number;
  57434. /**
  57435. * Creates a new instance of @see BloomMergePostProcess
  57436. * @param name The name of the effect.
  57437. * @param originalFromInput Post process which's input will be used for the merge.
  57438. * @param blurred Blurred highlights post process which's output will be used.
  57439. * @param weight Weight of the bloom to be added to the original input.
  57440. * @param options The required width/height ratio to downsize to before computing the render pass.
  57441. * @param camera The camera to apply the render pass to.
  57442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57443. * @param engine The engine which the post process will be applied. (default: current engine)
  57444. * @param reusable If the post process can be reused on the same frame. (default: false)
  57445. * @param textureType Type of textures used when performing the post process. (default: 0)
  57446. * @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)
  57447. */
  57448. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57449. /** Weight of the bloom to be added to the original input. */
  57450. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57451. }
  57452. }
  57453. declare module "babylonjs/PostProcesses/bloomEffect" {
  57454. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57455. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57456. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57457. import { Camera } from "babylonjs/Cameras/camera";
  57458. import { Scene } from "babylonjs/scene";
  57459. /**
  57460. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57461. */
  57462. export class BloomEffect extends PostProcessRenderEffect {
  57463. private bloomScale;
  57464. /**
  57465. * @hidden Internal
  57466. */
  57467. _effects: Array<PostProcess>;
  57468. /**
  57469. * @hidden Internal
  57470. */
  57471. _downscale: ExtractHighlightsPostProcess;
  57472. private _blurX;
  57473. private _blurY;
  57474. private _merge;
  57475. /**
  57476. * The luminance threshold to find bright areas of the image to bloom.
  57477. */
  57478. threshold: number;
  57479. /**
  57480. * The strength of the bloom.
  57481. */
  57482. weight: number;
  57483. /**
  57484. * Specifies the size of the bloom blur kernel, relative to the final output size
  57485. */
  57486. kernel: number;
  57487. /**
  57488. * Creates a new instance of @see BloomEffect
  57489. * @param scene The scene the effect belongs to.
  57490. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57491. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57492. * @param bloomWeight The the strength of bloom.
  57493. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57494. * @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)
  57495. */
  57496. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57497. /**
  57498. * Disposes each of the internal effects for a given camera.
  57499. * @param camera The camera to dispose the effect on.
  57500. */
  57501. disposeEffects(camera: Camera): void;
  57502. /**
  57503. * @hidden Internal
  57504. */
  57505. _updateEffects(): void;
  57506. /**
  57507. * Internal
  57508. * @returns if all the contained post processes are ready.
  57509. * @hidden
  57510. */
  57511. _isReady(): boolean;
  57512. }
  57513. }
  57514. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57515. /** @hidden */
  57516. export var chromaticAberrationPixelShader: {
  57517. name: string;
  57518. shader: string;
  57519. };
  57520. }
  57521. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57522. import { Vector2 } from "babylonjs/Maths/math";
  57523. import { Nullable } from "babylonjs/types";
  57524. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57525. import { Camera } from "babylonjs/Cameras/camera";
  57526. import { Engine } from "babylonjs/Engines/engine";
  57527. import "babylonjs/Shaders/chromaticAberration.fragment";
  57528. /**
  57529. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57530. */
  57531. export class ChromaticAberrationPostProcess extends PostProcess {
  57532. /**
  57533. * The amount of seperation of rgb channels (default: 30)
  57534. */
  57535. aberrationAmount: number;
  57536. /**
  57537. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57538. */
  57539. radialIntensity: number;
  57540. /**
  57541. * 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))
  57542. */
  57543. direction: Vector2;
  57544. /**
  57545. * 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))
  57546. */
  57547. centerPosition: Vector2;
  57548. /**
  57549. * Creates a new instance ChromaticAberrationPostProcess
  57550. * @param name The name of the effect.
  57551. * @param screenWidth The width of the screen to apply the effect on.
  57552. * @param screenHeight The height of the screen to apply the effect on.
  57553. * @param options The required width/height ratio to downsize to before computing the render pass.
  57554. * @param camera The camera to apply the render pass to.
  57555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57556. * @param engine The engine which the post process will be applied. (default: current engine)
  57557. * @param reusable If the post process can be reused on the same frame. (default: false)
  57558. * @param textureType Type of textures used when performing the post process. (default: 0)
  57559. * @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)
  57560. */
  57561. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57562. }
  57563. }
  57564. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57565. /** @hidden */
  57566. export var circleOfConfusionPixelShader: {
  57567. name: string;
  57568. shader: string;
  57569. };
  57570. }
  57571. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57572. import { Nullable } from "babylonjs/types";
  57573. import { Engine } from "babylonjs/Engines/engine";
  57574. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57575. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57576. import { Camera } from "babylonjs/Cameras/camera";
  57577. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57578. /**
  57579. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57580. */
  57581. export class CircleOfConfusionPostProcess extends PostProcess {
  57582. /**
  57583. * 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.
  57584. */
  57585. lensSize: number;
  57586. /**
  57587. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57588. */
  57589. fStop: number;
  57590. /**
  57591. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57592. */
  57593. focusDistance: number;
  57594. /**
  57595. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57596. */
  57597. focalLength: number;
  57598. private _depthTexture;
  57599. /**
  57600. * Creates a new instance CircleOfConfusionPostProcess
  57601. * @param name The name of the effect.
  57602. * @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.
  57603. * @param options The required width/height ratio to downsize to before computing the render pass.
  57604. * @param camera The camera to apply the render pass to.
  57605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57606. * @param engine The engine which the post process will be applied. (default: current engine)
  57607. * @param reusable If the post process can be reused on the same frame. (default: false)
  57608. * @param textureType Type of textures used when performing the post process. (default: 0)
  57609. * @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)
  57610. */
  57611. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57612. /**
  57613. * 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.
  57614. */
  57615. depthTexture: RenderTargetTexture;
  57616. }
  57617. }
  57618. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57619. /** @hidden */
  57620. export var colorCorrectionPixelShader: {
  57621. name: string;
  57622. shader: string;
  57623. };
  57624. }
  57625. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57626. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57627. import { Engine } from "babylonjs/Engines/engine";
  57628. import { Camera } from "babylonjs/Cameras/camera";
  57629. import "babylonjs/Shaders/colorCorrection.fragment";
  57630. /**
  57631. *
  57632. * This post-process allows the modification of rendered colors by using
  57633. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57634. *
  57635. * The object needs to be provided an url to a texture containing the color
  57636. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57637. * Use an image editing software to tweak the LUT to match your needs.
  57638. *
  57639. * For an example of a color LUT, see here:
  57640. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57641. * For explanations on color grading, see here:
  57642. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57643. *
  57644. */
  57645. export class ColorCorrectionPostProcess extends PostProcess {
  57646. private _colorTableTexture;
  57647. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57648. }
  57649. }
  57650. declare module "babylonjs/Shaders/convolution.fragment" {
  57651. /** @hidden */
  57652. export var convolutionPixelShader: {
  57653. name: string;
  57654. shader: string;
  57655. };
  57656. }
  57657. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  57658. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57659. import { Nullable } from "babylonjs/types";
  57660. import { Camera } from "babylonjs/Cameras/camera";
  57661. import { Engine } from "babylonjs/Engines/engine";
  57662. import "babylonjs/Shaders/convolution.fragment";
  57663. /**
  57664. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57665. * input texture to perform effects such as edge detection or sharpening
  57666. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57667. */
  57668. export class ConvolutionPostProcess extends PostProcess {
  57669. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57670. kernel: number[];
  57671. /**
  57672. * Creates a new instance ConvolutionPostProcess
  57673. * @param name The name of the effect.
  57674. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  57675. * @param options The required width/height ratio to downsize to before computing the render pass.
  57676. * @param camera The camera to apply the render pass to.
  57677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57678. * @param engine The engine which the post process will be applied. (default: current engine)
  57679. * @param reusable If the post process can be reused on the same frame. (default: false)
  57680. * @param textureType Type of textures used when performing the post process. (default: 0)
  57681. */
  57682. constructor(name: string,
  57683. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  57684. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57685. /**
  57686. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57687. */
  57688. static EdgeDetect0Kernel: number[];
  57689. /**
  57690. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57691. */
  57692. static EdgeDetect1Kernel: number[];
  57693. /**
  57694. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57695. */
  57696. static EdgeDetect2Kernel: number[];
  57697. /**
  57698. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57699. */
  57700. static SharpenKernel: number[];
  57701. /**
  57702. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57703. */
  57704. static EmbossKernel: number[];
  57705. /**
  57706. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57707. */
  57708. static GaussianKernel: number[];
  57709. }
  57710. }
  57711. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  57712. import { Nullable } from "babylonjs/types";
  57713. import { Vector2 } from "babylonjs/Maths/math";
  57714. import { Camera } from "babylonjs/Cameras/camera";
  57715. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57716. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  57717. import { Engine } from "babylonjs/Engines/engine";
  57718. import { Scene } from "babylonjs/scene";
  57719. /**
  57720. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57721. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57722. * based on samples that have a large difference in distance than the center pixel.
  57723. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57724. */
  57725. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57726. direction: Vector2;
  57727. /**
  57728. * Creates a new instance CircleOfConfusionPostProcess
  57729. * @param name The name of the effect.
  57730. * @param scene The scene the effect belongs to.
  57731. * @param direction The direction the blur should be applied.
  57732. * @param kernel The size of the kernel used to blur.
  57733. * @param options The required width/height ratio to downsize to before computing the render pass.
  57734. * @param camera The camera to apply the render pass to.
  57735. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57736. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57738. * @param engine The engine which the post process will be applied. (default: current engine)
  57739. * @param reusable If the post process can be reused on the same frame. (default: false)
  57740. * @param textureType Type of textures used when performing the post process. (default: 0)
  57741. * @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)
  57742. */
  57743. 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);
  57744. }
  57745. }
  57746. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  57747. /** @hidden */
  57748. export var depthOfFieldMergePixelShader: {
  57749. name: string;
  57750. shader: string;
  57751. };
  57752. }
  57753. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  57754. import { Nullable } from "babylonjs/types";
  57755. import { Camera } from "babylonjs/Cameras/camera";
  57756. import { Effect } from "babylonjs/Materials/effect";
  57757. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57758. import { Engine } from "babylonjs/Engines/engine";
  57759. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  57760. /**
  57761. * Options to be set when merging outputs from the default pipeline.
  57762. */
  57763. export class DepthOfFieldMergePostProcessOptions {
  57764. /**
  57765. * The original image to merge on top of
  57766. */
  57767. originalFromInput: PostProcess;
  57768. /**
  57769. * Parameters to perform the merge of the depth of field effect
  57770. */
  57771. depthOfField?: {
  57772. circleOfConfusion: PostProcess;
  57773. blurSteps: Array<PostProcess>;
  57774. };
  57775. /**
  57776. * Parameters to perform the merge of bloom effect
  57777. */
  57778. bloom?: {
  57779. blurred: PostProcess;
  57780. weight: number;
  57781. };
  57782. }
  57783. /**
  57784. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57785. */
  57786. export class DepthOfFieldMergePostProcess extends PostProcess {
  57787. private blurSteps;
  57788. /**
  57789. * Creates a new instance of DepthOfFieldMergePostProcess
  57790. * @param name The name of the effect.
  57791. * @param originalFromInput Post process which's input will be used for the merge.
  57792. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57793. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57794. * @param options The required width/height ratio to downsize to before computing the render pass.
  57795. * @param camera The camera to apply the render pass to.
  57796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57797. * @param engine The engine which the post process will be applied. (default: current engine)
  57798. * @param reusable If the post process can be reused on the same frame. (default: false)
  57799. * @param textureType Type of textures used when performing the post process. (default: 0)
  57800. * @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)
  57801. */
  57802. 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);
  57803. /**
  57804. * Updates the effect with the current post process compile time values and recompiles the shader.
  57805. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57806. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57807. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57808. * @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
  57809. * @param onCompiled Called when the shader has been compiled.
  57810. * @param onError Called if there is an error when compiling a shader.
  57811. */
  57812. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57813. }
  57814. }
  57815. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  57816. import { Nullable } from "babylonjs/types";
  57817. import { Camera } from "babylonjs/Cameras/camera";
  57818. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57819. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57820. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57821. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57822. import { Scene } from "babylonjs/scene";
  57823. /**
  57824. * Specifies the level of max blur that should be applied when using the depth of field effect
  57825. */
  57826. export enum DepthOfFieldEffectBlurLevel {
  57827. /**
  57828. * Subtle blur
  57829. */
  57830. Low = 0,
  57831. /**
  57832. * Medium blur
  57833. */
  57834. Medium = 1,
  57835. /**
  57836. * Large blur
  57837. */
  57838. High = 2
  57839. }
  57840. /**
  57841. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57842. */
  57843. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57844. private _circleOfConfusion;
  57845. /**
  57846. * @hidden Internal, blurs from high to low
  57847. */
  57848. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57849. private _depthOfFieldBlurY;
  57850. private _dofMerge;
  57851. /**
  57852. * @hidden Internal post processes in depth of field effect
  57853. */
  57854. _effects: Array<PostProcess>;
  57855. /**
  57856. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57857. */
  57858. focalLength: number;
  57859. /**
  57860. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57861. */
  57862. fStop: number;
  57863. /**
  57864. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57865. */
  57866. focusDistance: number;
  57867. /**
  57868. * 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.
  57869. */
  57870. lensSize: number;
  57871. /**
  57872. * Creates a new instance DepthOfFieldEffect
  57873. * @param scene The scene the effect belongs to.
  57874. * @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.
  57875. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57876. * @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)
  57877. */
  57878. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57879. /**
  57880. * Get the current class name of the current effet
  57881. * @returns "DepthOfFieldEffect"
  57882. */
  57883. getClassName(): string;
  57884. /**
  57885. * 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.
  57886. */
  57887. depthTexture: RenderTargetTexture;
  57888. /**
  57889. * Disposes each of the internal effects for a given camera.
  57890. * @param camera The camera to dispose the effect on.
  57891. */
  57892. disposeEffects(camera: Camera): void;
  57893. /**
  57894. * @hidden Internal
  57895. */
  57896. _updateEffects(): void;
  57897. /**
  57898. * Internal
  57899. * @returns if all the contained post processes are ready.
  57900. * @hidden
  57901. */
  57902. _isReady(): boolean;
  57903. }
  57904. }
  57905. declare module "babylonjs/Shaders/displayPass.fragment" {
  57906. /** @hidden */
  57907. export var displayPassPixelShader: {
  57908. name: string;
  57909. shader: string;
  57910. };
  57911. }
  57912. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  57913. import { Nullable } from "babylonjs/types";
  57914. import { Camera } from "babylonjs/Cameras/camera";
  57915. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57916. import { Engine } from "babylonjs/Engines/engine";
  57917. import "babylonjs/Shaders/displayPass.fragment";
  57918. /**
  57919. * DisplayPassPostProcess which produces an output the same as it's input
  57920. */
  57921. export class DisplayPassPostProcess extends PostProcess {
  57922. /**
  57923. * Creates the DisplayPassPostProcess
  57924. * @param name The name of the effect.
  57925. * @param options The required width/height ratio to downsize to before computing the render pass.
  57926. * @param camera The camera to apply the render pass to.
  57927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57928. * @param engine The engine which the post process will be applied. (default: current engine)
  57929. * @param reusable If the post process can be reused on the same frame. (default: false)
  57930. */
  57931. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57932. }
  57933. }
  57934. declare module "babylonjs/Shaders/filter.fragment" {
  57935. /** @hidden */
  57936. export var filterPixelShader: {
  57937. name: string;
  57938. shader: string;
  57939. };
  57940. }
  57941. declare module "babylonjs/PostProcesses/filterPostProcess" {
  57942. import { Nullable } from "babylonjs/types";
  57943. import { Matrix } from "babylonjs/Maths/math";
  57944. import { Camera } from "babylonjs/Cameras/camera";
  57945. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57946. import { Engine } from "babylonjs/Engines/engine";
  57947. import "babylonjs/Shaders/filter.fragment";
  57948. /**
  57949. * Applies a kernel filter to the image
  57950. */
  57951. export class FilterPostProcess extends PostProcess {
  57952. /** The matrix to be applied to the image */
  57953. kernelMatrix: Matrix;
  57954. /**
  57955. *
  57956. * @param name The name of the effect.
  57957. * @param kernelMatrix The matrix to be applied to the image
  57958. * @param options The required width/height ratio to downsize to before computing the render pass.
  57959. * @param camera The camera to apply the render pass to.
  57960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57961. * @param engine The engine which the post process will be applied. (default: current engine)
  57962. * @param reusable If the post process can be reused on the same frame. (default: false)
  57963. */
  57964. constructor(name: string,
  57965. /** The matrix to be applied to the image */
  57966. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57967. }
  57968. }
  57969. declare module "babylonjs/Shaders/fxaa.fragment" {
  57970. /** @hidden */
  57971. export var fxaaPixelShader: {
  57972. name: string;
  57973. shader: string;
  57974. };
  57975. }
  57976. declare module "babylonjs/Shaders/fxaa.vertex" {
  57977. /** @hidden */
  57978. export var fxaaVertexShader: {
  57979. name: string;
  57980. shader: string;
  57981. };
  57982. }
  57983. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  57984. import { Nullable } from "babylonjs/types";
  57985. import { Camera } from "babylonjs/Cameras/camera";
  57986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57987. import { Engine } from "babylonjs/Engines/engine";
  57988. import "babylonjs/Shaders/fxaa.fragment";
  57989. import "babylonjs/Shaders/fxaa.vertex";
  57990. /**
  57991. * Fxaa post process
  57992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57993. */
  57994. export class FxaaPostProcess extends PostProcess {
  57995. /** @hidden */
  57996. texelWidth: number;
  57997. /** @hidden */
  57998. texelHeight: number;
  57999. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58000. private _getDefines;
  58001. }
  58002. }
  58003. declare module "babylonjs/Shaders/grain.fragment" {
  58004. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58005. /** @hidden */
  58006. export var grainPixelShader: {
  58007. name: string;
  58008. shader: string;
  58009. };
  58010. }
  58011. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58012. import { Nullable } from "babylonjs/types";
  58013. import { Camera } from "babylonjs/Cameras/camera";
  58014. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58015. import { Engine } from "babylonjs/Engines/engine";
  58016. import "babylonjs/Shaders/grain.fragment";
  58017. /**
  58018. * The GrainPostProcess adds noise to the image at mid luminance levels
  58019. */
  58020. export class GrainPostProcess extends PostProcess {
  58021. /**
  58022. * The intensity of the grain added (default: 30)
  58023. */
  58024. intensity: number;
  58025. /**
  58026. * If the grain should be randomized on every frame
  58027. */
  58028. animated: boolean;
  58029. /**
  58030. * Creates a new instance of @see GrainPostProcess
  58031. * @param name The name of the effect.
  58032. * @param options The required width/height ratio to downsize to before computing the render pass.
  58033. * @param camera The camera to apply the render pass to.
  58034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58035. * @param engine The engine which the post process will be applied. (default: current engine)
  58036. * @param reusable If the post process can be reused on the same frame. (default: false)
  58037. * @param textureType Type of textures used when performing the post process. (default: 0)
  58038. * @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)
  58039. */
  58040. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58041. }
  58042. }
  58043. declare module "babylonjs/Shaders/highlights.fragment" {
  58044. /** @hidden */
  58045. export var highlightsPixelShader: {
  58046. name: string;
  58047. shader: string;
  58048. };
  58049. }
  58050. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58051. import { Nullable } from "babylonjs/types";
  58052. import { Camera } from "babylonjs/Cameras/camera";
  58053. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58054. import { Engine } from "babylonjs/Engines/engine";
  58055. import "babylonjs/Shaders/highlights.fragment";
  58056. /**
  58057. * Extracts highlights from the image
  58058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58059. */
  58060. export class HighlightsPostProcess extends PostProcess {
  58061. /**
  58062. * Extracts highlights from the image
  58063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58064. * @param name The name of the effect.
  58065. * @param options The required width/height ratio to downsize to before computing the render pass.
  58066. * @param camera The camera to apply the render pass to.
  58067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58068. * @param engine The engine which the post process will be applied. (default: current engine)
  58069. * @param reusable If the post process can be reused on the same frame. (default: false)
  58070. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58071. */
  58072. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58073. }
  58074. }
  58075. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58076. /** @hidden */
  58077. export var mrtFragmentDeclaration: {
  58078. name: string;
  58079. shader: string;
  58080. };
  58081. }
  58082. declare module "babylonjs/Shaders/geometry.fragment" {
  58083. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58084. /** @hidden */
  58085. export var geometryPixelShader: {
  58086. name: string;
  58087. shader: string;
  58088. };
  58089. }
  58090. declare module "babylonjs/Shaders/geometry.vertex" {
  58091. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58092. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58093. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58094. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58095. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58096. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58097. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58098. /** @hidden */
  58099. export var geometryVertexShader: {
  58100. name: string;
  58101. shader: string;
  58102. };
  58103. }
  58104. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58105. import { Matrix } from "babylonjs/Maths/math";
  58106. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58107. import { Mesh } from "babylonjs/Meshes/mesh";
  58108. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58109. import { Effect } from "babylonjs/Materials/effect";
  58110. import { Scene } from "babylonjs/scene";
  58111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58112. import "babylonjs/Shaders/geometry.fragment";
  58113. import "babylonjs/Shaders/geometry.vertex";
  58114. /** @hidden */
  58115. interface ISavedTransformationMatrix {
  58116. world: Matrix;
  58117. viewProjection: Matrix;
  58118. }
  58119. /**
  58120. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58121. */
  58122. export class GeometryBufferRenderer {
  58123. /**
  58124. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58125. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58126. */
  58127. static readonly POSITION_TEXTURE_TYPE: number;
  58128. /**
  58129. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58130. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58131. */
  58132. static readonly VELOCITY_TEXTURE_TYPE: number;
  58133. /**
  58134. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58135. * in order to compute objects velocities when enableVelocity is set to "true"
  58136. * @hidden
  58137. */
  58138. _previousTransformationMatrices: {
  58139. [index: number]: ISavedTransformationMatrix;
  58140. };
  58141. /**
  58142. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58143. * in order to compute objects velocities when enableVelocity is set to "true"
  58144. * @hidden
  58145. */
  58146. _previousBonesTransformationMatrices: {
  58147. [index: number]: Float32Array;
  58148. };
  58149. /**
  58150. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58151. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58152. */
  58153. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58154. private _scene;
  58155. private _multiRenderTarget;
  58156. private _ratio;
  58157. private _enablePosition;
  58158. private _enableVelocity;
  58159. private _positionIndex;
  58160. private _velocityIndex;
  58161. protected _effect: Effect;
  58162. protected _cachedDefines: string;
  58163. /**
  58164. * Set the render list (meshes to be rendered) used in the G buffer.
  58165. */
  58166. renderList: Mesh[];
  58167. /**
  58168. * Gets wether or not G buffer are supported by the running hardware.
  58169. * This requires draw buffer supports
  58170. */
  58171. readonly isSupported: boolean;
  58172. /**
  58173. * Returns the index of the given texture type in the G-Buffer textures array
  58174. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58175. * @returns the index of the given texture type in the G-Buffer textures array
  58176. */
  58177. getTextureIndex(textureType: number): number;
  58178. /**
  58179. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58180. */
  58181. /**
  58182. * Sets whether or not objects positions are enabled for the G buffer.
  58183. */
  58184. enablePosition: boolean;
  58185. /**
  58186. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58187. */
  58188. /**
  58189. * Sets wether or not objects velocities are enabled for the G buffer.
  58190. */
  58191. enableVelocity: boolean;
  58192. /**
  58193. * Gets the scene associated with the buffer.
  58194. */
  58195. readonly scene: Scene;
  58196. /**
  58197. * Gets the ratio used by the buffer during its creation.
  58198. * How big is the buffer related to the main canvas.
  58199. */
  58200. readonly ratio: number;
  58201. /** @hidden */
  58202. static _SceneComponentInitialization: (scene: Scene) => void;
  58203. /**
  58204. * Creates a new G Buffer for the scene
  58205. * @param scene The scene the buffer belongs to
  58206. * @param ratio How big is the buffer related to the main canvas.
  58207. */
  58208. constructor(scene: Scene, ratio?: number);
  58209. /**
  58210. * Checks wether everything is ready to render a submesh to the G buffer.
  58211. * @param subMesh the submesh to check readiness for
  58212. * @param useInstances is the mesh drawn using instance or not
  58213. * @returns true if ready otherwise false
  58214. */
  58215. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58216. /**
  58217. * Gets the current underlying G Buffer.
  58218. * @returns the buffer
  58219. */
  58220. getGBuffer(): MultiRenderTarget;
  58221. /**
  58222. * Gets the number of samples used to render the buffer (anti aliasing).
  58223. */
  58224. /**
  58225. * Sets the number of samples used to render the buffer (anti aliasing).
  58226. */
  58227. samples: number;
  58228. /**
  58229. * Disposes the renderer and frees up associated resources.
  58230. */
  58231. dispose(): void;
  58232. protected _createRenderTargets(): void;
  58233. private _copyBonesTransformationMatrices;
  58234. }
  58235. }
  58236. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58237. import { Nullable } from "babylonjs/types";
  58238. import { Scene } from "babylonjs/scene";
  58239. import { ISceneComponent } from "babylonjs/sceneComponent";
  58240. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58241. module "babylonjs/scene" {
  58242. interface Scene {
  58243. /** @hidden (Backing field) */
  58244. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58245. /**
  58246. * Gets or Sets the current geometry buffer associated to the scene.
  58247. */
  58248. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58249. /**
  58250. * Enables a GeometryBufferRender and associates it with the scene
  58251. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58252. * @returns the GeometryBufferRenderer
  58253. */
  58254. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58255. /**
  58256. * Disables the GeometryBufferRender associated with the scene
  58257. */
  58258. disableGeometryBufferRenderer(): void;
  58259. }
  58260. }
  58261. /**
  58262. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58263. * in several rendering techniques.
  58264. */
  58265. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58266. /**
  58267. * The component name helpful to identify the component in the list of scene components.
  58268. */
  58269. readonly name: string;
  58270. /**
  58271. * The scene the component belongs to.
  58272. */
  58273. scene: Scene;
  58274. /**
  58275. * Creates a new instance of the component for the given scene
  58276. * @param scene Defines the scene to register the component in
  58277. */
  58278. constructor(scene: Scene);
  58279. /**
  58280. * Registers the component in a given scene
  58281. */
  58282. register(): void;
  58283. /**
  58284. * Rebuilds the elements related to this component in case of
  58285. * context lost for instance.
  58286. */
  58287. rebuild(): void;
  58288. /**
  58289. * Disposes the component and the associated ressources
  58290. */
  58291. dispose(): void;
  58292. private _gatherRenderTargets;
  58293. }
  58294. }
  58295. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58296. /** @hidden */
  58297. export var motionBlurPixelShader: {
  58298. name: string;
  58299. shader: string;
  58300. };
  58301. }
  58302. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58303. import { Nullable } from "babylonjs/types";
  58304. import { Camera } from "babylonjs/Cameras/camera";
  58305. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58306. import { Scene } from "babylonjs/scene";
  58307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58308. import "babylonjs/Animations/animatable";
  58309. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58310. import "babylonjs/Shaders/motionBlur.fragment";
  58311. import { Engine } from "babylonjs/Engines/engine";
  58312. /**
  58313. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58314. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58315. * As an example, all you have to do is to create the post-process:
  58316. * var mb = new BABYLON.MotionBlurPostProcess(
  58317. * 'mb', // The name of the effect.
  58318. * scene, // The scene containing the objects to blur according to their velocity.
  58319. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58320. * camera // The camera to apply the render pass to.
  58321. * );
  58322. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58323. */
  58324. export class MotionBlurPostProcess extends PostProcess {
  58325. /**
  58326. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58327. */
  58328. motionStrength: number;
  58329. /**
  58330. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58331. */
  58332. /**
  58333. * Sets the number of iterations to be used for motion blur quality
  58334. */
  58335. motionBlurSamples: number;
  58336. private _motionBlurSamples;
  58337. private _geometryBufferRenderer;
  58338. /**
  58339. * Creates a new instance MotionBlurPostProcess
  58340. * @param name The name of the effect.
  58341. * @param scene The scene containing the objects to blur according to their velocity.
  58342. * @param options The required width/height ratio to downsize to before computing the render pass.
  58343. * @param camera The camera to apply the render pass to.
  58344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58345. * @param engine The engine which the post process will be applied. (default: current engine)
  58346. * @param reusable If the post process can be reused on the same frame. (default: false)
  58347. * @param textureType Type of textures used when performing the post process. (default: 0)
  58348. * @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)
  58349. */
  58350. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58351. /**
  58352. * Excludes the given skinned mesh from computing bones velocities.
  58353. * 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.
  58354. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58355. */
  58356. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58357. /**
  58358. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58359. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58360. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58361. */
  58362. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58363. /**
  58364. * Disposes the post process.
  58365. * @param camera The camera to dispose the post process on.
  58366. */
  58367. dispose(camera?: Camera): void;
  58368. }
  58369. }
  58370. declare module "babylonjs/Shaders/refraction.fragment" {
  58371. /** @hidden */
  58372. export var refractionPixelShader: {
  58373. name: string;
  58374. shader: string;
  58375. };
  58376. }
  58377. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58378. import { Color3 } from "babylonjs/Maths/math";
  58379. import { Camera } from "babylonjs/Cameras/camera";
  58380. import { Texture } from "babylonjs/Materials/Textures/texture";
  58381. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58382. import { Engine } from "babylonjs/Engines/engine";
  58383. import "babylonjs/Shaders/refraction.fragment";
  58384. /**
  58385. * Post process which applies a refractin texture
  58386. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58387. */
  58388. export class RefractionPostProcess extends PostProcess {
  58389. /** the base color of the refraction (used to taint the rendering) */
  58390. color: Color3;
  58391. /** simulated refraction depth */
  58392. depth: number;
  58393. /** the coefficient of the base color (0 to remove base color tainting) */
  58394. colorLevel: number;
  58395. private _refTexture;
  58396. private _ownRefractionTexture;
  58397. /**
  58398. * Gets or sets the refraction texture
  58399. * Please note that you are responsible for disposing the texture if you set it manually
  58400. */
  58401. refractionTexture: Texture;
  58402. /**
  58403. * Initializes the RefractionPostProcess
  58404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58405. * @param name The name of the effect.
  58406. * @param refractionTextureUrl Url of the refraction texture to use
  58407. * @param color the base color of the refraction (used to taint the rendering)
  58408. * @param depth simulated refraction depth
  58409. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58410. * @param camera The camera to apply the render pass to.
  58411. * @param options The required width/height ratio to downsize to before computing the render pass.
  58412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58413. * @param engine The engine which the post process will be applied. (default: current engine)
  58414. * @param reusable If the post process can be reused on the same frame. (default: false)
  58415. */
  58416. constructor(name: string, refractionTextureUrl: string,
  58417. /** the base color of the refraction (used to taint the rendering) */
  58418. color: Color3,
  58419. /** simulated refraction depth */
  58420. depth: number,
  58421. /** the coefficient of the base color (0 to remove base color tainting) */
  58422. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58423. /**
  58424. * Disposes of the post process
  58425. * @param camera Camera to dispose post process on
  58426. */
  58427. dispose(camera: Camera): void;
  58428. }
  58429. }
  58430. declare module "babylonjs/Shaders/sharpen.fragment" {
  58431. /** @hidden */
  58432. export var sharpenPixelShader: {
  58433. name: string;
  58434. shader: string;
  58435. };
  58436. }
  58437. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58438. import { Nullable } from "babylonjs/types";
  58439. import { Camera } from "babylonjs/Cameras/camera";
  58440. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58441. import "babylonjs/Shaders/sharpen.fragment";
  58442. import { Engine } from "babylonjs/Engines/engine";
  58443. /**
  58444. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58445. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58446. */
  58447. export class SharpenPostProcess extends PostProcess {
  58448. /**
  58449. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58450. */
  58451. colorAmount: number;
  58452. /**
  58453. * How much sharpness should be applied (default: 0.3)
  58454. */
  58455. edgeAmount: number;
  58456. /**
  58457. * Creates a new instance ConvolutionPostProcess
  58458. * @param name The name of the effect.
  58459. * @param options The required width/height ratio to downsize to before computing the render pass.
  58460. * @param camera The camera to apply the render pass to.
  58461. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58462. * @param engine The engine which the post process will be applied. (default: current engine)
  58463. * @param reusable If the post process can be reused on the same frame. (default: false)
  58464. * @param textureType Type of textures used when performing the post process. (default: 0)
  58465. * @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)
  58466. */
  58467. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58468. }
  58469. }
  58470. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58471. import { Nullable } from "babylonjs/types";
  58472. import { Camera } from "babylonjs/Cameras/camera";
  58473. import { Engine } from "babylonjs/Engines/engine";
  58474. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58475. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58476. /**
  58477. * PostProcessRenderPipeline
  58478. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58479. */
  58480. export class PostProcessRenderPipeline {
  58481. private engine;
  58482. private _renderEffects;
  58483. private _renderEffectsForIsolatedPass;
  58484. /**
  58485. * List of inspectable custom properties (used by the Inspector)
  58486. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58487. */
  58488. inspectableCustomProperties: IInspectable[];
  58489. /**
  58490. * @hidden
  58491. */
  58492. protected _cameras: Camera[];
  58493. /** @hidden */
  58494. _name: string;
  58495. /**
  58496. * Gets pipeline name
  58497. */
  58498. readonly name: string;
  58499. /**
  58500. * Initializes a PostProcessRenderPipeline
  58501. * @param engine engine to add the pipeline to
  58502. * @param name name of the pipeline
  58503. */
  58504. constructor(engine: Engine, name: string);
  58505. /**
  58506. * Gets the class name
  58507. * @returns "PostProcessRenderPipeline"
  58508. */
  58509. getClassName(): string;
  58510. /**
  58511. * If all the render effects in the pipeline are supported
  58512. */
  58513. readonly isSupported: boolean;
  58514. /**
  58515. * Adds an effect to the pipeline
  58516. * @param renderEffect the effect to add
  58517. */
  58518. addEffect(renderEffect: PostProcessRenderEffect): void;
  58519. /** @hidden */
  58520. _rebuild(): void;
  58521. /** @hidden */
  58522. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58523. /** @hidden */
  58524. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58525. /** @hidden */
  58526. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58527. /** @hidden */
  58528. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58529. /** @hidden */
  58530. _attachCameras(cameras: Camera, unique: boolean): void;
  58531. /** @hidden */
  58532. _attachCameras(cameras: Camera[], unique: boolean): void;
  58533. /** @hidden */
  58534. _detachCameras(cameras: Camera): void;
  58535. /** @hidden */
  58536. _detachCameras(cameras: Nullable<Camera[]>): void;
  58537. /** @hidden */
  58538. _update(): void;
  58539. /** @hidden */
  58540. _reset(): void;
  58541. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58542. /**
  58543. * Disposes of the pipeline
  58544. */
  58545. dispose(): void;
  58546. }
  58547. }
  58548. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58549. import { Camera } from "babylonjs/Cameras/camera";
  58550. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58551. /**
  58552. * PostProcessRenderPipelineManager class
  58553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58554. */
  58555. export class PostProcessRenderPipelineManager {
  58556. private _renderPipelines;
  58557. /**
  58558. * Initializes a PostProcessRenderPipelineManager
  58559. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58560. */
  58561. constructor();
  58562. /**
  58563. * Gets the list of supported render pipelines
  58564. */
  58565. readonly supportedPipelines: PostProcessRenderPipeline[];
  58566. /**
  58567. * Adds a pipeline to the manager
  58568. * @param renderPipeline The pipeline to add
  58569. */
  58570. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58571. /**
  58572. * Attaches a camera to the pipeline
  58573. * @param renderPipelineName The name of the pipeline to attach to
  58574. * @param cameras the camera to attach
  58575. * @param unique if the camera can be attached multiple times to the pipeline
  58576. */
  58577. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58578. /**
  58579. * Detaches a camera from the pipeline
  58580. * @param renderPipelineName The name of the pipeline to detach from
  58581. * @param cameras the camera to detach
  58582. */
  58583. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58584. /**
  58585. * Enables an effect by name on a pipeline
  58586. * @param renderPipelineName the name of the pipeline to enable the effect in
  58587. * @param renderEffectName the name of the effect to enable
  58588. * @param cameras the cameras that the effect should be enabled on
  58589. */
  58590. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58591. /**
  58592. * Disables an effect by name on a pipeline
  58593. * @param renderPipelineName the name of the pipeline to disable the effect in
  58594. * @param renderEffectName the name of the effect to disable
  58595. * @param cameras the cameras that the effect should be disabled on
  58596. */
  58597. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58598. /**
  58599. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58600. */
  58601. update(): void;
  58602. /** @hidden */
  58603. _rebuild(): void;
  58604. /**
  58605. * Disposes of the manager and pipelines
  58606. */
  58607. dispose(): void;
  58608. }
  58609. }
  58610. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58611. import { ISceneComponent } from "babylonjs/sceneComponent";
  58612. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58613. import { Scene } from "babylonjs/scene";
  58614. module "babylonjs/scene" {
  58615. interface Scene {
  58616. /** @hidden (Backing field) */
  58617. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58618. /**
  58619. * Gets the postprocess render pipeline manager
  58620. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58621. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58622. */
  58623. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58624. }
  58625. }
  58626. /**
  58627. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58628. */
  58629. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58630. /**
  58631. * The component name helpfull to identify the component in the list of scene components.
  58632. */
  58633. readonly name: string;
  58634. /**
  58635. * The scene the component belongs to.
  58636. */
  58637. scene: Scene;
  58638. /**
  58639. * Creates a new instance of the component for the given scene
  58640. * @param scene Defines the scene to register the component in
  58641. */
  58642. constructor(scene: Scene);
  58643. /**
  58644. * Registers the component in a given scene
  58645. */
  58646. register(): void;
  58647. /**
  58648. * Rebuilds the elements related to this component in case of
  58649. * context lost for instance.
  58650. */
  58651. rebuild(): void;
  58652. /**
  58653. * Disposes the component and the associated ressources
  58654. */
  58655. dispose(): void;
  58656. private _gatherRenderTargets;
  58657. }
  58658. }
  58659. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  58660. import { Nullable } from "babylonjs/types";
  58661. import { IAnimatable } from "babylonjs/Misc/tools";
  58662. import { Camera } from "babylonjs/Cameras/camera";
  58663. import { IDisposable } from "babylonjs/scene";
  58664. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  58665. import { Scene } from "babylonjs/scene";
  58666. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  58667. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  58668. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  58669. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  58670. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58671. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58672. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  58673. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  58674. import { Animation } from "babylonjs/Animations/animation";
  58675. /**
  58676. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58677. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58678. */
  58679. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58680. private _scene;
  58681. private _camerasToBeAttached;
  58682. /**
  58683. * ID of the sharpen post process,
  58684. */
  58685. private readonly SharpenPostProcessId;
  58686. /**
  58687. * @ignore
  58688. * ID of the image processing post process;
  58689. */
  58690. readonly ImageProcessingPostProcessId: string;
  58691. /**
  58692. * @ignore
  58693. * ID of the Fast Approximate Anti-Aliasing post process;
  58694. */
  58695. readonly FxaaPostProcessId: string;
  58696. /**
  58697. * ID of the chromatic aberration post process,
  58698. */
  58699. private readonly ChromaticAberrationPostProcessId;
  58700. /**
  58701. * ID of the grain post process
  58702. */
  58703. private readonly GrainPostProcessId;
  58704. /**
  58705. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58706. */
  58707. sharpen: SharpenPostProcess;
  58708. private _sharpenEffect;
  58709. private bloom;
  58710. /**
  58711. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58712. */
  58713. depthOfField: DepthOfFieldEffect;
  58714. /**
  58715. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58716. */
  58717. fxaa: FxaaPostProcess;
  58718. /**
  58719. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58720. */
  58721. imageProcessing: ImageProcessingPostProcess;
  58722. /**
  58723. * Chromatic aberration post process which will shift rgb colors in the image
  58724. */
  58725. chromaticAberration: ChromaticAberrationPostProcess;
  58726. private _chromaticAberrationEffect;
  58727. /**
  58728. * Grain post process which add noise to the image
  58729. */
  58730. grain: GrainPostProcess;
  58731. private _grainEffect;
  58732. /**
  58733. * Glow post process which adds a glow to emissive areas of the image
  58734. */
  58735. private _glowLayer;
  58736. /**
  58737. * Animations which can be used to tweak settings over a period of time
  58738. */
  58739. animations: Animation[];
  58740. private _imageProcessingConfigurationObserver;
  58741. private _sharpenEnabled;
  58742. private _bloomEnabled;
  58743. private _depthOfFieldEnabled;
  58744. private _depthOfFieldBlurLevel;
  58745. private _fxaaEnabled;
  58746. private _imageProcessingEnabled;
  58747. private _defaultPipelineTextureType;
  58748. private _bloomScale;
  58749. private _chromaticAberrationEnabled;
  58750. private _grainEnabled;
  58751. private _buildAllowed;
  58752. /**
  58753. * Gets active scene
  58754. */
  58755. readonly scene: Scene;
  58756. /**
  58757. * Enable or disable the sharpen process from the pipeline
  58758. */
  58759. sharpenEnabled: boolean;
  58760. private _resizeObserver;
  58761. private _hardwareScaleLevel;
  58762. private _bloomKernel;
  58763. /**
  58764. * Specifies the size of the bloom blur kernel, relative to the final output size
  58765. */
  58766. bloomKernel: number;
  58767. /**
  58768. * Specifies the weight of the bloom in the final rendering
  58769. */
  58770. private _bloomWeight;
  58771. /**
  58772. * Specifies the luma threshold for the area that will be blurred by the bloom
  58773. */
  58774. private _bloomThreshold;
  58775. private _hdr;
  58776. /**
  58777. * The strength of the bloom.
  58778. */
  58779. bloomWeight: number;
  58780. /**
  58781. * The strength of the bloom.
  58782. */
  58783. bloomThreshold: number;
  58784. /**
  58785. * The scale of the bloom, lower value will provide better performance.
  58786. */
  58787. bloomScale: number;
  58788. /**
  58789. * Enable or disable the bloom from the pipeline
  58790. */
  58791. bloomEnabled: boolean;
  58792. private _rebuildBloom;
  58793. /**
  58794. * If the depth of field is enabled.
  58795. */
  58796. depthOfFieldEnabled: boolean;
  58797. /**
  58798. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58799. */
  58800. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58801. /**
  58802. * If the anti aliasing is enabled.
  58803. */
  58804. fxaaEnabled: boolean;
  58805. private _samples;
  58806. /**
  58807. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58808. */
  58809. samples: number;
  58810. /**
  58811. * If image processing is enabled.
  58812. */
  58813. imageProcessingEnabled: boolean;
  58814. /**
  58815. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58816. */
  58817. glowLayerEnabled: boolean;
  58818. /**
  58819. * Gets the glow layer (or null if not defined)
  58820. */
  58821. readonly glowLayer: Nullable<GlowLayer>;
  58822. /**
  58823. * Enable or disable the chromaticAberration process from the pipeline
  58824. */
  58825. chromaticAberrationEnabled: boolean;
  58826. /**
  58827. * Enable or disable the grain process from the pipeline
  58828. */
  58829. grainEnabled: boolean;
  58830. /**
  58831. * @constructor
  58832. * @param name - The rendering pipeline name (default: "")
  58833. * @param hdr - If high dynamic range textures should be used (default: true)
  58834. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58835. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58836. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58837. */
  58838. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58839. /**
  58840. * Get the class name
  58841. * @returns "DefaultRenderingPipeline"
  58842. */
  58843. getClassName(): string;
  58844. /**
  58845. * Force the compilation of the entire pipeline.
  58846. */
  58847. prepare(): void;
  58848. private _hasCleared;
  58849. private _prevPostProcess;
  58850. private _prevPrevPostProcess;
  58851. private _setAutoClearAndTextureSharing;
  58852. private _depthOfFieldSceneObserver;
  58853. private _buildPipeline;
  58854. private _disposePostProcesses;
  58855. /**
  58856. * Adds a camera to the pipeline
  58857. * @param camera the camera to be added
  58858. */
  58859. addCamera(camera: Camera): void;
  58860. /**
  58861. * Removes a camera from the pipeline
  58862. * @param camera the camera to remove
  58863. */
  58864. removeCamera(camera: Camera): void;
  58865. /**
  58866. * Dispose of the pipeline and stop all post processes
  58867. */
  58868. dispose(): void;
  58869. /**
  58870. * Serialize the rendering pipeline (Used when exporting)
  58871. * @returns the serialized object
  58872. */
  58873. serialize(): any;
  58874. /**
  58875. * Parse the serialized pipeline
  58876. * @param source Source pipeline.
  58877. * @param scene The scene to load the pipeline to.
  58878. * @param rootUrl The URL of the serialized pipeline.
  58879. * @returns An instantiated pipeline from the serialized object.
  58880. */
  58881. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58882. }
  58883. }
  58884. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  58885. /** @hidden */
  58886. export var lensHighlightsPixelShader: {
  58887. name: string;
  58888. shader: string;
  58889. };
  58890. }
  58891. declare module "babylonjs/Shaders/depthOfField.fragment" {
  58892. /** @hidden */
  58893. export var depthOfFieldPixelShader: {
  58894. name: string;
  58895. shader: string;
  58896. };
  58897. }
  58898. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  58899. import { Camera } from "babylonjs/Cameras/camera";
  58900. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58901. import { Scene } from "babylonjs/scene";
  58902. import "babylonjs/Shaders/chromaticAberration.fragment";
  58903. import "babylonjs/Shaders/lensHighlights.fragment";
  58904. import "babylonjs/Shaders/depthOfField.fragment";
  58905. /**
  58906. * BABYLON.JS Chromatic Aberration GLSL Shader
  58907. * Author: Olivier Guyot
  58908. * Separates very slightly R, G and B colors on the edges of the screen
  58909. * Inspired by Francois Tarlier & Martins Upitis
  58910. */
  58911. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58912. /**
  58913. * @ignore
  58914. * The chromatic aberration PostProcess id in the pipeline
  58915. */
  58916. LensChromaticAberrationEffect: string;
  58917. /**
  58918. * @ignore
  58919. * The highlights enhancing PostProcess id in the pipeline
  58920. */
  58921. HighlightsEnhancingEffect: string;
  58922. /**
  58923. * @ignore
  58924. * The depth-of-field PostProcess id in the pipeline
  58925. */
  58926. LensDepthOfFieldEffect: string;
  58927. private _scene;
  58928. private _depthTexture;
  58929. private _grainTexture;
  58930. private _chromaticAberrationPostProcess;
  58931. private _highlightsPostProcess;
  58932. private _depthOfFieldPostProcess;
  58933. private _edgeBlur;
  58934. private _grainAmount;
  58935. private _chromaticAberration;
  58936. private _distortion;
  58937. private _highlightsGain;
  58938. private _highlightsThreshold;
  58939. private _dofDistance;
  58940. private _dofAperture;
  58941. private _dofDarken;
  58942. private _dofPentagon;
  58943. private _blurNoise;
  58944. /**
  58945. * @constructor
  58946. *
  58947. * Effect parameters are as follow:
  58948. * {
  58949. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58950. * edge_blur: number; // from 0 to x (1 for realism)
  58951. * distortion: number; // from 0 to x (1 for realism)
  58952. * grain_amount: number; // from 0 to 1
  58953. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58954. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58955. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58956. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58957. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58958. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58959. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58960. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58961. * }
  58962. * Note: if an effect parameter is unset, effect is disabled
  58963. *
  58964. * @param name The rendering pipeline name
  58965. * @param parameters - An object containing all parameters (see above)
  58966. * @param scene The scene linked to this pipeline
  58967. * @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)
  58968. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58969. */
  58970. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58971. /**
  58972. * Get the class name
  58973. * @returns "LensRenderingPipeline"
  58974. */
  58975. getClassName(): string;
  58976. /**
  58977. * Gets associated scene
  58978. */
  58979. readonly scene: Scene;
  58980. /**
  58981. * Gets or sets the edge blur
  58982. */
  58983. edgeBlur: number;
  58984. /**
  58985. * Gets or sets the grain amount
  58986. */
  58987. grainAmount: number;
  58988. /**
  58989. * Gets or sets the chromatic aberration amount
  58990. */
  58991. chromaticAberration: number;
  58992. /**
  58993. * Gets or sets the depth of field aperture
  58994. */
  58995. dofAperture: number;
  58996. /**
  58997. * Gets or sets the edge distortion
  58998. */
  58999. edgeDistortion: number;
  59000. /**
  59001. * Gets or sets the depth of field distortion
  59002. */
  59003. dofDistortion: number;
  59004. /**
  59005. * Gets or sets the darken out of focus amount
  59006. */
  59007. darkenOutOfFocus: number;
  59008. /**
  59009. * Gets or sets a boolean indicating if blur noise is enabled
  59010. */
  59011. blurNoise: boolean;
  59012. /**
  59013. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59014. */
  59015. pentagonBokeh: boolean;
  59016. /**
  59017. * Gets or sets the highlight grain amount
  59018. */
  59019. highlightsGain: number;
  59020. /**
  59021. * Gets or sets the highlight threshold
  59022. */
  59023. highlightsThreshold: number;
  59024. /**
  59025. * Sets the amount of blur at the edges
  59026. * @param amount blur amount
  59027. */
  59028. setEdgeBlur(amount: number): void;
  59029. /**
  59030. * Sets edge blur to 0
  59031. */
  59032. disableEdgeBlur(): void;
  59033. /**
  59034. * Sets the amout of grain
  59035. * @param amount Amount of grain
  59036. */
  59037. setGrainAmount(amount: number): void;
  59038. /**
  59039. * Set grain amount to 0
  59040. */
  59041. disableGrain(): void;
  59042. /**
  59043. * Sets the chromatic aberration amount
  59044. * @param amount amount of chromatic aberration
  59045. */
  59046. setChromaticAberration(amount: number): void;
  59047. /**
  59048. * Sets chromatic aberration amount to 0
  59049. */
  59050. disableChromaticAberration(): void;
  59051. /**
  59052. * Sets the EdgeDistortion amount
  59053. * @param amount amount of EdgeDistortion
  59054. */
  59055. setEdgeDistortion(amount: number): void;
  59056. /**
  59057. * Sets edge distortion to 0
  59058. */
  59059. disableEdgeDistortion(): void;
  59060. /**
  59061. * Sets the FocusDistance amount
  59062. * @param amount amount of FocusDistance
  59063. */
  59064. setFocusDistance(amount: number): void;
  59065. /**
  59066. * Disables depth of field
  59067. */
  59068. disableDepthOfField(): void;
  59069. /**
  59070. * Sets the Aperture amount
  59071. * @param amount amount of Aperture
  59072. */
  59073. setAperture(amount: number): void;
  59074. /**
  59075. * Sets the DarkenOutOfFocus amount
  59076. * @param amount amount of DarkenOutOfFocus
  59077. */
  59078. setDarkenOutOfFocus(amount: number): void;
  59079. private _pentagonBokehIsEnabled;
  59080. /**
  59081. * Creates a pentagon bokeh effect
  59082. */
  59083. enablePentagonBokeh(): void;
  59084. /**
  59085. * Disables the pentagon bokeh effect
  59086. */
  59087. disablePentagonBokeh(): void;
  59088. /**
  59089. * Enables noise blur
  59090. */
  59091. enableNoiseBlur(): void;
  59092. /**
  59093. * Disables noise blur
  59094. */
  59095. disableNoiseBlur(): void;
  59096. /**
  59097. * Sets the HighlightsGain amount
  59098. * @param amount amount of HighlightsGain
  59099. */
  59100. setHighlightsGain(amount: number): void;
  59101. /**
  59102. * Sets the HighlightsThreshold amount
  59103. * @param amount amount of HighlightsThreshold
  59104. */
  59105. setHighlightsThreshold(amount: number): void;
  59106. /**
  59107. * Disables highlights
  59108. */
  59109. disableHighlights(): void;
  59110. /**
  59111. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59112. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59113. */
  59114. dispose(disableDepthRender?: boolean): void;
  59115. private _createChromaticAberrationPostProcess;
  59116. private _createHighlightsPostProcess;
  59117. private _createDepthOfFieldPostProcess;
  59118. private _createGrainTexture;
  59119. }
  59120. }
  59121. declare module "babylonjs/Shaders/ssao2.fragment" {
  59122. /** @hidden */
  59123. export var ssao2PixelShader: {
  59124. name: string;
  59125. shader: string;
  59126. };
  59127. }
  59128. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59129. /** @hidden */
  59130. export var ssaoCombinePixelShader: {
  59131. name: string;
  59132. shader: string;
  59133. };
  59134. }
  59135. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59136. import { Camera } from "babylonjs/Cameras/camera";
  59137. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59138. import { Scene } from "babylonjs/scene";
  59139. import "babylonjs/Shaders/ssao2.fragment";
  59140. import "babylonjs/Shaders/ssaoCombine.fragment";
  59141. /**
  59142. * Render pipeline to produce ssao effect
  59143. */
  59144. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59145. /**
  59146. * @ignore
  59147. * The PassPostProcess id in the pipeline that contains the original scene color
  59148. */
  59149. SSAOOriginalSceneColorEffect: string;
  59150. /**
  59151. * @ignore
  59152. * The SSAO PostProcess id in the pipeline
  59153. */
  59154. SSAORenderEffect: string;
  59155. /**
  59156. * @ignore
  59157. * The horizontal blur PostProcess id in the pipeline
  59158. */
  59159. SSAOBlurHRenderEffect: string;
  59160. /**
  59161. * @ignore
  59162. * The vertical blur PostProcess id in the pipeline
  59163. */
  59164. SSAOBlurVRenderEffect: string;
  59165. /**
  59166. * @ignore
  59167. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59168. */
  59169. SSAOCombineRenderEffect: string;
  59170. /**
  59171. * The output strength of the SSAO post-process. Default value is 1.0.
  59172. */
  59173. totalStrength: number;
  59174. /**
  59175. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59176. */
  59177. maxZ: number;
  59178. /**
  59179. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59180. */
  59181. minZAspect: number;
  59182. private _samples;
  59183. /**
  59184. * Number of samples used for the SSAO calculations. Default value is 8
  59185. */
  59186. samples: number;
  59187. private _textureSamples;
  59188. /**
  59189. * Number of samples to use for antialiasing
  59190. */
  59191. textureSamples: number;
  59192. /**
  59193. * Ratio object used for SSAO ratio and blur ratio
  59194. */
  59195. private _ratio;
  59196. /**
  59197. * Dynamically generated sphere sampler.
  59198. */
  59199. private _sampleSphere;
  59200. /**
  59201. * Blur filter offsets
  59202. */
  59203. private _samplerOffsets;
  59204. private _expensiveBlur;
  59205. /**
  59206. * If bilateral blur should be used
  59207. */
  59208. expensiveBlur: boolean;
  59209. /**
  59210. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59211. */
  59212. radius: number;
  59213. /**
  59214. * The base color of the SSAO post-process
  59215. * The final result is "base + ssao" between [0, 1]
  59216. */
  59217. base: number;
  59218. /**
  59219. * Support test.
  59220. */
  59221. static readonly IsSupported: boolean;
  59222. private _scene;
  59223. private _depthTexture;
  59224. private _normalTexture;
  59225. private _randomTexture;
  59226. private _originalColorPostProcess;
  59227. private _ssaoPostProcess;
  59228. private _blurHPostProcess;
  59229. private _blurVPostProcess;
  59230. private _ssaoCombinePostProcess;
  59231. private _firstUpdate;
  59232. /**
  59233. * Gets active scene
  59234. */
  59235. readonly scene: Scene;
  59236. /**
  59237. * @constructor
  59238. * @param name The rendering pipeline name
  59239. * @param scene The scene linked to this pipeline
  59240. * @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 }
  59241. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59242. */
  59243. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59244. /**
  59245. * Get the class name
  59246. * @returns "SSAO2RenderingPipeline"
  59247. */
  59248. getClassName(): string;
  59249. /**
  59250. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59251. */
  59252. dispose(disableGeometryBufferRenderer?: boolean): void;
  59253. private _createBlurPostProcess;
  59254. /** @hidden */
  59255. _rebuild(): void;
  59256. private _bits;
  59257. private _radicalInverse_VdC;
  59258. private _hammersley;
  59259. private _hemisphereSample_uniform;
  59260. private _generateHemisphere;
  59261. private _createSSAOPostProcess;
  59262. private _createSSAOCombinePostProcess;
  59263. private _createRandomTexture;
  59264. /**
  59265. * Serialize the rendering pipeline (Used when exporting)
  59266. * @returns the serialized object
  59267. */
  59268. serialize(): any;
  59269. /**
  59270. * Parse the serialized pipeline
  59271. * @param source Source pipeline.
  59272. * @param scene The scene to load the pipeline to.
  59273. * @param rootUrl The URL of the serialized pipeline.
  59274. * @returns An instantiated pipeline from the serialized object.
  59275. */
  59276. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59277. }
  59278. }
  59279. declare module "babylonjs/Shaders/ssao.fragment" {
  59280. /** @hidden */
  59281. export var ssaoPixelShader: {
  59282. name: string;
  59283. shader: string;
  59284. };
  59285. }
  59286. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59287. import { Camera } from "babylonjs/Cameras/camera";
  59288. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59289. import { Scene } from "babylonjs/scene";
  59290. import "babylonjs/Shaders/ssao.fragment";
  59291. import "babylonjs/Shaders/ssaoCombine.fragment";
  59292. /**
  59293. * Render pipeline to produce ssao effect
  59294. */
  59295. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59296. /**
  59297. * @ignore
  59298. * The PassPostProcess id in the pipeline that contains the original scene color
  59299. */
  59300. SSAOOriginalSceneColorEffect: string;
  59301. /**
  59302. * @ignore
  59303. * The SSAO PostProcess id in the pipeline
  59304. */
  59305. SSAORenderEffect: string;
  59306. /**
  59307. * @ignore
  59308. * The horizontal blur PostProcess id in the pipeline
  59309. */
  59310. SSAOBlurHRenderEffect: string;
  59311. /**
  59312. * @ignore
  59313. * The vertical blur PostProcess id in the pipeline
  59314. */
  59315. SSAOBlurVRenderEffect: string;
  59316. /**
  59317. * @ignore
  59318. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59319. */
  59320. SSAOCombineRenderEffect: string;
  59321. /**
  59322. * The output strength of the SSAO post-process. Default value is 1.0.
  59323. */
  59324. totalStrength: number;
  59325. /**
  59326. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59327. */
  59328. radius: number;
  59329. /**
  59330. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59331. * Must not be equal to fallOff and superior to fallOff.
  59332. * Default value is 0.0075
  59333. */
  59334. area: number;
  59335. /**
  59336. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59337. * Must not be equal to area and inferior to area.
  59338. * Default value is 0.000001
  59339. */
  59340. fallOff: number;
  59341. /**
  59342. * The base color of the SSAO post-process
  59343. * The final result is "base + ssao" between [0, 1]
  59344. */
  59345. base: number;
  59346. private _scene;
  59347. private _depthTexture;
  59348. private _randomTexture;
  59349. private _originalColorPostProcess;
  59350. private _ssaoPostProcess;
  59351. private _blurHPostProcess;
  59352. private _blurVPostProcess;
  59353. private _ssaoCombinePostProcess;
  59354. private _firstUpdate;
  59355. /**
  59356. * Gets active scene
  59357. */
  59358. readonly scene: Scene;
  59359. /**
  59360. * @constructor
  59361. * @param name - The rendering pipeline name
  59362. * @param scene - The scene linked to this pipeline
  59363. * @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 }
  59364. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59365. */
  59366. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59367. /**
  59368. * Get the class name
  59369. * @returns "SSAORenderingPipeline"
  59370. */
  59371. getClassName(): string;
  59372. /**
  59373. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59374. */
  59375. dispose(disableDepthRender?: boolean): void;
  59376. private _createBlurPostProcess;
  59377. /** @hidden */
  59378. _rebuild(): void;
  59379. private _createSSAOPostProcess;
  59380. private _createSSAOCombinePostProcess;
  59381. private _createRandomTexture;
  59382. }
  59383. }
  59384. declare module "babylonjs/Shaders/standard.fragment" {
  59385. /** @hidden */
  59386. export var standardPixelShader: {
  59387. name: string;
  59388. shader: string;
  59389. };
  59390. }
  59391. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59392. import { Nullable } from "babylonjs/types";
  59393. import { IAnimatable } from "babylonjs/Misc/tools";
  59394. import { Camera } from "babylonjs/Cameras/camera";
  59395. import { Texture } from "babylonjs/Materials/Textures/texture";
  59396. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59397. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59398. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59399. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59400. import { IDisposable } from "babylonjs/scene";
  59401. import { SpotLight } from "babylonjs/Lights/spotLight";
  59402. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59403. import { Scene } from "babylonjs/scene";
  59404. import { Animation } from "babylonjs/Animations/animation";
  59405. import "babylonjs/Shaders/standard.fragment";
  59406. /**
  59407. * Standard rendering pipeline
  59408. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59409. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59410. */
  59411. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59412. /**
  59413. * Public members
  59414. */
  59415. /**
  59416. * Post-process which contains the original scene color before the pipeline applies all the effects
  59417. */
  59418. originalPostProcess: Nullable<PostProcess>;
  59419. /**
  59420. * Post-process used to down scale an image x4
  59421. */
  59422. downSampleX4PostProcess: Nullable<PostProcess>;
  59423. /**
  59424. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59425. */
  59426. brightPassPostProcess: Nullable<PostProcess>;
  59427. /**
  59428. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59429. */
  59430. blurHPostProcesses: PostProcess[];
  59431. /**
  59432. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59433. */
  59434. blurVPostProcesses: PostProcess[];
  59435. /**
  59436. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59437. */
  59438. textureAdderPostProcess: Nullable<PostProcess>;
  59439. /**
  59440. * Post-process used to create volumetric lighting effect
  59441. */
  59442. volumetricLightPostProcess: Nullable<PostProcess>;
  59443. /**
  59444. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59445. */
  59446. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59447. /**
  59448. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59449. */
  59450. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59451. /**
  59452. * Post-process used to merge the volumetric light effect and the real scene color
  59453. */
  59454. volumetricLightMergePostProces: Nullable<PostProcess>;
  59455. /**
  59456. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59457. */
  59458. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59459. /**
  59460. * Base post-process used to calculate the average luminance of the final image for HDR
  59461. */
  59462. luminancePostProcess: Nullable<PostProcess>;
  59463. /**
  59464. * Post-processes used to create down sample post-processes in order to get
  59465. * the average luminance of the final image for HDR
  59466. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59467. */
  59468. luminanceDownSamplePostProcesses: PostProcess[];
  59469. /**
  59470. * Post-process used to create a HDR effect (light adaptation)
  59471. */
  59472. hdrPostProcess: Nullable<PostProcess>;
  59473. /**
  59474. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59475. */
  59476. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59477. /**
  59478. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59479. */
  59480. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59481. /**
  59482. * Post-process used to merge the final HDR post-process and the real scene color
  59483. */
  59484. hdrFinalPostProcess: Nullable<PostProcess>;
  59485. /**
  59486. * Post-process used to create a lens flare effect
  59487. */
  59488. lensFlarePostProcess: Nullable<PostProcess>;
  59489. /**
  59490. * Post-process that merges the result of the lens flare post-process and the real scene color
  59491. */
  59492. lensFlareComposePostProcess: Nullable<PostProcess>;
  59493. /**
  59494. * Post-process used to create a motion blur effect
  59495. */
  59496. motionBlurPostProcess: Nullable<PostProcess>;
  59497. /**
  59498. * Post-process used to create a depth of field effect
  59499. */
  59500. depthOfFieldPostProcess: Nullable<PostProcess>;
  59501. /**
  59502. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59503. */
  59504. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59505. /**
  59506. * Represents the brightness threshold in order to configure the illuminated surfaces
  59507. */
  59508. brightThreshold: number;
  59509. /**
  59510. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59511. */
  59512. blurWidth: number;
  59513. /**
  59514. * Sets if the blur for highlighted surfaces must be only horizontal
  59515. */
  59516. horizontalBlur: boolean;
  59517. /**
  59518. * Gets the overall exposure used by the pipeline
  59519. */
  59520. /**
  59521. * Sets the overall exposure used by the pipeline
  59522. */
  59523. exposure: number;
  59524. /**
  59525. * Texture used typically to simulate "dirty" on camera lens
  59526. */
  59527. lensTexture: Nullable<Texture>;
  59528. /**
  59529. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59530. */
  59531. volumetricLightCoefficient: number;
  59532. /**
  59533. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59534. */
  59535. volumetricLightPower: number;
  59536. /**
  59537. * Used the set the blur intensity to smooth the volumetric lights
  59538. */
  59539. volumetricLightBlurScale: number;
  59540. /**
  59541. * Light (spot or directional) used to generate the volumetric lights rays
  59542. * The source light must have a shadow generate so the pipeline can get its
  59543. * depth map
  59544. */
  59545. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59546. /**
  59547. * For eye adaptation, represents the minimum luminance the eye can see
  59548. */
  59549. hdrMinimumLuminance: number;
  59550. /**
  59551. * For eye adaptation, represents the decrease luminance speed
  59552. */
  59553. hdrDecreaseRate: number;
  59554. /**
  59555. * For eye adaptation, represents the increase luminance speed
  59556. */
  59557. hdrIncreaseRate: number;
  59558. /**
  59559. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59560. */
  59561. /**
  59562. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59563. */
  59564. hdrAutoExposure: boolean;
  59565. /**
  59566. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59567. */
  59568. lensColorTexture: Nullable<Texture>;
  59569. /**
  59570. * The overall strengh for the lens flare effect
  59571. */
  59572. lensFlareStrength: number;
  59573. /**
  59574. * Dispersion coefficient for lens flare ghosts
  59575. */
  59576. lensFlareGhostDispersal: number;
  59577. /**
  59578. * Main lens flare halo width
  59579. */
  59580. lensFlareHaloWidth: number;
  59581. /**
  59582. * Based on the lens distortion effect, defines how much the lens flare result
  59583. * is distorted
  59584. */
  59585. lensFlareDistortionStrength: number;
  59586. /**
  59587. * Lens star texture must be used to simulate rays on the flares and is available
  59588. * in the documentation
  59589. */
  59590. lensStarTexture: Nullable<Texture>;
  59591. /**
  59592. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59593. * flare effect by taking account of the dirt texture
  59594. */
  59595. lensFlareDirtTexture: Nullable<Texture>;
  59596. /**
  59597. * Represents the focal length for the depth of field effect
  59598. */
  59599. depthOfFieldDistance: number;
  59600. /**
  59601. * Represents the blur intensity for the blurred part of the depth of field effect
  59602. */
  59603. depthOfFieldBlurWidth: number;
  59604. /**
  59605. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59606. */
  59607. /**
  59608. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59609. */
  59610. motionStrength: number;
  59611. /**
  59612. * Gets wether or not the motion blur post-process is object based or screen based.
  59613. */
  59614. /**
  59615. * Sets wether or not the motion blur post-process should be object based or screen based
  59616. */
  59617. objectBasedMotionBlur: boolean;
  59618. /**
  59619. * List of animations for the pipeline (IAnimatable implementation)
  59620. */
  59621. animations: Animation[];
  59622. /**
  59623. * Private members
  59624. */
  59625. private _scene;
  59626. private _currentDepthOfFieldSource;
  59627. private _basePostProcess;
  59628. private _fixedExposure;
  59629. private _currentExposure;
  59630. private _hdrAutoExposure;
  59631. private _hdrCurrentLuminance;
  59632. private _motionStrength;
  59633. private _isObjectBasedMotionBlur;
  59634. private _floatTextureType;
  59635. private _ratio;
  59636. private _bloomEnabled;
  59637. private _depthOfFieldEnabled;
  59638. private _vlsEnabled;
  59639. private _lensFlareEnabled;
  59640. private _hdrEnabled;
  59641. private _motionBlurEnabled;
  59642. private _fxaaEnabled;
  59643. private _motionBlurSamples;
  59644. private _volumetricLightStepsCount;
  59645. private _samples;
  59646. /**
  59647. * @ignore
  59648. * Specifies if the bloom pipeline is enabled
  59649. */
  59650. BloomEnabled: boolean;
  59651. /**
  59652. * @ignore
  59653. * Specifies if the depth of field pipeline is enabed
  59654. */
  59655. DepthOfFieldEnabled: boolean;
  59656. /**
  59657. * @ignore
  59658. * Specifies if the lens flare pipeline is enabed
  59659. */
  59660. LensFlareEnabled: boolean;
  59661. /**
  59662. * @ignore
  59663. * Specifies if the HDR pipeline is enabled
  59664. */
  59665. HDREnabled: boolean;
  59666. /**
  59667. * @ignore
  59668. * Specifies if the volumetric lights scattering effect is enabled
  59669. */
  59670. VLSEnabled: boolean;
  59671. /**
  59672. * @ignore
  59673. * Specifies if the motion blur effect is enabled
  59674. */
  59675. MotionBlurEnabled: boolean;
  59676. /**
  59677. * Specifies if anti-aliasing is enabled
  59678. */
  59679. fxaaEnabled: boolean;
  59680. /**
  59681. * Specifies the number of steps used to calculate the volumetric lights
  59682. * Typically in interval [50, 200]
  59683. */
  59684. volumetricLightStepsCount: number;
  59685. /**
  59686. * Specifies the number of samples used for the motion blur effect
  59687. * Typically in interval [16, 64]
  59688. */
  59689. motionBlurSamples: number;
  59690. /**
  59691. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59692. */
  59693. samples: number;
  59694. /**
  59695. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59696. * @constructor
  59697. * @param name The rendering pipeline name
  59698. * @param scene The scene linked to this pipeline
  59699. * @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)
  59700. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59701. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59702. */
  59703. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59704. private _buildPipeline;
  59705. private _createDownSampleX4PostProcess;
  59706. private _createBrightPassPostProcess;
  59707. private _createBlurPostProcesses;
  59708. private _createTextureAdderPostProcess;
  59709. private _createVolumetricLightPostProcess;
  59710. private _createLuminancePostProcesses;
  59711. private _createHdrPostProcess;
  59712. private _createLensFlarePostProcess;
  59713. private _createDepthOfFieldPostProcess;
  59714. private _createMotionBlurPostProcess;
  59715. private _getDepthTexture;
  59716. private _disposePostProcesses;
  59717. /**
  59718. * Dispose of the pipeline and stop all post processes
  59719. */
  59720. dispose(): void;
  59721. /**
  59722. * Serialize the rendering pipeline (Used when exporting)
  59723. * @returns the serialized object
  59724. */
  59725. serialize(): any;
  59726. /**
  59727. * Parse the serialized pipeline
  59728. * @param source Source pipeline.
  59729. * @param scene The scene to load the pipeline to.
  59730. * @param rootUrl The URL of the serialized pipeline.
  59731. * @returns An instantiated pipeline from the serialized object.
  59732. */
  59733. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59734. /**
  59735. * Luminance steps
  59736. */
  59737. static LuminanceSteps: number;
  59738. }
  59739. }
  59740. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  59741. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  59742. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  59743. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  59744. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  59745. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  59746. }
  59747. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  59748. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  59749. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59750. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59751. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59752. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59753. }
  59754. declare module "babylonjs/Shaders/tonemap.fragment" {
  59755. /** @hidden */
  59756. export var tonemapPixelShader: {
  59757. name: string;
  59758. shader: string;
  59759. };
  59760. }
  59761. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  59762. import { Camera } from "babylonjs/Cameras/camera";
  59763. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59764. import "babylonjs/Shaders/tonemap.fragment";
  59765. import { Engine } from "babylonjs/Engines/engine";
  59766. /** Defines operator used for tonemapping */
  59767. export enum TonemappingOperator {
  59768. /** Hable */
  59769. Hable = 0,
  59770. /** Reinhard */
  59771. Reinhard = 1,
  59772. /** HejiDawson */
  59773. HejiDawson = 2,
  59774. /** Photographic */
  59775. Photographic = 3
  59776. }
  59777. /**
  59778. * Defines a post process to apply tone mapping
  59779. */
  59780. export class TonemapPostProcess extends PostProcess {
  59781. private _operator;
  59782. /** Defines the required exposure adjustement */
  59783. exposureAdjustment: number;
  59784. /**
  59785. * Creates a new TonemapPostProcess
  59786. * @param name defines the name of the postprocess
  59787. * @param _operator defines the operator to use
  59788. * @param exposureAdjustment defines the required exposure adjustement
  59789. * @param camera defines the camera to use (can be null)
  59790. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59791. * @param engine defines the hosting engine (can be ignore if camera is set)
  59792. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59793. */
  59794. constructor(name: string, _operator: TonemappingOperator,
  59795. /** Defines the required exposure adjustement */
  59796. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59797. }
  59798. }
  59799. declare module "babylonjs/Shaders/depth.vertex" {
  59800. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59801. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59802. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59803. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59804. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59805. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59806. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59807. /** @hidden */
  59808. export var depthVertexShader: {
  59809. name: string;
  59810. shader: string;
  59811. };
  59812. }
  59813. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  59814. /** @hidden */
  59815. export var volumetricLightScatteringPixelShader: {
  59816. name: string;
  59817. shader: string;
  59818. };
  59819. }
  59820. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  59821. /** @hidden */
  59822. export var volumetricLightScatteringPassPixelShader: {
  59823. name: string;
  59824. shader: string;
  59825. };
  59826. }
  59827. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  59828. import { Vector3 } from "babylonjs/Maths/math";
  59829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59830. import { Mesh } from "babylonjs/Meshes/mesh";
  59831. import { Camera } from "babylonjs/Cameras/camera";
  59832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59833. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59834. import { Scene } from "babylonjs/scene";
  59835. import "babylonjs/Meshes/Builders/planeBuilder";
  59836. import "babylonjs/Shaders/depth.vertex";
  59837. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  59838. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  59839. import { Engine } from "babylonjs/Engines/engine";
  59840. /**
  59841. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59842. */
  59843. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59844. private _volumetricLightScatteringPass;
  59845. private _volumetricLightScatteringRTT;
  59846. private _viewPort;
  59847. private _screenCoordinates;
  59848. private _cachedDefines;
  59849. /**
  59850. * If not undefined, the mesh position is computed from the attached node position
  59851. */
  59852. attachedNode: {
  59853. position: Vector3;
  59854. };
  59855. /**
  59856. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59857. */
  59858. customMeshPosition: Vector3;
  59859. /**
  59860. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59861. */
  59862. useCustomMeshPosition: boolean;
  59863. /**
  59864. * If the post-process should inverse the light scattering direction
  59865. */
  59866. invert: boolean;
  59867. /**
  59868. * The internal mesh used by the post-process
  59869. */
  59870. mesh: Mesh;
  59871. /**
  59872. * @hidden
  59873. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59874. */
  59875. useDiffuseColor: boolean;
  59876. /**
  59877. * Array containing the excluded meshes not rendered in the internal pass
  59878. */
  59879. excludedMeshes: AbstractMesh[];
  59880. /**
  59881. * Controls the overall intensity of the post-process
  59882. */
  59883. exposure: number;
  59884. /**
  59885. * Dissipates each sample's contribution in range [0, 1]
  59886. */
  59887. decay: number;
  59888. /**
  59889. * Controls the overall intensity of each sample
  59890. */
  59891. weight: number;
  59892. /**
  59893. * Controls the density of each sample
  59894. */
  59895. density: number;
  59896. /**
  59897. * @constructor
  59898. * @param name The post-process name
  59899. * @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)
  59900. * @param camera The camera that the post-process will be attached to
  59901. * @param mesh The mesh used to create the light scattering
  59902. * @param samples The post-process quality, default 100
  59903. * @param samplingModeThe post-process filtering mode
  59904. * @param engine The babylon engine
  59905. * @param reusable If the post-process is reusable
  59906. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59907. */
  59908. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59909. /**
  59910. * Returns the string "VolumetricLightScatteringPostProcess"
  59911. * @returns "VolumetricLightScatteringPostProcess"
  59912. */
  59913. getClassName(): string;
  59914. private _isReady;
  59915. /**
  59916. * Sets the new light position for light scattering effect
  59917. * @param position The new custom light position
  59918. */
  59919. setCustomMeshPosition(position: Vector3): void;
  59920. /**
  59921. * Returns the light position for light scattering effect
  59922. * @return Vector3 The custom light position
  59923. */
  59924. getCustomMeshPosition(): Vector3;
  59925. /**
  59926. * Disposes the internal assets and detaches the post-process from the camera
  59927. */
  59928. dispose(camera: Camera): void;
  59929. /**
  59930. * Returns the render target texture used by the post-process
  59931. * @return the render target texture used by the post-process
  59932. */
  59933. getPass(): RenderTargetTexture;
  59934. private _meshExcluded;
  59935. private _createPass;
  59936. private _updateMeshScreenCoordinates;
  59937. /**
  59938. * Creates a default mesh for the Volumeric Light Scattering post-process
  59939. * @param name The mesh name
  59940. * @param scene The scene where to create the mesh
  59941. * @return the default mesh
  59942. */
  59943. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59944. }
  59945. }
  59946. declare module "babylonjs/PostProcesses/index" {
  59947. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  59948. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  59949. export * from "babylonjs/PostProcesses/bloomEffect";
  59950. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  59951. export * from "babylonjs/PostProcesses/blurPostProcess";
  59952. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59953. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  59954. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  59955. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  59956. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59957. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  59958. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  59959. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  59960. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59961. export * from "babylonjs/PostProcesses/filterPostProcess";
  59962. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  59963. export * from "babylonjs/PostProcesses/grainPostProcess";
  59964. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  59965. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59966. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  59967. export * from "babylonjs/PostProcesses/passPostProcess";
  59968. export * from "babylonjs/PostProcesses/postProcess";
  59969. export * from "babylonjs/PostProcesses/postProcessManager";
  59970. export * from "babylonjs/PostProcesses/refractionPostProcess";
  59971. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  59972. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  59973. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  59974. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  59975. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  59976. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  59977. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  59978. }
  59979. declare module "babylonjs/Probes/index" {
  59980. export * from "babylonjs/Probes/reflectionProbe";
  59981. }
  59982. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  59983. import { Scene } from "babylonjs/scene";
  59984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59985. import { Color3 } from "babylonjs/Maths/math";
  59986. import { SmartArray } from "babylonjs/Misc/smartArray";
  59987. import { ISceneComponent } from "babylonjs/sceneComponent";
  59988. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  59989. import "babylonjs/Meshes/Builders/boxBuilder";
  59990. import "babylonjs/Shaders/color.fragment";
  59991. import "babylonjs/Shaders/color.vertex";
  59992. module "babylonjs/scene" {
  59993. interface Scene {
  59994. /** @hidden (Backing field) */
  59995. _boundingBoxRenderer: BoundingBoxRenderer;
  59996. /** @hidden (Backing field) */
  59997. _forceShowBoundingBoxes: boolean;
  59998. /**
  59999. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60000. */
  60001. forceShowBoundingBoxes: boolean;
  60002. /**
  60003. * Gets the bounding box renderer associated with the scene
  60004. * @returns a BoundingBoxRenderer
  60005. */
  60006. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60007. }
  60008. }
  60009. module "babylonjs/Meshes/abstractMesh" {
  60010. interface AbstractMesh {
  60011. /** @hidden (Backing field) */
  60012. _showBoundingBox: boolean;
  60013. /**
  60014. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60015. */
  60016. showBoundingBox: boolean;
  60017. }
  60018. }
  60019. /**
  60020. * Component responsible of rendering the bounding box of the meshes in a scene.
  60021. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60022. */
  60023. export class BoundingBoxRenderer implements ISceneComponent {
  60024. /**
  60025. * The component name helpfull to identify the component in the list of scene components.
  60026. */
  60027. readonly name: string;
  60028. /**
  60029. * The scene the component belongs to.
  60030. */
  60031. scene: Scene;
  60032. /**
  60033. * Color of the bounding box lines placed in front of an object
  60034. */
  60035. frontColor: Color3;
  60036. /**
  60037. * Color of the bounding box lines placed behind an object
  60038. */
  60039. backColor: Color3;
  60040. /**
  60041. * Defines if the renderer should show the back lines or not
  60042. */
  60043. showBackLines: boolean;
  60044. /**
  60045. * @hidden
  60046. */
  60047. renderList: SmartArray<BoundingBox>;
  60048. private _colorShader;
  60049. private _vertexBuffers;
  60050. private _indexBuffer;
  60051. private _fillIndexBuffer;
  60052. private _fillIndexData;
  60053. /**
  60054. * Instantiates a new bounding box renderer in a scene.
  60055. * @param scene the scene the renderer renders in
  60056. */
  60057. constructor(scene: Scene);
  60058. /**
  60059. * Registers the component in a given scene
  60060. */
  60061. register(): void;
  60062. private _evaluateSubMesh;
  60063. private _activeMesh;
  60064. private _prepareRessources;
  60065. private _createIndexBuffer;
  60066. /**
  60067. * Rebuilds the elements related to this component in case of
  60068. * context lost for instance.
  60069. */
  60070. rebuild(): void;
  60071. /**
  60072. * @hidden
  60073. */
  60074. reset(): void;
  60075. /**
  60076. * Render the bounding boxes of a specific rendering group
  60077. * @param renderingGroupId defines the rendering group to render
  60078. */
  60079. render(renderingGroupId: number): void;
  60080. /**
  60081. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60082. * @param mesh Define the mesh to render the occlusion bounding box for
  60083. */
  60084. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60085. /**
  60086. * Dispose and release the resources attached to this renderer.
  60087. */
  60088. dispose(): void;
  60089. }
  60090. }
  60091. declare module "babylonjs/Shaders/depth.fragment" {
  60092. /** @hidden */
  60093. export var depthPixelShader: {
  60094. name: string;
  60095. shader: string;
  60096. };
  60097. }
  60098. declare module "babylonjs/Rendering/depthRenderer" {
  60099. import { Nullable } from "babylonjs/types";
  60100. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60101. import { Scene } from "babylonjs/scene";
  60102. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60103. import { Camera } from "babylonjs/Cameras/camera";
  60104. import "babylonjs/Shaders/depth.fragment";
  60105. import "babylonjs/Shaders/depth.vertex";
  60106. /**
  60107. * This represents a depth renderer in Babylon.
  60108. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60109. */
  60110. export class DepthRenderer {
  60111. private _scene;
  60112. private _depthMap;
  60113. private _effect;
  60114. private _cachedDefines;
  60115. private _camera;
  60116. /**
  60117. * Specifiess that the depth renderer will only be used within
  60118. * the camera it is created for.
  60119. * This can help forcing its rendering during the camera processing.
  60120. */
  60121. useOnlyInActiveCamera: boolean;
  60122. /** @hidden */
  60123. static _SceneComponentInitialization: (scene: Scene) => void;
  60124. /**
  60125. * Instantiates a depth renderer
  60126. * @param scene The scene the renderer belongs to
  60127. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60128. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60129. */
  60130. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60131. /**
  60132. * Creates the depth rendering effect and checks if the effect is ready.
  60133. * @param subMesh The submesh to be used to render the depth map of
  60134. * @param useInstances If multiple world instances should be used
  60135. * @returns if the depth renderer is ready to render the depth map
  60136. */
  60137. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60138. /**
  60139. * Gets the texture which the depth map will be written to.
  60140. * @returns The depth map texture
  60141. */
  60142. getDepthMap(): RenderTargetTexture;
  60143. /**
  60144. * Disposes of the depth renderer.
  60145. */
  60146. dispose(): void;
  60147. }
  60148. }
  60149. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60150. import { Nullable } from "babylonjs/types";
  60151. import { Scene } from "babylonjs/scene";
  60152. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60153. import { Camera } from "babylonjs/Cameras/camera";
  60154. import { ISceneComponent } from "babylonjs/sceneComponent";
  60155. module "babylonjs/scene" {
  60156. interface Scene {
  60157. /** @hidden (Backing field) */
  60158. _depthRenderer: {
  60159. [id: string]: DepthRenderer;
  60160. };
  60161. /**
  60162. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60163. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60164. * @returns the created depth renderer
  60165. */
  60166. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60167. /**
  60168. * Disables a depth renderer for a given camera
  60169. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60170. */
  60171. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60172. }
  60173. }
  60174. /**
  60175. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60176. * in several rendering techniques.
  60177. */
  60178. export class DepthRendererSceneComponent implements ISceneComponent {
  60179. /**
  60180. * The component name helpfull to identify the component in the list of scene components.
  60181. */
  60182. readonly name: string;
  60183. /**
  60184. * The scene the component belongs to.
  60185. */
  60186. scene: Scene;
  60187. /**
  60188. * Creates a new instance of the component for the given scene
  60189. * @param scene Defines the scene to register the component in
  60190. */
  60191. constructor(scene: Scene);
  60192. /**
  60193. * Registers the component in a given scene
  60194. */
  60195. register(): void;
  60196. /**
  60197. * Rebuilds the elements related to this component in case of
  60198. * context lost for instance.
  60199. */
  60200. rebuild(): void;
  60201. /**
  60202. * Disposes the component and the associated ressources
  60203. */
  60204. dispose(): void;
  60205. private _gatherRenderTargets;
  60206. private _gatherActiveCameraRenderTargets;
  60207. }
  60208. }
  60209. declare module "babylonjs/Shaders/outline.fragment" {
  60210. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60211. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60212. /** @hidden */
  60213. export var outlinePixelShader: {
  60214. name: string;
  60215. shader: string;
  60216. };
  60217. }
  60218. declare module "babylonjs/Shaders/outline.vertex" {
  60219. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60220. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60221. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60222. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60223. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60224. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60225. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60226. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60227. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60228. /** @hidden */
  60229. export var outlineVertexShader: {
  60230. name: string;
  60231. shader: string;
  60232. };
  60233. }
  60234. declare module "babylonjs/Rendering/outlineRenderer" {
  60235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60236. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60237. import { Scene } from "babylonjs/scene";
  60238. import { ISceneComponent } from "babylonjs/sceneComponent";
  60239. import "babylonjs/Shaders/outline.fragment";
  60240. import "babylonjs/Shaders/outline.vertex";
  60241. module "babylonjs/scene" {
  60242. interface Scene {
  60243. /** @hidden */
  60244. _outlineRenderer: OutlineRenderer;
  60245. /**
  60246. * Gets the outline renderer associated with the scene
  60247. * @returns a OutlineRenderer
  60248. */
  60249. getOutlineRenderer(): OutlineRenderer;
  60250. }
  60251. }
  60252. module "babylonjs/Meshes/abstractMesh" {
  60253. interface AbstractMesh {
  60254. /** @hidden (Backing field) */
  60255. _renderOutline: boolean;
  60256. /**
  60257. * Gets or sets a boolean indicating if the outline must be rendered as well
  60258. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60259. */
  60260. renderOutline: boolean;
  60261. /** @hidden (Backing field) */
  60262. _renderOverlay: boolean;
  60263. /**
  60264. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60265. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60266. */
  60267. renderOverlay: boolean;
  60268. }
  60269. }
  60270. /**
  60271. * This class is responsible to draw bothe outline/overlay of meshes.
  60272. * It should not be used directly but through the available method on mesh.
  60273. */
  60274. export class OutlineRenderer implements ISceneComponent {
  60275. /**
  60276. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60277. */
  60278. private static _StencilReference;
  60279. /**
  60280. * The name of the component. Each component must have a unique name.
  60281. */
  60282. name: string;
  60283. /**
  60284. * The scene the component belongs to.
  60285. */
  60286. scene: Scene;
  60287. /**
  60288. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60289. */
  60290. zOffset: number;
  60291. private _engine;
  60292. private _effect;
  60293. private _cachedDefines;
  60294. private _savedDepthWrite;
  60295. /**
  60296. * Instantiates a new outline renderer. (There could be only one per scene).
  60297. * @param scene Defines the scene it belongs to
  60298. */
  60299. constructor(scene: Scene);
  60300. /**
  60301. * Register the component to one instance of a scene.
  60302. */
  60303. register(): void;
  60304. /**
  60305. * Rebuilds the elements related to this component in case of
  60306. * context lost for instance.
  60307. */
  60308. rebuild(): void;
  60309. /**
  60310. * Disposes the component and the associated ressources.
  60311. */
  60312. dispose(): void;
  60313. /**
  60314. * Renders the outline in the canvas.
  60315. * @param subMesh Defines the sumesh to render
  60316. * @param batch Defines the batch of meshes in case of instances
  60317. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60318. */
  60319. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60320. /**
  60321. * Returns whether or not the outline renderer is ready for a given submesh.
  60322. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60323. * @param subMesh Defines the submesh to check readyness for
  60324. * @param useInstances Defines wheter wee are trying to render instances or not
  60325. * @returns true if ready otherwise false
  60326. */
  60327. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60328. private _beforeRenderingMesh;
  60329. private _afterRenderingMesh;
  60330. }
  60331. }
  60332. declare module "babylonjs/Rendering/index" {
  60333. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60334. export * from "babylonjs/Rendering/depthRenderer";
  60335. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60336. export * from "babylonjs/Rendering/edgesRenderer";
  60337. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60338. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60339. export * from "babylonjs/Rendering/outlineRenderer";
  60340. export * from "babylonjs/Rendering/renderingGroup";
  60341. export * from "babylonjs/Rendering/renderingManager";
  60342. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60343. }
  60344. declare module "babylonjs/Sprites/index" {
  60345. export * from "babylonjs/Sprites/sprite";
  60346. export * from "babylonjs/Sprites/spriteManager";
  60347. export * from "babylonjs/Sprites/spriteSceneComponent";
  60348. }
  60349. declare module "babylonjs/Misc/assetsManager" {
  60350. import { Scene } from "babylonjs/scene";
  60351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60352. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60353. import { Skeleton } from "babylonjs/Bones/skeleton";
  60354. import { Observable } from "babylonjs/Misc/observable";
  60355. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60356. import { Texture } from "babylonjs/Materials/Textures/texture";
  60357. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60358. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60359. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60360. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60361. /**
  60362. * Defines the list of states available for a task inside a AssetsManager
  60363. */
  60364. export enum AssetTaskState {
  60365. /**
  60366. * Initialization
  60367. */
  60368. INIT = 0,
  60369. /**
  60370. * Running
  60371. */
  60372. RUNNING = 1,
  60373. /**
  60374. * Done
  60375. */
  60376. DONE = 2,
  60377. /**
  60378. * Error
  60379. */
  60380. ERROR = 3
  60381. }
  60382. /**
  60383. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60384. */
  60385. export abstract class AbstractAssetTask {
  60386. /**
  60387. * Task name
  60388. */ name: string;
  60389. /**
  60390. * Callback called when the task is successful
  60391. */
  60392. onSuccess: (task: any) => void;
  60393. /**
  60394. * Callback called when the task is not successful
  60395. */
  60396. onError: (task: any, message?: string, exception?: any) => void;
  60397. /**
  60398. * Creates a new AssetsManager
  60399. * @param name defines the name of the task
  60400. */
  60401. constructor(
  60402. /**
  60403. * Task name
  60404. */ name: string);
  60405. private _isCompleted;
  60406. private _taskState;
  60407. private _errorObject;
  60408. /**
  60409. * Get if the task is completed
  60410. */
  60411. readonly isCompleted: boolean;
  60412. /**
  60413. * Gets the current state of the task
  60414. */
  60415. readonly taskState: AssetTaskState;
  60416. /**
  60417. * Gets the current error object (if task is in error)
  60418. */
  60419. readonly errorObject: {
  60420. message?: string;
  60421. exception?: any;
  60422. };
  60423. /**
  60424. * Internal only
  60425. * @hidden
  60426. */
  60427. _setErrorObject(message?: string, exception?: any): void;
  60428. /**
  60429. * Execute the current task
  60430. * @param scene defines the scene where you want your assets to be loaded
  60431. * @param onSuccess is a callback called when the task is successfully executed
  60432. * @param onError is a callback called if an error occurs
  60433. */
  60434. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60435. /**
  60436. * Execute the current task
  60437. * @param scene defines the scene where you want your assets to be loaded
  60438. * @param onSuccess is a callback called when the task is successfully executed
  60439. * @param onError is a callback called if an error occurs
  60440. */
  60441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60442. /**
  60443. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60444. * This can be used with failed tasks that have the reason for failure fixed.
  60445. */
  60446. reset(): void;
  60447. private onErrorCallback;
  60448. private onDoneCallback;
  60449. }
  60450. /**
  60451. * Define the interface used by progress events raised during assets loading
  60452. */
  60453. export interface IAssetsProgressEvent {
  60454. /**
  60455. * Defines the number of remaining tasks to process
  60456. */
  60457. remainingCount: number;
  60458. /**
  60459. * Defines the total number of tasks
  60460. */
  60461. totalCount: number;
  60462. /**
  60463. * Defines the task that was just processed
  60464. */
  60465. task: AbstractAssetTask;
  60466. }
  60467. /**
  60468. * Class used to share progress information about assets loading
  60469. */
  60470. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60471. /**
  60472. * Defines the number of remaining tasks to process
  60473. */
  60474. remainingCount: number;
  60475. /**
  60476. * Defines the total number of tasks
  60477. */
  60478. totalCount: number;
  60479. /**
  60480. * Defines the task that was just processed
  60481. */
  60482. task: AbstractAssetTask;
  60483. /**
  60484. * Creates a AssetsProgressEvent
  60485. * @param remainingCount defines the number of remaining tasks to process
  60486. * @param totalCount defines the total number of tasks
  60487. * @param task defines the task that was just processed
  60488. */
  60489. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60490. }
  60491. /**
  60492. * Define a task used by AssetsManager to load meshes
  60493. */
  60494. export class MeshAssetTask extends AbstractAssetTask {
  60495. /**
  60496. * Defines the name of the task
  60497. */
  60498. name: string;
  60499. /**
  60500. * Defines the list of mesh's names you want to load
  60501. */
  60502. meshesNames: any;
  60503. /**
  60504. * Defines the root url to use as a base to load your meshes and associated resources
  60505. */
  60506. rootUrl: string;
  60507. /**
  60508. * Defines the filename of the scene to load from
  60509. */
  60510. sceneFilename: string;
  60511. /**
  60512. * Gets the list of loaded meshes
  60513. */
  60514. loadedMeshes: Array<AbstractMesh>;
  60515. /**
  60516. * Gets the list of loaded particle systems
  60517. */
  60518. loadedParticleSystems: Array<IParticleSystem>;
  60519. /**
  60520. * Gets the list of loaded skeletons
  60521. */
  60522. loadedSkeletons: Array<Skeleton>;
  60523. /**
  60524. * Gets the list of loaded animation groups
  60525. */
  60526. loadedAnimationGroups: Array<AnimationGroup>;
  60527. /**
  60528. * Callback called when the task is successful
  60529. */
  60530. onSuccess: (task: MeshAssetTask) => void;
  60531. /**
  60532. * Callback called when the task is successful
  60533. */
  60534. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60535. /**
  60536. * Creates a new MeshAssetTask
  60537. * @param name defines the name of the task
  60538. * @param meshesNames defines the list of mesh's names you want to load
  60539. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60540. * @param sceneFilename defines the filename of the scene to load from
  60541. */
  60542. constructor(
  60543. /**
  60544. * Defines the name of the task
  60545. */
  60546. name: string,
  60547. /**
  60548. * Defines the list of mesh's names you want to load
  60549. */
  60550. meshesNames: any,
  60551. /**
  60552. * Defines the root url to use as a base to load your meshes and associated resources
  60553. */
  60554. rootUrl: string,
  60555. /**
  60556. * Defines the filename of the scene to load from
  60557. */
  60558. sceneFilename: string);
  60559. /**
  60560. * Execute the current task
  60561. * @param scene defines the scene where you want your assets to be loaded
  60562. * @param onSuccess is a callback called when the task is successfully executed
  60563. * @param onError is a callback called if an error occurs
  60564. */
  60565. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60566. }
  60567. /**
  60568. * Define a task used by AssetsManager to load text content
  60569. */
  60570. export class TextFileAssetTask extends AbstractAssetTask {
  60571. /**
  60572. * Defines the name of the task
  60573. */
  60574. name: string;
  60575. /**
  60576. * Defines the location of the file to load
  60577. */
  60578. url: string;
  60579. /**
  60580. * Gets the loaded text string
  60581. */
  60582. text: string;
  60583. /**
  60584. * Callback called when the task is successful
  60585. */
  60586. onSuccess: (task: TextFileAssetTask) => void;
  60587. /**
  60588. * Callback called when the task is successful
  60589. */
  60590. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60591. /**
  60592. * Creates a new TextFileAssetTask object
  60593. * @param name defines the name of the task
  60594. * @param url defines the location of the file to load
  60595. */
  60596. constructor(
  60597. /**
  60598. * Defines the name of the task
  60599. */
  60600. name: string,
  60601. /**
  60602. * Defines the location of the file to load
  60603. */
  60604. url: string);
  60605. /**
  60606. * Execute the current task
  60607. * @param scene defines the scene where you want your assets to be loaded
  60608. * @param onSuccess is a callback called when the task is successfully executed
  60609. * @param onError is a callback called if an error occurs
  60610. */
  60611. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60612. }
  60613. /**
  60614. * Define a task used by AssetsManager to load binary data
  60615. */
  60616. export class BinaryFileAssetTask extends AbstractAssetTask {
  60617. /**
  60618. * Defines the name of the task
  60619. */
  60620. name: string;
  60621. /**
  60622. * Defines the location of the file to load
  60623. */
  60624. url: string;
  60625. /**
  60626. * Gets the lodaded data (as an array buffer)
  60627. */
  60628. data: ArrayBuffer;
  60629. /**
  60630. * Callback called when the task is successful
  60631. */
  60632. onSuccess: (task: BinaryFileAssetTask) => void;
  60633. /**
  60634. * Callback called when the task is successful
  60635. */
  60636. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60637. /**
  60638. * Creates a new BinaryFileAssetTask object
  60639. * @param name defines the name of the new task
  60640. * @param url defines the location of the file to load
  60641. */
  60642. constructor(
  60643. /**
  60644. * Defines the name of the task
  60645. */
  60646. name: string,
  60647. /**
  60648. * Defines the location of the file to load
  60649. */
  60650. url: string);
  60651. /**
  60652. * Execute the current task
  60653. * @param scene defines the scene where you want your assets to be loaded
  60654. * @param onSuccess is a callback called when the task is successfully executed
  60655. * @param onError is a callback called if an error occurs
  60656. */
  60657. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60658. }
  60659. /**
  60660. * Define a task used by AssetsManager to load images
  60661. */
  60662. export class ImageAssetTask extends AbstractAssetTask {
  60663. /**
  60664. * Defines the name of the task
  60665. */
  60666. name: string;
  60667. /**
  60668. * Defines the location of the image to load
  60669. */
  60670. url: string;
  60671. /**
  60672. * Gets the loaded images
  60673. */
  60674. image: HTMLImageElement;
  60675. /**
  60676. * Callback called when the task is successful
  60677. */
  60678. onSuccess: (task: ImageAssetTask) => void;
  60679. /**
  60680. * Callback called when the task is successful
  60681. */
  60682. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60683. /**
  60684. * Creates a new ImageAssetTask
  60685. * @param name defines the name of the task
  60686. * @param url defines the location of the image to load
  60687. */
  60688. constructor(
  60689. /**
  60690. * Defines the name of the task
  60691. */
  60692. name: string,
  60693. /**
  60694. * Defines the location of the image to load
  60695. */
  60696. url: string);
  60697. /**
  60698. * Execute the current task
  60699. * @param scene defines the scene where you want your assets to be loaded
  60700. * @param onSuccess is a callback called when the task is successfully executed
  60701. * @param onError is a callback called if an error occurs
  60702. */
  60703. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60704. }
  60705. /**
  60706. * Defines the interface used by texture loading tasks
  60707. */
  60708. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60709. /**
  60710. * Gets the loaded texture
  60711. */
  60712. texture: TEX;
  60713. }
  60714. /**
  60715. * Define a task used by AssetsManager to load 2D textures
  60716. */
  60717. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60718. /**
  60719. * Defines the name of the task
  60720. */
  60721. name: string;
  60722. /**
  60723. * Defines the location of the file to load
  60724. */
  60725. url: string;
  60726. /**
  60727. * Defines if mipmap should not be generated (default is false)
  60728. */
  60729. noMipmap?: boolean | undefined;
  60730. /**
  60731. * Defines if texture must be inverted on Y axis (default is false)
  60732. */
  60733. invertY?: boolean | undefined;
  60734. /**
  60735. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60736. */
  60737. samplingMode: number;
  60738. /**
  60739. * Gets the loaded texture
  60740. */
  60741. texture: Texture;
  60742. /**
  60743. * Callback called when the task is successful
  60744. */
  60745. onSuccess: (task: TextureAssetTask) => void;
  60746. /**
  60747. * Callback called when the task is successful
  60748. */
  60749. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60750. /**
  60751. * Creates a new TextureAssetTask object
  60752. * @param name defines the name of the task
  60753. * @param url defines the location of the file to load
  60754. * @param noMipmap defines if mipmap should not be generated (default is false)
  60755. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60756. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60757. */
  60758. constructor(
  60759. /**
  60760. * Defines the name of the task
  60761. */
  60762. name: string,
  60763. /**
  60764. * Defines the location of the file to load
  60765. */
  60766. url: string,
  60767. /**
  60768. * Defines if mipmap should not be generated (default is false)
  60769. */
  60770. noMipmap?: boolean | undefined,
  60771. /**
  60772. * Defines if texture must be inverted on Y axis (default is false)
  60773. */
  60774. invertY?: boolean | undefined,
  60775. /**
  60776. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60777. */
  60778. samplingMode?: number);
  60779. /**
  60780. * Execute the current task
  60781. * @param scene defines the scene where you want your assets to be loaded
  60782. * @param onSuccess is a callback called when the task is successfully executed
  60783. * @param onError is a callback called if an error occurs
  60784. */
  60785. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60786. }
  60787. /**
  60788. * Define a task used by AssetsManager to load cube textures
  60789. */
  60790. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60791. /**
  60792. * Defines the name of the task
  60793. */
  60794. name: string;
  60795. /**
  60796. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60797. */
  60798. url: string;
  60799. /**
  60800. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60801. */
  60802. extensions?: string[] | undefined;
  60803. /**
  60804. * Defines if mipmaps should not be generated (default is false)
  60805. */
  60806. noMipmap?: boolean | undefined;
  60807. /**
  60808. * Defines the explicit list of files (undefined by default)
  60809. */
  60810. files?: string[] | undefined;
  60811. /**
  60812. * Gets the loaded texture
  60813. */
  60814. texture: CubeTexture;
  60815. /**
  60816. * Callback called when the task is successful
  60817. */
  60818. onSuccess: (task: CubeTextureAssetTask) => void;
  60819. /**
  60820. * Callback called when the task is successful
  60821. */
  60822. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60823. /**
  60824. * Creates a new CubeTextureAssetTask
  60825. * @param name defines the name of the task
  60826. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60827. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60828. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60829. * @param files defines the explicit list of files (undefined by default)
  60830. */
  60831. constructor(
  60832. /**
  60833. * Defines the name of the task
  60834. */
  60835. name: string,
  60836. /**
  60837. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60838. */
  60839. url: string,
  60840. /**
  60841. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60842. */
  60843. extensions?: string[] | undefined,
  60844. /**
  60845. * Defines if mipmaps should not be generated (default is false)
  60846. */
  60847. noMipmap?: boolean | undefined,
  60848. /**
  60849. * Defines the explicit list of files (undefined by default)
  60850. */
  60851. files?: string[] | undefined);
  60852. /**
  60853. * Execute the current task
  60854. * @param scene defines the scene where you want your assets to be loaded
  60855. * @param onSuccess is a callback called when the task is successfully executed
  60856. * @param onError is a callback called if an error occurs
  60857. */
  60858. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60859. }
  60860. /**
  60861. * Define a task used by AssetsManager to load HDR cube textures
  60862. */
  60863. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60864. /**
  60865. * Defines the name of the task
  60866. */
  60867. name: string;
  60868. /**
  60869. * Defines the location of the file to load
  60870. */
  60871. url: string;
  60872. /**
  60873. * Defines the desired size (the more it increases the longer the generation will be)
  60874. */
  60875. size: number;
  60876. /**
  60877. * Defines if mipmaps should not be generated (default is false)
  60878. */
  60879. noMipmap: boolean;
  60880. /**
  60881. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60882. */
  60883. generateHarmonics: boolean;
  60884. /**
  60885. * 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)
  60886. */
  60887. gammaSpace: boolean;
  60888. /**
  60889. * Internal Use Only
  60890. */
  60891. reserved: boolean;
  60892. /**
  60893. * Gets the loaded texture
  60894. */
  60895. texture: HDRCubeTexture;
  60896. /**
  60897. * Callback called when the task is successful
  60898. */
  60899. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60900. /**
  60901. * Callback called when the task is successful
  60902. */
  60903. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60904. /**
  60905. * Creates a new HDRCubeTextureAssetTask object
  60906. * @param name defines the name of the task
  60907. * @param url defines the location of the file to load
  60908. * @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.
  60909. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60910. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60911. * @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)
  60912. * @param reserved Internal use only
  60913. */
  60914. constructor(
  60915. /**
  60916. * Defines the name of the task
  60917. */
  60918. name: string,
  60919. /**
  60920. * Defines the location of the file to load
  60921. */
  60922. url: string,
  60923. /**
  60924. * Defines the desired size (the more it increases the longer the generation will be)
  60925. */
  60926. size: number,
  60927. /**
  60928. * Defines if mipmaps should not be generated (default is false)
  60929. */
  60930. noMipmap?: boolean,
  60931. /**
  60932. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60933. */
  60934. generateHarmonics?: boolean,
  60935. /**
  60936. * 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)
  60937. */
  60938. gammaSpace?: boolean,
  60939. /**
  60940. * Internal Use Only
  60941. */
  60942. reserved?: boolean);
  60943. /**
  60944. * Execute the current task
  60945. * @param scene defines the scene where you want your assets to be loaded
  60946. * @param onSuccess is a callback called when the task is successfully executed
  60947. * @param onError is a callback called if an error occurs
  60948. */
  60949. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60950. }
  60951. /**
  60952. * Define a task used by AssetsManager to load Equirectangular cube textures
  60953. */
  60954. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60955. /**
  60956. * Defines the name of the task
  60957. */
  60958. name: string;
  60959. /**
  60960. * Defines the location of the file to load
  60961. */
  60962. url: string;
  60963. /**
  60964. * Defines the desired size (the more it increases the longer the generation will be)
  60965. */
  60966. size: number;
  60967. /**
  60968. * Defines if mipmaps should not be generated (default is false)
  60969. */
  60970. noMipmap: boolean;
  60971. /**
  60972. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60973. * but the standard material would require them in Gamma space) (default is true)
  60974. */
  60975. gammaSpace: boolean;
  60976. /**
  60977. * Gets the loaded texture
  60978. */
  60979. texture: EquiRectangularCubeTexture;
  60980. /**
  60981. * Callback called when the task is successful
  60982. */
  60983. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60984. /**
  60985. * Callback called when the task is successful
  60986. */
  60987. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60988. /**
  60989. * Creates a new EquiRectangularCubeTextureAssetTask object
  60990. * @param name defines the name of the task
  60991. * @param url defines the location of the file to load
  60992. * @param size defines the desired size (the more it increases the longer the generation will be)
  60993. * If the size is omitted this implies you are using a preprocessed cubemap.
  60994. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60995. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60996. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60997. * (default is true)
  60998. */
  60999. constructor(
  61000. /**
  61001. * Defines the name of the task
  61002. */
  61003. name: string,
  61004. /**
  61005. * Defines the location of the file to load
  61006. */
  61007. url: string,
  61008. /**
  61009. * Defines the desired size (the more it increases the longer the generation will be)
  61010. */
  61011. size: number,
  61012. /**
  61013. * Defines if mipmaps should not be generated (default is false)
  61014. */
  61015. noMipmap?: boolean,
  61016. /**
  61017. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61018. * but the standard material would require them in Gamma space) (default is true)
  61019. */
  61020. gammaSpace?: boolean);
  61021. /**
  61022. * Execute the current task
  61023. * @param scene defines the scene where you want your assets to be loaded
  61024. * @param onSuccess is a callback called when the task is successfully executed
  61025. * @param onError is a callback called if an error occurs
  61026. */
  61027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61028. }
  61029. /**
  61030. * This class can be used to easily import assets into a scene
  61031. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61032. */
  61033. export class AssetsManager {
  61034. private _scene;
  61035. private _isLoading;
  61036. protected _tasks: AbstractAssetTask[];
  61037. protected _waitingTasksCount: number;
  61038. protected _totalTasksCount: number;
  61039. /**
  61040. * Callback called when all tasks are processed
  61041. */
  61042. onFinish: (tasks: AbstractAssetTask[]) => void;
  61043. /**
  61044. * Callback called when a task is successful
  61045. */
  61046. onTaskSuccess: (task: AbstractAssetTask) => void;
  61047. /**
  61048. * Callback called when a task had an error
  61049. */
  61050. onTaskError: (task: AbstractAssetTask) => void;
  61051. /**
  61052. * Callback called when a task is done (whatever the result is)
  61053. */
  61054. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61055. /**
  61056. * Observable called when all tasks are processed
  61057. */
  61058. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61059. /**
  61060. * Observable called when a task had an error
  61061. */
  61062. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61063. /**
  61064. * Observable called when all tasks were executed
  61065. */
  61066. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61067. /**
  61068. * Observable called when a task is done (whatever the result is)
  61069. */
  61070. onProgressObservable: Observable<IAssetsProgressEvent>;
  61071. /**
  61072. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61073. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61074. */
  61075. useDefaultLoadingScreen: boolean;
  61076. /**
  61077. * Creates a new AssetsManager
  61078. * @param scene defines the scene to work on
  61079. */
  61080. constructor(scene: Scene);
  61081. /**
  61082. * Add a MeshAssetTask to the list of active tasks
  61083. * @param taskName defines the name of the new task
  61084. * @param meshesNames defines the name of meshes to load
  61085. * @param rootUrl defines the root url to use to locate files
  61086. * @param sceneFilename defines the filename of the scene file
  61087. * @returns a new MeshAssetTask object
  61088. */
  61089. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61090. /**
  61091. * Add a TextFileAssetTask to the list of active tasks
  61092. * @param taskName defines the name of the new task
  61093. * @param url defines the url of the file to load
  61094. * @returns a new TextFileAssetTask object
  61095. */
  61096. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61097. /**
  61098. * Add a BinaryFileAssetTask to the list of active tasks
  61099. * @param taskName defines the name of the new task
  61100. * @param url defines the url of the file to load
  61101. * @returns a new BinaryFileAssetTask object
  61102. */
  61103. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61104. /**
  61105. * Add a ImageAssetTask to the list of active tasks
  61106. * @param taskName defines the name of the new task
  61107. * @param url defines the url of the file to load
  61108. * @returns a new ImageAssetTask object
  61109. */
  61110. addImageTask(taskName: string, url: string): ImageAssetTask;
  61111. /**
  61112. * Add a TextureAssetTask to the list of active tasks
  61113. * @param taskName defines the name of the new task
  61114. * @param url defines the url of the file to load
  61115. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61116. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61117. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61118. * @returns a new TextureAssetTask object
  61119. */
  61120. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61121. /**
  61122. * Add a CubeTextureAssetTask to the list of active tasks
  61123. * @param taskName defines the name of the new task
  61124. * @param url defines the url of the file to load
  61125. * @param extensions defines the extension to use to load the cube map (can be null)
  61126. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61127. * @param files defines the list of files to load (can be null)
  61128. * @returns a new CubeTextureAssetTask object
  61129. */
  61130. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61131. /**
  61132. *
  61133. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61134. * @param taskName defines the name of the new task
  61135. * @param url defines the url of the file to load
  61136. * @param size defines the size you want for the cubemap (can be null)
  61137. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61138. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61139. * @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)
  61140. * @param reserved Internal use only
  61141. * @returns a new HDRCubeTextureAssetTask object
  61142. */
  61143. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61144. /**
  61145. *
  61146. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61147. * @param taskName defines the name of the new task
  61148. * @param url defines the url of the file to load
  61149. * @param size defines the size you want for the cubemap (can be null)
  61150. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61151. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61152. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61153. * @returns a new EquiRectangularCubeTextureAssetTask object
  61154. */
  61155. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61156. /**
  61157. * Remove a task from the assets manager.
  61158. * @param task the task to remove
  61159. */
  61160. removeTask(task: AbstractAssetTask): void;
  61161. private _decreaseWaitingTasksCount;
  61162. private _runTask;
  61163. /**
  61164. * Reset the AssetsManager and remove all tasks
  61165. * @return the current instance of the AssetsManager
  61166. */
  61167. reset(): AssetsManager;
  61168. /**
  61169. * Start the loading process
  61170. * @return the current instance of the AssetsManager
  61171. */
  61172. load(): AssetsManager;
  61173. /**
  61174. * Start the loading process as an async operation
  61175. * @return a promise returning the list of failed tasks
  61176. */
  61177. loadAsync(): Promise<void>;
  61178. }
  61179. }
  61180. declare module "babylonjs/Misc/deferred" {
  61181. /**
  61182. * Wrapper class for promise with external resolve and reject.
  61183. */
  61184. export class Deferred<T> {
  61185. /**
  61186. * The promise associated with this deferred object.
  61187. */
  61188. readonly promise: Promise<T>;
  61189. private _resolve;
  61190. private _reject;
  61191. /**
  61192. * The resolve method of the promise associated with this deferred object.
  61193. */
  61194. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61195. /**
  61196. * The reject method of the promise associated with this deferred object.
  61197. */
  61198. readonly reject: (reason?: any) => void;
  61199. /**
  61200. * Constructor for this deferred object.
  61201. */
  61202. constructor();
  61203. }
  61204. }
  61205. declare module "babylonjs/Misc/meshExploder" {
  61206. import { Mesh } from "babylonjs/Meshes/mesh";
  61207. /**
  61208. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61209. */
  61210. export class MeshExploder {
  61211. private _centerMesh;
  61212. private _meshes;
  61213. private _meshesOrigins;
  61214. private _toCenterVectors;
  61215. private _scaledDirection;
  61216. private _newPosition;
  61217. private _centerPosition;
  61218. /**
  61219. * Explodes meshes from a center mesh.
  61220. * @param meshes The meshes to explode.
  61221. * @param centerMesh The mesh to be center of explosion.
  61222. */
  61223. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61224. private _setCenterMesh;
  61225. /**
  61226. * Get class name
  61227. * @returns "MeshExploder"
  61228. */
  61229. getClassName(): string;
  61230. /**
  61231. * "Exploded meshes"
  61232. * @returns Array of meshes with the centerMesh at index 0.
  61233. */
  61234. getMeshes(): Array<Mesh>;
  61235. /**
  61236. * Explodes meshes giving a specific direction
  61237. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61238. */
  61239. explode(direction?: number): void;
  61240. }
  61241. }
  61242. declare module "babylonjs/Misc/filesInput" {
  61243. import { Engine } from "babylonjs/Engines/engine";
  61244. import { Scene } from "babylonjs/scene";
  61245. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61246. /**
  61247. * Class used to help managing file picking and drag'n'drop
  61248. */
  61249. export class FilesInput {
  61250. /**
  61251. * List of files ready to be loaded
  61252. */
  61253. static readonly FilesToLoad: {
  61254. [key: string]: File;
  61255. };
  61256. /**
  61257. * Callback called when a file is processed
  61258. */
  61259. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61260. private _engine;
  61261. private _currentScene;
  61262. private _sceneLoadedCallback;
  61263. private _progressCallback;
  61264. private _additionalRenderLoopLogicCallback;
  61265. private _textureLoadingCallback;
  61266. private _startingProcessingFilesCallback;
  61267. private _onReloadCallback;
  61268. private _errorCallback;
  61269. private _elementToMonitor;
  61270. private _sceneFileToLoad;
  61271. private _filesToLoad;
  61272. /**
  61273. * Creates a new FilesInput
  61274. * @param engine defines the rendering engine
  61275. * @param scene defines the hosting scene
  61276. * @param sceneLoadedCallback callback called when scene is loaded
  61277. * @param progressCallback callback called to track progress
  61278. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61279. * @param textureLoadingCallback callback called when a texture is loading
  61280. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61281. * @param onReloadCallback callback called when a reload is requested
  61282. * @param errorCallback callback call if an error occurs
  61283. */
  61284. 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);
  61285. private _dragEnterHandler;
  61286. private _dragOverHandler;
  61287. private _dropHandler;
  61288. /**
  61289. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61290. * @param elementToMonitor defines the DOM element to track
  61291. */
  61292. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61293. /**
  61294. * Release all associated resources
  61295. */
  61296. dispose(): void;
  61297. private renderFunction;
  61298. private drag;
  61299. private drop;
  61300. private _traverseFolder;
  61301. private _processFiles;
  61302. /**
  61303. * Load files from a drop event
  61304. * @param event defines the drop event to use as source
  61305. */
  61306. loadFiles(event: any): void;
  61307. private _processReload;
  61308. /**
  61309. * Reload the current scene from the loaded files
  61310. */
  61311. reload(): void;
  61312. }
  61313. }
  61314. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61315. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61316. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61317. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61318. }
  61319. declare module "babylonjs/Misc/sceneOptimizer" {
  61320. import { Scene, IDisposable } from "babylonjs/scene";
  61321. import { Observable } from "babylonjs/Misc/observable";
  61322. /**
  61323. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61325. */
  61326. export class SceneOptimization {
  61327. /**
  61328. * Defines the priority of this optimization (0 by default which means first in the list)
  61329. */
  61330. priority: number;
  61331. /**
  61332. * Gets a string describing the action executed by the current optimization
  61333. * @returns description string
  61334. */
  61335. getDescription(): string;
  61336. /**
  61337. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61338. * @param scene defines the current scene where to apply this optimization
  61339. * @param optimizer defines the current optimizer
  61340. * @returns true if everything that can be done was applied
  61341. */
  61342. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61343. /**
  61344. * Creates the SceneOptimization object
  61345. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61346. * @param desc defines the description associated with the optimization
  61347. */
  61348. constructor(
  61349. /**
  61350. * Defines the priority of this optimization (0 by default which means first in the list)
  61351. */
  61352. priority?: number);
  61353. }
  61354. /**
  61355. * Defines an optimization used to reduce the size of render target textures
  61356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61357. */
  61358. export class TextureOptimization extends SceneOptimization {
  61359. /**
  61360. * Defines the priority of this optimization (0 by default which means first in the list)
  61361. */
  61362. priority: number;
  61363. /**
  61364. * 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
  61365. */
  61366. maximumSize: number;
  61367. /**
  61368. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61369. */
  61370. step: number;
  61371. /**
  61372. * Gets a string describing the action executed by the current optimization
  61373. * @returns description string
  61374. */
  61375. getDescription(): string;
  61376. /**
  61377. * Creates the TextureOptimization object
  61378. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61379. * @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
  61380. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61381. */
  61382. constructor(
  61383. /**
  61384. * Defines the priority of this optimization (0 by default which means first in the list)
  61385. */
  61386. priority?: number,
  61387. /**
  61388. * 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
  61389. */
  61390. maximumSize?: number,
  61391. /**
  61392. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61393. */
  61394. step?: number);
  61395. /**
  61396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61397. * @param scene defines the current scene where to apply this optimization
  61398. * @param optimizer defines the current optimizer
  61399. * @returns true if everything that can be done was applied
  61400. */
  61401. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61402. }
  61403. /**
  61404. * Defines an optimization used to increase or decrease the rendering resolution
  61405. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61406. */
  61407. export class HardwareScalingOptimization extends SceneOptimization {
  61408. /**
  61409. * Defines the priority of this optimization (0 by default which means first in the list)
  61410. */
  61411. priority: number;
  61412. /**
  61413. * Defines the maximum scale to use (2 by default)
  61414. */
  61415. maximumScale: number;
  61416. /**
  61417. * Defines the step to use between two passes (0.5 by default)
  61418. */
  61419. step: number;
  61420. private _currentScale;
  61421. private _directionOffset;
  61422. /**
  61423. * Gets a string describing the action executed by the current optimization
  61424. * @return description string
  61425. */
  61426. getDescription(): string;
  61427. /**
  61428. * Creates the HardwareScalingOptimization object
  61429. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61430. * @param maximumScale defines the maximum scale to use (2 by default)
  61431. * @param step defines the step to use between two passes (0.5 by default)
  61432. */
  61433. constructor(
  61434. /**
  61435. * Defines the priority of this optimization (0 by default which means first in the list)
  61436. */
  61437. priority?: number,
  61438. /**
  61439. * Defines the maximum scale to use (2 by default)
  61440. */
  61441. maximumScale?: number,
  61442. /**
  61443. * Defines the step to use between two passes (0.5 by default)
  61444. */
  61445. step?: number);
  61446. /**
  61447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61448. * @param scene defines the current scene where to apply this optimization
  61449. * @param optimizer defines the current optimizer
  61450. * @returns true if everything that can be done was applied
  61451. */
  61452. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61453. }
  61454. /**
  61455. * Defines an optimization used to remove shadows
  61456. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61457. */
  61458. export class ShadowsOptimization extends SceneOptimization {
  61459. /**
  61460. * Gets a string describing the action executed by the current optimization
  61461. * @return description string
  61462. */
  61463. getDescription(): string;
  61464. /**
  61465. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61466. * @param scene defines the current scene where to apply this optimization
  61467. * @param optimizer defines the current optimizer
  61468. * @returns true if everything that can be done was applied
  61469. */
  61470. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61471. }
  61472. /**
  61473. * Defines an optimization used to turn post-processes off
  61474. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61475. */
  61476. export class PostProcessesOptimization extends SceneOptimization {
  61477. /**
  61478. * Gets a string describing the action executed by the current optimization
  61479. * @return description string
  61480. */
  61481. getDescription(): string;
  61482. /**
  61483. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61484. * @param scene defines the current scene where to apply this optimization
  61485. * @param optimizer defines the current optimizer
  61486. * @returns true if everything that can be done was applied
  61487. */
  61488. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61489. }
  61490. /**
  61491. * Defines an optimization used to turn lens flares off
  61492. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61493. */
  61494. export class LensFlaresOptimization extends SceneOptimization {
  61495. /**
  61496. * Gets a string describing the action executed by the current optimization
  61497. * @return description string
  61498. */
  61499. getDescription(): string;
  61500. /**
  61501. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61502. * @param scene defines the current scene where to apply this optimization
  61503. * @param optimizer defines the current optimizer
  61504. * @returns true if everything that can be done was applied
  61505. */
  61506. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61507. }
  61508. /**
  61509. * Defines an optimization based on user defined callback.
  61510. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61511. */
  61512. export class CustomOptimization extends SceneOptimization {
  61513. /**
  61514. * Callback called to apply the custom optimization.
  61515. */
  61516. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61517. /**
  61518. * Callback called to get custom description
  61519. */
  61520. onGetDescription: () => string;
  61521. /**
  61522. * Gets a string describing the action executed by the current optimization
  61523. * @returns description string
  61524. */
  61525. getDescription(): string;
  61526. /**
  61527. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61528. * @param scene defines the current scene where to apply this optimization
  61529. * @param optimizer defines the current optimizer
  61530. * @returns true if everything that can be done was applied
  61531. */
  61532. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61533. }
  61534. /**
  61535. * Defines an optimization used to turn particles off
  61536. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61537. */
  61538. export class ParticlesOptimization extends SceneOptimization {
  61539. /**
  61540. * Gets a string describing the action executed by the current optimization
  61541. * @return description string
  61542. */
  61543. getDescription(): string;
  61544. /**
  61545. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61546. * @param scene defines the current scene where to apply this optimization
  61547. * @param optimizer defines the current optimizer
  61548. * @returns true if everything that can be done was applied
  61549. */
  61550. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61551. }
  61552. /**
  61553. * Defines an optimization used to turn render targets off
  61554. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61555. */
  61556. export class RenderTargetsOptimization extends SceneOptimization {
  61557. /**
  61558. * Gets a string describing the action executed by the current optimization
  61559. * @return description string
  61560. */
  61561. getDescription(): string;
  61562. /**
  61563. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61564. * @param scene defines the current scene where to apply this optimization
  61565. * @param optimizer defines the current optimizer
  61566. * @returns true if everything that can be done was applied
  61567. */
  61568. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61569. }
  61570. /**
  61571. * Defines an optimization used to merge meshes with compatible materials
  61572. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61573. */
  61574. export class MergeMeshesOptimization extends SceneOptimization {
  61575. private static _UpdateSelectionTree;
  61576. /**
  61577. * Gets or sets a boolean which defines if optimization octree has to be updated
  61578. */
  61579. /**
  61580. * Gets or sets a boolean which defines if optimization octree has to be updated
  61581. */
  61582. static UpdateSelectionTree: boolean;
  61583. /**
  61584. * Gets a string describing the action executed by the current optimization
  61585. * @return description string
  61586. */
  61587. getDescription(): string;
  61588. private _canBeMerged;
  61589. /**
  61590. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61591. * @param scene defines the current scene where to apply this optimization
  61592. * @param optimizer defines the current optimizer
  61593. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61594. * @returns true if everything that can be done was applied
  61595. */
  61596. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61597. }
  61598. /**
  61599. * Defines a list of options used by SceneOptimizer
  61600. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61601. */
  61602. export class SceneOptimizerOptions {
  61603. /**
  61604. * Defines the target frame rate to reach (60 by default)
  61605. */
  61606. targetFrameRate: number;
  61607. /**
  61608. * Defines the interval between two checkes (2000ms by default)
  61609. */
  61610. trackerDuration: number;
  61611. /**
  61612. * Gets the list of optimizations to apply
  61613. */
  61614. optimizations: SceneOptimization[];
  61615. /**
  61616. * Creates a new list of options used by SceneOptimizer
  61617. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61618. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61619. */
  61620. constructor(
  61621. /**
  61622. * Defines the target frame rate to reach (60 by default)
  61623. */
  61624. targetFrameRate?: number,
  61625. /**
  61626. * Defines the interval between two checkes (2000ms by default)
  61627. */
  61628. trackerDuration?: number);
  61629. /**
  61630. * Add a new optimization
  61631. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61632. * @returns the current SceneOptimizerOptions
  61633. */
  61634. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61635. /**
  61636. * Add a new custom optimization
  61637. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61638. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61639. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61640. * @returns the current SceneOptimizerOptions
  61641. */
  61642. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61643. /**
  61644. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61645. * @param targetFrameRate defines the target frame rate (60 by default)
  61646. * @returns a SceneOptimizerOptions object
  61647. */
  61648. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61649. /**
  61650. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61651. * @param targetFrameRate defines the target frame rate (60 by default)
  61652. * @returns a SceneOptimizerOptions object
  61653. */
  61654. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61655. /**
  61656. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61657. * @param targetFrameRate defines the target frame rate (60 by default)
  61658. * @returns a SceneOptimizerOptions object
  61659. */
  61660. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61661. }
  61662. /**
  61663. * Class used to run optimizations in order to reach a target frame rate
  61664. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61665. */
  61666. export class SceneOptimizer implements IDisposable {
  61667. private _isRunning;
  61668. private _options;
  61669. private _scene;
  61670. private _currentPriorityLevel;
  61671. private _targetFrameRate;
  61672. private _trackerDuration;
  61673. private _currentFrameRate;
  61674. private _sceneDisposeObserver;
  61675. private _improvementMode;
  61676. /**
  61677. * Defines an observable called when the optimizer reaches the target frame rate
  61678. */
  61679. onSuccessObservable: Observable<SceneOptimizer>;
  61680. /**
  61681. * Defines an observable called when the optimizer enables an optimization
  61682. */
  61683. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61684. /**
  61685. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61686. */
  61687. onFailureObservable: Observable<SceneOptimizer>;
  61688. /**
  61689. * Gets a boolean indicating if the optimizer is in improvement mode
  61690. */
  61691. readonly isInImprovementMode: boolean;
  61692. /**
  61693. * Gets the current priority level (0 at start)
  61694. */
  61695. readonly currentPriorityLevel: number;
  61696. /**
  61697. * Gets the current frame rate checked by the SceneOptimizer
  61698. */
  61699. readonly currentFrameRate: number;
  61700. /**
  61701. * Gets or sets the current target frame rate (60 by default)
  61702. */
  61703. /**
  61704. * Gets or sets the current target frame rate (60 by default)
  61705. */
  61706. targetFrameRate: number;
  61707. /**
  61708. * Gets or sets the current interval between two checks (every 2000ms by default)
  61709. */
  61710. /**
  61711. * Gets or sets the current interval between two checks (every 2000ms by default)
  61712. */
  61713. trackerDuration: number;
  61714. /**
  61715. * Gets the list of active optimizations
  61716. */
  61717. readonly optimizations: SceneOptimization[];
  61718. /**
  61719. * Creates a new SceneOptimizer
  61720. * @param scene defines the scene to work on
  61721. * @param options defines the options to use with the SceneOptimizer
  61722. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61723. * @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)
  61724. */
  61725. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61726. /**
  61727. * Stops the current optimizer
  61728. */
  61729. stop(): void;
  61730. /**
  61731. * Reset the optimizer to initial step (current priority level = 0)
  61732. */
  61733. reset(): void;
  61734. /**
  61735. * Start the optimizer. By default it will try to reach a specific framerate
  61736. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61737. */
  61738. start(): void;
  61739. private _checkCurrentState;
  61740. /**
  61741. * Release all resources
  61742. */
  61743. dispose(): void;
  61744. /**
  61745. * Helper function to create a SceneOptimizer with one single line of code
  61746. * @param scene defines the scene to work on
  61747. * @param options defines the options to use with the SceneOptimizer
  61748. * @param onSuccess defines a callback to call on success
  61749. * @param onFailure defines a callback to call on failure
  61750. * @returns the new SceneOptimizer object
  61751. */
  61752. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61753. }
  61754. }
  61755. declare module "babylonjs/Misc/sceneSerializer" {
  61756. import { Scene } from "babylonjs/scene";
  61757. /**
  61758. * Class used to serialize a scene into a string
  61759. */
  61760. export class SceneSerializer {
  61761. /**
  61762. * Clear cache used by a previous serialization
  61763. */
  61764. static ClearCache(): void;
  61765. /**
  61766. * Serialize a scene into a JSON compatible object
  61767. * @param scene defines the scene to serialize
  61768. * @returns a JSON compatible object
  61769. */
  61770. static Serialize(scene: Scene): any;
  61771. /**
  61772. * Serialize a mesh into a JSON compatible object
  61773. * @param toSerialize defines the mesh to serialize
  61774. * @param withParents defines if parents must be serialized as well
  61775. * @param withChildren defines if children must be serialized as well
  61776. * @returns a JSON compatible object
  61777. */
  61778. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61779. }
  61780. }
  61781. declare module "babylonjs/Misc/textureTools" {
  61782. import { Texture } from "babylonjs/Materials/Textures/texture";
  61783. /**
  61784. * Class used to host texture specific utilities
  61785. */
  61786. export class TextureTools {
  61787. /**
  61788. * Uses the GPU to create a copy texture rescaled at a given size
  61789. * @param texture Texture to copy from
  61790. * @param width defines the desired width
  61791. * @param height defines the desired height
  61792. * @param useBilinearMode defines if bilinear mode has to be used
  61793. * @return the generated texture
  61794. */
  61795. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61796. }
  61797. }
  61798. declare module "babylonjs/Misc/videoRecorder" {
  61799. import { Nullable } from "babylonjs/types";
  61800. import { Engine } from "babylonjs/Engines/engine";
  61801. /**
  61802. * This represents the different options available for the video capture.
  61803. */
  61804. export interface VideoRecorderOptions {
  61805. /** Defines the mime type of the video. */
  61806. mimeType: string;
  61807. /** Defines the FPS the video should be recorded at. */
  61808. fps: number;
  61809. /** Defines the chunk size for the recording data. */
  61810. recordChunckSize: number;
  61811. /** The audio tracks to attach to the recording. */
  61812. audioTracks?: MediaStreamTrack[];
  61813. }
  61814. /**
  61815. * This can help with recording videos from BabylonJS.
  61816. * This is based on the available WebRTC functionalities of the browser.
  61817. *
  61818. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61819. */
  61820. export class VideoRecorder {
  61821. private static readonly _defaultOptions;
  61822. /**
  61823. * Returns whether or not the VideoRecorder is available in your browser.
  61824. * @param engine Defines the Babylon Engine.
  61825. * @returns true if supported otherwise false.
  61826. */
  61827. static IsSupported(engine: Engine): boolean;
  61828. private readonly _options;
  61829. private _canvas;
  61830. private _mediaRecorder;
  61831. private _recordedChunks;
  61832. private _fileName;
  61833. private _resolve;
  61834. private _reject;
  61835. /**
  61836. * True when a recording is already in progress.
  61837. */
  61838. readonly isRecording: boolean;
  61839. /**
  61840. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  61841. * @param engine Defines the BabylonJS Engine you wish to record.
  61842. * @param options Defines options that can be used to customize the capture.
  61843. */
  61844. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61845. /**
  61846. * Stops the current recording before the default capture timeout passed in the startRecording function.
  61847. */
  61848. stopRecording(): void;
  61849. /**
  61850. * Starts recording the canvas for a max duration specified in parameters.
  61851. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  61852. * If null no automatic download will start and you can rely on the promise to get the data back.
  61853. * @param maxDuration Defines the maximum recording time in seconds.
  61854. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61855. * @return A promise callback at the end of the recording with the video data in Blob.
  61856. */
  61857. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61858. /**
  61859. * Releases internal resources used during the recording.
  61860. */
  61861. dispose(): void;
  61862. private _handleDataAvailable;
  61863. private _handleError;
  61864. private _handleStop;
  61865. }
  61866. }
  61867. declare module "babylonjs/Misc/screenshotTools" {
  61868. import { Camera } from "babylonjs/Cameras/camera";
  61869. import { Engine } from "babylonjs/Engines/engine";
  61870. /**
  61871. * Class containing a set of static utilities functions for screenshots
  61872. */
  61873. export class ScreenshotTools {
  61874. /**
  61875. * Captures a screenshot of the current rendering
  61876. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61877. * @param engine defines the rendering engine
  61878. * @param camera defines the source camera
  61879. * @param size This parameter can be set to a single number or to an object with the
  61880. * following (optional) properties: precision, width, height. If a single number is passed,
  61881. * it will be used for both width and height. If an object is passed, the screenshot size
  61882. * will be derived from the parameters. The precision property is a multiplier allowing
  61883. * rendering at a higher or lower resolution
  61884. * @param successCallback defines the callback receives a single parameter which contains the
  61885. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61886. * src parameter of an <img> to display it
  61887. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61888. * Check your browser for supported MIME types
  61889. */
  61890. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  61891. /**
  61892. * Generates an image screenshot from the specified camera.
  61893. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61894. * @param engine The engine to use for rendering
  61895. * @param camera The camera to use for rendering
  61896. * @param size This parameter can be set to a single number or to an object with the
  61897. * following (optional) properties: precision, width, height. If a single number is passed,
  61898. * it will be used for both width and height. If an object is passed, the screenshot size
  61899. * will be derived from the parameters. The precision property is a multiplier allowing
  61900. * rendering at a higher or lower resolution
  61901. * @param successCallback The callback receives a single parameter which contains the
  61902. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61903. * src parameter of an <img> to display it
  61904. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61905. * Check your browser for supported MIME types
  61906. * @param samples Texture samples (default: 1)
  61907. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61908. * @param fileName A name for for the downloaded file.
  61909. */
  61910. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61911. }
  61912. }
  61913. declare module "babylonjs/Misc/index" {
  61914. export * from "babylonjs/Misc/andOrNotEvaluator";
  61915. export * from "babylonjs/Misc/assetsManager";
  61916. export * from "babylonjs/Misc/dds";
  61917. export * from "babylonjs/Misc/decorators";
  61918. export * from "babylonjs/Misc/deferred";
  61919. export * from "babylonjs/Misc/environmentTextureTools";
  61920. export * from "babylonjs/Misc/meshExploder";
  61921. export * from "babylonjs/Misc/filesInput";
  61922. export * from "babylonjs/Misc/HighDynamicRange/index";
  61923. export * from "babylonjs/Misc/khronosTextureContainer";
  61924. export * from "babylonjs/Misc/observable";
  61925. export * from "babylonjs/Misc/performanceMonitor";
  61926. export * from "babylonjs/Misc/promise";
  61927. export * from "babylonjs/Misc/sceneOptimizer";
  61928. export * from "babylonjs/Misc/sceneSerializer";
  61929. export * from "babylonjs/Misc/smartArray";
  61930. export * from "babylonjs/Misc/stringDictionary";
  61931. export * from "babylonjs/Misc/tags";
  61932. export * from "babylonjs/Misc/textureTools";
  61933. export * from "babylonjs/Misc/tga";
  61934. export * from "babylonjs/Misc/tools";
  61935. export * from "babylonjs/Misc/videoRecorder";
  61936. export * from "babylonjs/Misc/virtualJoystick";
  61937. export * from "babylonjs/Misc/workerPool";
  61938. export * from "babylonjs/Misc/logger";
  61939. export * from "babylonjs/Misc/typeStore";
  61940. export * from "babylonjs/Misc/filesInputStore";
  61941. export * from "babylonjs/Misc/deepCopier";
  61942. export * from "babylonjs/Misc/pivotTools";
  61943. export * from "babylonjs/Misc/precisionDate";
  61944. export * from "babylonjs/Misc/screenshotTools";
  61945. export * from "babylonjs/Misc/typeStore";
  61946. export * from "babylonjs/Misc/webRequest";
  61947. export * from "babylonjs/Misc/iInspectable";
  61948. export * from "babylonjs/Misc/brdfTextureTools";
  61949. }
  61950. declare module "babylonjs/index" {
  61951. export * from "babylonjs/abstractScene";
  61952. export * from "babylonjs/Actions/index";
  61953. export * from "babylonjs/Animations/index";
  61954. export * from "babylonjs/assetContainer";
  61955. export * from "babylonjs/Audio/index";
  61956. export * from "babylonjs/Behaviors/index";
  61957. export * from "babylonjs/Bones/index";
  61958. export * from "babylonjs/Cameras/index";
  61959. export * from "babylonjs/Collisions/index";
  61960. export * from "babylonjs/Culling/index";
  61961. export * from "babylonjs/Debug/index";
  61962. export * from "babylonjs/Engines/index";
  61963. export * from "babylonjs/Events/index";
  61964. export * from "babylonjs/Gamepads/index";
  61965. export * from "babylonjs/Gizmos/index";
  61966. export * from "babylonjs/Helpers/index";
  61967. export * from "babylonjs/Instrumentation/index";
  61968. export * from "babylonjs/Layers/index";
  61969. export * from "babylonjs/LensFlares/index";
  61970. export * from "babylonjs/Lights/index";
  61971. export * from "babylonjs/Loading/index";
  61972. export * from "babylonjs/Materials/index";
  61973. export * from "babylonjs/Maths/index";
  61974. export * from "babylonjs/Meshes/index";
  61975. export * from "babylonjs/Morph/index";
  61976. export * from "babylonjs/node";
  61977. export * from "babylonjs/Offline/index";
  61978. export * from "babylonjs/Particles/index";
  61979. export * from "babylonjs/Physics/index";
  61980. export * from "babylonjs/PostProcesses/index";
  61981. export * from "babylonjs/Probes/index";
  61982. export * from "babylonjs/Rendering/index";
  61983. export * from "babylonjs/scene";
  61984. export * from "babylonjs/sceneComponent";
  61985. export * from "babylonjs/Sprites/index";
  61986. export * from "babylonjs/States/index";
  61987. export * from "babylonjs/Misc/index";
  61988. export * from "babylonjs/types";
  61989. }
  61990. declare module "babylonjs/Animations/pathCursor" {
  61991. import { Path2, Vector3 } from "babylonjs/Maths/math";
  61992. /**
  61993. * A cursor which tracks a point on a path
  61994. */
  61995. export class PathCursor {
  61996. private path;
  61997. /**
  61998. * Stores path cursor callbacks for when an onchange event is triggered
  61999. */
  62000. private _onchange;
  62001. /**
  62002. * The value of the path cursor
  62003. */
  62004. value: number;
  62005. /**
  62006. * The animation array of the path cursor
  62007. */
  62008. animations: Animation[];
  62009. /**
  62010. * Initializes the path cursor
  62011. * @param path The path to track
  62012. */
  62013. constructor(path: Path2);
  62014. /**
  62015. * Gets the cursor point on the path
  62016. * @returns A point on the path cursor at the cursor location
  62017. */
  62018. getPoint(): Vector3;
  62019. /**
  62020. * Moves the cursor ahead by the step amount
  62021. * @param step The amount to move the cursor forward
  62022. * @returns This path cursor
  62023. */
  62024. moveAhead(step?: number): PathCursor;
  62025. /**
  62026. * Moves the cursor behind by the step amount
  62027. * @param step The amount to move the cursor back
  62028. * @returns This path cursor
  62029. */
  62030. moveBack(step?: number): PathCursor;
  62031. /**
  62032. * Moves the cursor by the step amount
  62033. * If the step amount is greater than one, an exception is thrown
  62034. * @param step The amount to move the cursor
  62035. * @returns This path cursor
  62036. */
  62037. move(step: number): PathCursor;
  62038. /**
  62039. * Ensures that the value is limited between zero and one
  62040. * @returns This path cursor
  62041. */
  62042. private ensureLimits;
  62043. /**
  62044. * Runs onchange callbacks on change (used by the animation engine)
  62045. * @returns This path cursor
  62046. */
  62047. private raiseOnChange;
  62048. /**
  62049. * Executes a function on change
  62050. * @param f A path cursor onchange callback
  62051. * @returns This path cursor
  62052. */
  62053. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62054. }
  62055. }
  62056. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62057. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62058. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62059. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62060. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62061. }
  62062. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62063. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62064. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62065. }
  62066. declare module "babylonjs/Engines/Processors/index" {
  62067. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62068. export * from "babylonjs/Engines/Processors/Expressions/index";
  62069. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62070. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62071. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62072. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62073. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62074. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62075. }
  62076. declare module "babylonjs/Legacy/legacy" {
  62077. import * as Babylon from "babylonjs/index";
  62078. export * from "babylonjs/index";
  62079. }
  62080. declare module "babylonjs/Shaders/blur.fragment" {
  62081. /** @hidden */
  62082. export var blurPixelShader: {
  62083. name: string;
  62084. shader: string;
  62085. };
  62086. }
  62087. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  62088. /** @hidden */
  62089. export var bones300Declaration: {
  62090. name: string;
  62091. shader: string;
  62092. };
  62093. }
  62094. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  62095. /** @hidden */
  62096. export var instances300Declaration: {
  62097. name: string;
  62098. shader: string;
  62099. };
  62100. }
  62101. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62102. /** @hidden */
  62103. export var pointCloudVertexDeclaration: {
  62104. name: string;
  62105. shader: string;
  62106. };
  62107. }
  62108. // Mixins
  62109. interface Window {
  62110. mozIndexedDB: IDBFactory;
  62111. webkitIndexedDB: IDBFactory;
  62112. msIndexedDB: IDBFactory;
  62113. webkitURL: typeof URL;
  62114. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62115. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62116. WebGLRenderingContext: WebGLRenderingContext;
  62117. MSGesture: MSGesture;
  62118. CANNON: any;
  62119. AudioContext: AudioContext;
  62120. webkitAudioContext: AudioContext;
  62121. PointerEvent: any;
  62122. Math: Math;
  62123. Uint8Array: Uint8ArrayConstructor;
  62124. Float32Array: Float32ArrayConstructor;
  62125. mozURL: typeof URL;
  62126. msURL: typeof URL;
  62127. VRFrameData: any; // WebVR, from specs 1.1
  62128. DracoDecoderModule: any;
  62129. setImmediate(handler: (...args: any[]) => void): number;
  62130. }
  62131. interface HTMLCanvasElement {
  62132. requestPointerLock(): void;
  62133. msRequestPointerLock?(): void;
  62134. mozRequestPointerLock?(): void;
  62135. webkitRequestPointerLock?(): void;
  62136. /** Track wether a record is in progress */
  62137. isRecording: boolean;
  62138. /** Capture Stream method defined by some browsers */
  62139. captureStream(fps?: number): MediaStream;
  62140. }
  62141. interface CanvasRenderingContext2D {
  62142. msImageSmoothingEnabled: boolean;
  62143. }
  62144. interface MouseEvent {
  62145. mozMovementX: number;
  62146. mozMovementY: number;
  62147. webkitMovementX: number;
  62148. webkitMovementY: number;
  62149. msMovementX: number;
  62150. msMovementY: number;
  62151. }
  62152. interface Navigator {
  62153. mozGetVRDevices: (any: any) => any;
  62154. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62155. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62156. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62157. webkitGetGamepads(): Gamepad[];
  62158. msGetGamepads(): Gamepad[];
  62159. webkitGamepads(): Gamepad[];
  62160. }
  62161. interface HTMLVideoElement {
  62162. mozSrcObject: any;
  62163. }
  62164. interface Math {
  62165. fround(x: number): number;
  62166. imul(a: number, b: number): number;
  62167. }
  62168. interface WebGLRenderingContext {
  62169. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62170. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62171. vertexAttribDivisor(index: number, divisor: number): void;
  62172. createVertexArray(): any;
  62173. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62174. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62175. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62176. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62177. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62178. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62179. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62180. // Queries
  62181. createQuery(): WebGLQuery;
  62182. deleteQuery(query: WebGLQuery): void;
  62183. beginQuery(target: number, query: WebGLQuery): void;
  62184. endQuery(target: number): void;
  62185. getQueryParameter(query: WebGLQuery, pname: number): any;
  62186. getQuery(target: number, pname: number): any;
  62187. MAX_SAMPLES: number;
  62188. RGBA8: number;
  62189. READ_FRAMEBUFFER: number;
  62190. DRAW_FRAMEBUFFER: number;
  62191. UNIFORM_BUFFER: number;
  62192. HALF_FLOAT_OES: number;
  62193. RGBA16F: number;
  62194. RGBA32F: number;
  62195. R32F: number;
  62196. RG32F: number;
  62197. RGB32F: number;
  62198. R16F: number;
  62199. RG16F: number;
  62200. RGB16F: number;
  62201. RED: number;
  62202. RG: number;
  62203. R8: number;
  62204. RG8: number;
  62205. UNSIGNED_INT_24_8: number;
  62206. DEPTH24_STENCIL8: number;
  62207. /* Multiple Render Targets */
  62208. drawBuffers(buffers: number[]): void;
  62209. readBuffer(src: number): void;
  62210. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62211. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62212. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62213. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62214. // Occlusion Query
  62215. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62216. ANY_SAMPLES_PASSED: number;
  62217. QUERY_RESULT_AVAILABLE: number;
  62218. QUERY_RESULT: number;
  62219. }
  62220. interface WebGLProgram {
  62221. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62222. }
  62223. interface EXT_disjoint_timer_query {
  62224. QUERY_COUNTER_BITS_EXT: number;
  62225. TIME_ELAPSED_EXT: number;
  62226. TIMESTAMP_EXT: number;
  62227. GPU_DISJOINT_EXT: number;
  62228. QUERY_RESULT_EXT: number;
  62229. QUERY_RESULT_AVAILABLE_EXT: number;
  62230. queryCounterEXT(query: WebGLQuery, target: number): void;
  62231. createQueryEXT(): WebGLQuery;
  62232. beginQueryEXT(target: number, query: WebGLQuery): void;
  62233. endQueryEXT(target: number): void;
  62234. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62235. deleteQueryEXT(query: WebGLQuery): void;
  62236. }
  62237. interface WebGLUniformLocation {
  62238. _currentState: any;
  62239. }
  62240. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62241. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62242. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62243. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62244. interface WebGLRenderingContext {
  62245. readonly RASTERIZER_DISCARD: number;
  62246. readonly DEPTH_COMPONENT24: number;
  62247. readonly TEXTURE_3D: number;
  62248. readonly TEXTURE_2D_ARRAY: number;
  62249. readonly TEXTURE_COMPARE_FUNC: number;
  62250. readonly TEXTURE_COMPARE_MODE: number;
  62251. readonly COMPARE_REF_TO_TEXTURE: number;
  62252. readonly TEXTURE_WRAP_R: number;
  62253. readonly HALF_FLOAT: number;
  62254. readonly RGB8: number;
  62255. readonly RED_INTEGER: number;
  62256. readonly RG_INTEGER: number;
  62257. readonly RGB_INTEGER: number;
  62258. readonly RGBA_INTEGER: number;
  62259. readonly R8_SNORM: number;
  62260. readonly RG8_SNORM: number;
  62261. readonly RGB8_SNORM: number;
  62262. readonly RGBA8_SNORM: number;
  62263. readonly R8I: number;
  62264. readonly RG8I: number;
  62265. readonly RGB8I: number;
  62266. readonly RGBA8I: number;
  62267. readonly R8UI: number;
  62268. readonly RG8UI: number;
  62269. readonly RGB8UI: number;
  62270. readonly RGBA8UI: number;
  62271. readonly R16I: number;
  62272. readonly RG16I: number;
  62273. readonly RGB16I: number;
  62274. readonly RGBA16I: number;
  62275. readonly R16UI: number;
  62276. readonly RG16UI: number;
  62277. readonly RGB16UI: number;
  62278. readonly RGBA16UI: number;
  62279. readonly R32I: number;
  62280. readonly RG32I: number;
  62281. readonly RGB32I: number;
  62282. readonly RGBA32I: number;
  62283. readonly R32UI: number;
  62284. readonly RG32UI: number;
  62285. readonly RGB32UI: number;
  62286. readonly RGBA32UI: number;
  62287. readonly RGB10_A2UI: number;
  62288. readonly R11F_G11F_B10F: number;
  62289. readonly RGB9_E5: number;
  62290. readonly RGB10_A2: number;
  62291. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62292. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62293. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62294. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62295. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62296. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62297. 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;
  62298. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62299. readonly TRANSFORM_FEEDBACK: number;
  62300. readonly INTERLEAVED_ATTRIBS: number;
  62301. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62302. createTransformFeedback(): WebGLTransformFeedback;
  62303. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62304. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62305. beginTransformFeedback(primitiveMode: number): void;
  62306. endTransformFeedback(): void;
  62307. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62308. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62309. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62310. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62311. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62312. }
  62313. interface ImageBitmap {
  62314. readonly width: number;
  62315. readonly height: number;
  62316. close(): void;
  62317. }
  62318. interface WebGLQuery extends WebGLObject {
  62319. }
  62320. declare var WebGLQuery: {
  62321. prototype: WebGLQuery;
  62322. new(): WebGLQuery;
  62323. };
  62324. interface WebGLSampler extends WebGLObject {
  62325. }
  62326. declare var WebGLSampler: {
  62327. prototype: WebGLSampler;
  62328. new(): WebGLSampler;
  62329. };
  62330. interface WebGLSync extends WebGLObject {
  62331. }
  62332. declare var WebGLSync: {
  62333. prototype: WebGLSync;
  62334. new(): WebGLSync;
  62335. };
  62336. interface WebGLTransformFeedback extends WebGLObject {
  62337. }
  62338. declare var WebGLTransformFeedback: {
  62339. prototype: WebGLTransformFeedback;
  62340. new(): WebGLTransformFeedback;
  62341. };
  62342. interface WebGLVertexArrayObject extends WebGLObject {
  62343. }
  62344. declare var WebGLVertexArrayObject: {
  62345. prototype: WebGLVertexArrayObject;
  62346. new(): WebGLVertexArrayObject;
  62347. };
  62348. // Type definitions for WebVR API
  62349. // Project: https://w3c.github.io/webvr/
  62350. // Definitions by: six a <https://github.com/lostfictions>
  62351. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62352. interface VRDisplay extends EventTarget {
  62353. /**
  62354. * Dictionary of capabilities describing the VRDisplay.
  62355. */
  62356. readonly capabilities: VRDisplayCapabilities;
  62357. /**
  62358. * z-depth defining the far plane of the eye view frustum
  62359. * enables mapping of values in the render target depth
  62360. * attachment to scene coordinates. Initially set to 10000.0.
  62361. */
  62362. depthFar: number;
  62363. /**
  62364. * z-depth defining the near plane of the eye view frustum
  62365. * enables mapping of values in the render target depth
  62366. * attachment to scene coordinates. Initially set to 0.01.
  62367. */
  62368. depthNear: number;
  62369. /**
  62370. * An identifier for this distinct VRDisplay. Used as an
  62371. * association point in the Gamepad API.
  62372. */
  62373. readonly displayId: number;
  62374. /**
  62375. * A display name, a user-readable name identifying it.
  62376. */
  62377. readonly displayName: string;
  62378. readonly isConnected: boolean;
  62379. readonly isPresenting: boolean;
  62380. /**
  62381. * If this VRDisplay supports room-scale experiences, the optional
  62382. * stage attribute contains details on the room-scale parameters.
  62383. */
  62384. readonly stageParameters: VRStageParameters | null;
  62385. /**
  62386. * Passing the value returned by `requestAnimationFrame` to
  62387. * `cancelAnimationFrame` will unregister the callback.
  62388. * @param handle Define the hanle of the request to cancel
  62389. */
  62390. cancelAnimationFrame(handle: number): void;
  62391. /**
  62392. * Stops presenting to the VRDisplay.
  62393. * @returns a promise to know when it stopped
  62394. */
  62395. exitPresent(): Promise<void>;
  62396. /**
  62397. * Return the current VREyeParameters for the given eye.
  62398. * @param whichEye Define the eye we want the parameter for
  62399. * @returns the eye parameters
  62400. */
  62401. getEyeParameters(whichEye: string): VREyeParameters;
  62402. /**
  62403. * Populates the passed VRFrameData with the information required to render
  62404. * the current frame.
  62405. * @param frameData Define the data structure to populate
  62406. * @returns true if ok otherwise false
  62407. */
  62408. getFrameData(frameData: VRFrameData): boolean;
  62409. /**
  62410. * Get the layers currently being presented.
  62411. * @returns the list of VR layers
  62412. */
  62413. getLayers(): VRLayer[];
  62414. /**
  62415. * Return a VRPose containing the future predicted pose of the VRDisplay
  62416. * when the current frame will be presented. The value returned will not
  62417. * change until JavaScript has returned control to the browser.
  62418. *
  62419. * The VRPose will contain the position, orientation, velocity,
  62420. * and acceleration of each of these properties.
  62421. * @returns the pose object
  62422. */
  62423. getPose(): VRPose;
  62424. /**
  62425. * Return the current instantaneous pose of the VRDisplay, with no
  62426. * prediction applied.
  62427. * @returns the current instantaneous pose
  62428. */
  62429. getImmediatePose(): VRPose;
  62430. /**
  62431. * The callback passed to `requestAnimationFrame` will be called
  62432. * any time a new frame should be rendered. When the VRDisplay is
  62433. * presenting the callback will be called at the native refresh
  62434. * rate of the HMD. When not presenting this function acts
  62435. * identically to how window.requestAnimationFrame acts. Content should
  62436. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62437. * asynchronously from other displays and at differing refresh rates.
  62438. * @param callback Define the eaction to run next frame
  62439. * @returns the request handle it
  62440. */
  62441. requestAnimationFrame(callback: FrameRequestCallback): number;
  62442. /**
  62443. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62444. * Repeat calls while already presenting will update the VRLayers being displayed.
  62445. * @param layers Define the list of layer to present
  62446. * @returns a promise to know when the request has been fulfilled
  62447. */
  62448. requestPresent(layers: VRLayer[]): Promise<void>;
  62449. /**
  62450. * Reset the pose for this display, treating its current position and
  62451. * orientation as the "origin/zero" values. VRPose.position,
  62452. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62453. * updated when calling resetPose(). This should be called in only
  62454. * sitting-space experiences.
  62455. */
  62456. resetPose(): void;
  62457. /**
  62458. * The VRLayer provided to the VRDisplay will be captured and presented
  62459. * in the HMD. Calling this function has the same effect on the source
  62460. * canvas as any other operation that uses its source image, and canvases
  62461. * created without preserveDrawingBuffer set to true will be cleared.
  62462. * @param pose Define the pose to submit
  62463. */
  62464. submitFrame(pose?: VRPose): void;
  62465. }
  62466. declare var VRDisplay: {
  62467. prototype: VRDisplay;
  62468. new(): VRDisplay;
  62469. };
  62470. interface VRLayer {
  62471. leftBounds?: number[] | Float32Array | null;
  62472. rightBounds?: number[] | Float32Array | null;
  62473. source?: HTMLCanvasElement | null;
  62474. }
  62475. interface VRDisplayCapabilities {
  62476. readonly canPresent: boolean;
  62477. readonly hasExternalDisplay: boolean;
  62478. readonly hasOrientation: boolean;
  62479. readonly hasPosition: boolean;
  62480. readonly maxLayers: number;
  62481. }
  62482. interface VREyeParameters {
  62483. /** @deprecated */
  62484. readonly fieldOfView: VRFieldOfView;
  62485. readonly offset: Float32Array;
  62486. readonly renderHeight: number;
  62487. readonly renderWidth: number;
  62488. }
  62489. interface VRFieldOfView {
  62490. readonly downDegrees: number;
  62491. readonly leftDegrees: number;
  62492. readonly rightDegrees: number;
  62493. readonly upDegrees: number;
  62494. }
  62495. interface VRFrameData {
  62496. readonly leftProjectionMatrix: Float32Array;
  62497. readonly leftViewMatrix: Float32Array;
  62498. readonly pose: VRPose;
  62499. readonly rightProjectionMatrix: Float32Array;
  62500. readonly rightViewMatrix: Float32Array;
  62501. readonly timestamp: number;
  62502. }
  62503. interface VRPose {
  62504. readonly angularAcceleration: Float32Array | null;
  62505. readonly angularVelocity: Float32Array | null;
  62506. readonly linearAcceleration: Float32Array | null;
  62507. readonly linearVelocity: Float32Array | null;
  62508. readonly orientation: Float32Array | null;
  62509. readonly position: Float32Array | null;
  62510. readonly timestamp: number;
  62511. }
  62512. interface VRStageParameters {
  62513. sittingToStandingTransform?: Float32Array;
  62514. sizeX?: number;
  62515. sizeY?: number;
  62516. }
  62517. interface Navigator {
  62518. getVRDisplays(): Promise<VRDisplay[]>;
  62519. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62520. }
  62521. interface Window {
  62522. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62523. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62524. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62525. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62526. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62527. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62528. }
  62529. interface Gamepad {
  62530. readonly displayId: number;
  62531. }
  62532. interface XRDevice {
  62533. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62534. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62535. }
  62536. interface XRSession {
  62537. getInputSources(): Array<any>;
  62538. baseLayer: XRWebGLLayer;
  62539. requestFrameOfReference(type: string): Promise<void>;
  62540. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62541. end(): Promise<void>;
  62542. requestAnimationFrame: Function;
  62543. addEventListener: Function;
  62544. }
  62545. interface XRSessionCreationOptions {
  62546. outputContext?: WebGLRenderingContext | null;
  62547. immersive?: boolean;
  62548. environmentIntegration?: boolean;
  62549. }
  62550. interface XRLayer {
  62551. getViewport: Function;
  62552. framebufferWidth: number;
  62553. framebufferHeight: number;
  62554. }
  62555. interface XRView {
  62556. projectionMatrix: Float32Array;
  62557. }
  62558. interface XRFrame {
  62559. getDevicePose: Function;
  62560. getInputPose: Function;
  62561. views: Array<XRView>;
  62562. baseLayer: XRLayer;
  62563. }
  62564. interface XRFrameOfReference {
  62565. }
  62566. interface XRWebGLLayer extends XRLayer {
  62567. framebuffer: WebGLFramebuffer;
  62568. }
  62569. declare var XRWebGLLayer: {
  62570. prototype: XRWebGLLayer;
  62571. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62572. };
  62573. declare module "babylonjs" {
  62574. export * from "babylonjs/Legacy/legacy";
  62575. }
  62576. declare module BABYLON {
  62577. /** Alias type for value that can be null */
  62578. export type Nullable<T> = T | null;
  62579. /**
  62580. * Alias type for number that are floats
  62581. * @ignorenaming
  62582. */
  62583. export type float = number;
  62584. /**
  62585. * Alias type for number that are doubles.
  62586. * @ignorenaming
  62587. */
  62588. export type double = number;
  62589. /**
  62590. * Alias type for number that are integer
  62591. * @ignorenaming
  62592. */
  62593. export type int = number;
  62594. /** Alias type for number array or Float32Array */
  62595. export type FloatArray = number[] | Float32Array;
  62596. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62597. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62598. /**
  62599. * Alias for types that can be used by a Buffer or VertexBuffer.
  62600. */
  62601. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62602. /**
  62603. * Alias type for primitive types
  62604. * @ignorenaming
  62605. */
  62606. type Primitive = undefined | null | boolean | string | number | Function;
  62607. /**
  62608. * Type modifier to make all the properties of an object Readonly
  62609. */
  62610. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62611. /**
  62612. * Type modifier to make all the properties of an object Readonly recursively
  62613. */
  62614. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62615. /** @hidden */
  62616. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62617. }
  62618. /** @hidden */
  62619. /** @hidden */
  62620. type DeepImmutableObject<T> = {
  62621. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62622. };
  62623. }
  62624. declare module BABYLON {
  62625. /**
  62626. * Class containing a set of static utilities functions for arrays.
  62627. */
  62628. export class ArrayTools {
  62629. /**
  62630. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62631. * @param size the number of element to construct and put in the array
  62632. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62633. * @returns a new array filled with new objects
  62634. */
  62635. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62636. }
  62637. }
  62638. declare module BABYLON {
  62639. /**
  62640. * Scalar computation library
  62641. */
  62642. export class Scalar {
  62643. /**
  62644. * Two pi constants convenient for computation.
  62645. */
  62646. static TwoPi: number;
  62647. /**
  62648. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62649. * @param a number
  62650. * @param b number
  62651. * @param epsilon (default = 1.401298E-45)
  62652. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62653. */
  62654. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62655. /**
  62656. * Returns a string : the upper case translation of the number i to hexadecimal.
  62657. * @param i number
  62658. * @returns the upper case translation of the number i to hexadecimal.
  62659. */
  62660. static ToHex(i: number): string;
  62661. /**
  62662. * Returns -1 if value is negative and +1 is value is positive.
  62663. * @param value the value
  62664. * @returns the value itself if it's equal to zero.
  62665. */
  62666. static Sign(value: number): number;
  62667. /**
  62668. * Returns the value itself if it's between min and max.
  62669. * Returns min if the value is lower than min.
  62670. * Returns max if the value is greater than max.
  62671. * @param value the value to clmap
  62672. * @param min the min value to clamp to (default: 0)
  62673. * @param max the max value to clamp to (default: 1)
  62674. * @returns the clamped value
  62675. */
  62676. static Clamp(value: number, min?: number, max?: number): number;
  62677. /**
  62678. * the log2 of value.
  62679. * @param value the value to compute log2 of
  62680. * @returns the log2 of value.
  62681. */
  62682. static Log2(value: number): number;
  62683. /**
  62684. * Loops the value, so that it is never larger than length and never smaller than 0.
  62685. *
  62686. * This is similar to the modulo operator but it works with floating point numbers.
  62687. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62688. * With t = 5 and length = 2.5, the result would be 0.0.
  62689. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62690. * @param value the value
  62691. * @param length the length
  62692. * @returns the looped value
  62693. */
  62694. static Repeat(value: number, length: number): number;
  62695. /**
  62696. * Normalize the value between 0.0 and 1.0 using min and max values
  62697. * @param value value to normalize
  62698. * @param min max to normalize between
  62699. * @param max min to normalize between
  62700. * @returns the normalized value
  62701. */
  62702. static Normalize(value: number, min: number, max: number): number;
  62703. /**
  62704. * Denormalize the value from 0.0 and 1.0 using min and max values
  62705. * @param normalized value to denormalize
  62706. * @param min max to denormalize between
  62707. * @param max min to denormalize between
  62708. * @returns the denormalized value
  62709. */
  62710. static Denormalize(normalized: number, min: number, max: number): number;
  62711. /**
  62712. * Calculates the shortest difference between two given angles given in degrees.
  62713. * @param current current angle in degrees
  62714. * @param target target angle in degrees
  62715. * @returns the delta
  62716. */
  62717. static DeltaAngle(current: number, target: number): number;
  62718. /**
  62719. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62720. * @param tx value
  62721. * @param length length
  62722. * @returns The returned value will move back and forth between 0 and length
  62723. */
  62724. static PingPong(tx: number, length: number): number;
  62725. /**
  62726. * Interpolates between min and max with smoothing at the limits.
  62727. *
  62728. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62729. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62730. * @param from from
  62731. * @param to to
  62732. * @param tx value
  62733. * @returns the smooth stepped value
  62734. */
  62735. static SmoothStep(from: number, to: number, tx: number): number;
  62736. /**
  62737. * Moves a value current towards target.
  62738. *
  62739. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62740. * Negative values of maxDelta pushes the value away from target.
  62741. * @param current current value
  62742. * @param target target value
  62743. * @param maxDelta max distance to move
  62744. * @returns resulting value
  62745. */
  62746. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62747. /**
  62748. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62749. *
  62750. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62751. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62752. * @param current current value
  62753. * @param target target value
  62754. * @param maxDelta max distance to move
  62755. * @returns resulting angle
  62756. */
  62757. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62758. /**
  62759. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62760. * @param start start value
  62761. * @param end target value
  62762. * @param amount amount to lerp between
  62763. * @returns the lerped value
  62764. */
  62765. static Lerp(start: number, end: number, amount: number): number;
  62766. /**
  62767. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62768. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62769. * @param start start value
  62770. * @param end target value
  62771. * @param amount amount to lerp between
  62772. * @returns the lerped value
  62773. */
  62774. static LerpAngle(start: number, end: number, amount: number): number;
  62775. /**
  62776. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62777. * @param a start value
  62778. * @param b target value
  62779. * @param value value between a and b
  62780. * @returns the inverseLerp value
  62781. */
  62782. static InverseLerp(a: number, b: number, value: number): number;
  62783. /**
  62784. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62785. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62786. * @param value1 spline value
  62787. * @param tangent1 spline value
  62788. * @param value2 spline value
  62789. * @param tangent2 spline value
  62790. * @param amount input value
  62791. * @returns hermite result
  62792. */
  62793. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62794. /**
  62795. * Returns a random float number between and min and max values
  62796. * @param min min value of random
  62797. * @param max max value of random
  62798. * @returns random value
  62799. */
  62800. static RandomRange(min: number, max: number): number;
  62801. /**
  62802. * This function returns percentage of a number in a given range.
  62803. *
  62804. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62805. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62806. * @param number to convert to percentage
  62807. * @param min min range
  62808. * @param max max range
  62809. * @returns the percentage
  62810. */
  62811. static RangeToPercent(number: number, min: number, max: number): number;
  62812. /**
  62813. * This function returns number that corresponds to the percentage in a given range.
  62814. *
  62815. * PercentToRange(0.34,0,100) will return 34.
  62816. * @param percent to convert to number
  62817. * @param min min range
  62818. * @param max max range
  62819. * @returns the number
  62820. */
  62821. static PercentToRange(percent: number, min: number, max: number): number;
  62822. /**
  62823. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62824. * @param angle The angle to normalize in radian.
  62825. * @return The converted angle.
  62826. */
  62827. static NormalizeRadians(angle: number): number;
  62828. }
  62829. }
  62830. declare module BABYLON {
  62831. /**
  62832. * Constant used to convert a value to gamma space
  62833. * @ignorenaming
  62834. */
  62835. export const ToGammaSpace: number;
  62836. /**
  62837. * Constant used to convert a value to linear space
  62838. * @ignorenaming
  62839. */
  62840. export const ToLinearSpace = 2.2;
  62841. /**
  62842. * Constant used to define the minimal number value in Babylon.js
  62843. * @ignorenaming
  62844. */
  62845. let Epsilon: number;
  62846. /**
  62847. * Class used to hold a RBG color
  62848. */
  62849. export class Color3 {
  62850. /**
  62851. * Defines the red component (between 0 and 1, default is 0)
  62852. */
  62853. r: number;
  62854. /**
  62855. * Defines the green component (between 0 and 1, default is 0)
  62856. */
  62857. g: number;
  62858. /**
  62859. * Defines the blue component (between 0 and 1, default is 0)
  62860. */
  62861. b: number;
  62862. /**
  62863. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62864. * @param r defines the red component (between 0 and 1, default is 0)
  62865. * @param g defines the green component (between 0 and 1, default is 0)
  62866. * @param b defines the blue component (between 0 and 1, default is 0)
  62867. */
  62868. constructor(
  62869. /**
  62870. * Defines the red component (between 0 and 1, default is 0)
  62871. */
  62872. r?: number,
  62873. /**
  62874. * Defines the green component (between 0 and 1, default is 0)
  62875. */
  62876. g?: number,
  62877. /**
  62878. * Defines the blue component (between 0 and 1, default is 0)
  62879. */
  62880. b?: number);
  62881. /**
  62882. * Creates a string with the Color3 current values
  62883. * @returns the string representation of the Color3 object
  62884. */
  62885. toString(): string;
  62886. /**
  62887. * Returns the string "Color3"
  62888. * @returns "Color3"
  62889. */
  62890. getClassName(): string;
  62891. /**
  62892. * Compute the Color3 hash code
  62893. * @returns an unique number that can be used to hash Color3 objects
  62894. */
  62895. getHashCode(): number;
  62896. /**
  62897. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62898. * @param array defines the array where to store the r,g,b components
  62899. * @param index defines an optional index in the target array to define where to start storing values
  62900. * @returns the current Color3 object
  62901. */
  62902. toArray(array: FloatArray, index?: number): Color3;
  62903. /**
  62904. * Returns a new Color4 object from the current Color3 and the given alpha
  62905. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62906. * @returns a new Color4 object
  62907. */
  62908. toColor4(alpha?: number): Color4;
  62909. /**
  62910. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62911. * @returns the new array
  62912. */
  62913. asArray(): number[];
  62914. /**
  62915. * Returns the luminance value
  62916. * @returns a float value
  62917. */
  62918. toLuminance(): number;
  62919. /**
  62920. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62921. * @param otherColor defines the second operand
  62922. * @returns the new Color3 object
  62923. */
  62924. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62925. /**
  62926. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62927. * @param otherColor defines the second operand
  62928. * @param result defines the Color3 object where to store the result
  62929. * @returns the current Color3
  62930. */
  62931. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62932. /**
  62933. * Determines equality between Color3 objects
  62934. * @param otherColor defines the second operand
  62935. * @returns true if the rgb values are equal to the given ones
  62936. */
  62937. equals(otherColor: DeepImmutable<Color3>): boolean;
  62938. /**
  62939. * Determines equality between the current Color3 object and a set of r,b,g values
  62940. * @param r defines the red component to check
  62941. * @param g defines the green component to check
  62942. * @param b defines the blue component to check
  62943. * @returns true if the rgb values are equal to the given ones
  62944. */
  62945. equalsFloats(r: number, g: number, b: number): boolean;
  62946. /**
  62947. * Multiplies in place each rgb value by scale
  62948. * @param scale defines the scaling factor
  62949. * @returns the updated Color3
  62950. */
  62951. scale(scale: number): Color3;
  62952. /**
  62953. * Multiplies the rgb values by scale and stores the result into "result"
  62954. * @param scale defines the scaling factor
  62955. * @param result defines the Color3 object where to store the result
  62956. * @returns the unmodified current Color3
  62957. */
  62958. scaleToRef(scale: number, result: Color3): Color3;
  62959. /**
  62960. * Scale the current Color3 values by a factor and add the result to a given Color3
  62961. * @param scale defines the scale factor
  62962. * @param result defines color to store the result into
  62963. * @returns the unmodified current Color3
  62964. */
  62965. scaleAndAddToRef(scale: number, result: Color3): Color3;
  62966. /**
  62967. * Clamps the rgb values by the min and max values and stores the result into "result"
  62968. * @param min defines minimum clamping value (default is 0)
  62969. * @param max defines maximum clamping value (default is 1)
  62970. * @param result defines color to store the result into
  62971. * @returns the original Color3
  62972. */
  62973. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  62974. /**
  62975. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  62976. * @param otherColor defines the second operand
  62977. * @returns the new Color3
  62978. */
  62979. add(otherColor: DeepImmutable<Color3>): Color3;
  62980. /**
  62981. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  62982. * @param otherColor defines the second operand
  62983. * @param result defines Color3 object to store the result into
  62984. * @returns the unmodified current Color3
  62985. */
  62986. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62987. /**
  62988. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  62989. * @param otherColor defines the second operand
  62990. * @returns the new Color3
  62991. */
  62992. subtract(otherColor: DeepImmutable<Color3>): Color3;
  62993. /**
  62994. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  62995. * @param otherColor defines the second operand
  62996. * @param result defines Color3 object to store the result into
  62997. * @returns the unmodified current Color3
  62998. */
  62999. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63000. /**
  63001. * Copy the current object
  63002. * @returns a new Color3 copied the current one
  63003. */
  63004. clone(): Color3;
  63005. /**
  63006. * Copies the rgb values from the source in the current Color3
  63007. * @param source defines the source Color3 object
  63008. * @returns the updated Color3 object
  63009. */
  63010. copyFrom(source: DeepImmutable<Color3>): Color3;
  63011. /**
  63012. * Updates the Color3 rgb values from the given floats
  63013. * @param r defines the red component to read from
  63014. * @param g defines the green component to read from
  63015. * @param b defines the blue component to read from
  63016. * @returns the current Color3 object
  63017. */
  63018. copyFromFloats(r: number, g: number, b: number): Color3;
  63019. /**
  63020. * Updates the Color3 rgb values from the given floats
  63021. * @param r defines the red component to read from
  63022. * @param g defines the green component to read from
  63023. * @param b defines the blue component to read from
  63024. * @returns the current Color3 object
  63025. */
  63026. set(r: number, g: number, b: number): Color3;
  63027. /**
  63028. * Compute the Color3 hexadecimal code as a string
  63029. * @returns a string containing the hexadecimal representation of the Color3 object
  63030. */
  63031. toHexString(): string;
  63032. /**
  63033. * Computes a new Color3 converted from the current one to linear space
  63034. * @returns a new Color3 object
  63035. */
  63036. toLinearSpace(): Color3;
  63037. /**
  63038. * Converts current color in rgb space to HSV values
  63039. * @returns a new color3 representing the HSV values
  63040. */
  63041. toHSV(): Color3;
  63042. /**
  63043. * Converts current color in rgb space to HSV values
  63044. * @param result defines the Color3 where to store the HSV values
  63045. */
  63046. toHSVToRef(result: Color3): void;
  63047. /**
  63048. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63049. * @param convertedColor defines the Color3 object where to store the linear space version
  63050. * @returns the unmodified Color3
  63051. */
  63052. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63053. /**
  63054. * Computes a new Color3 converted from the current one to gamma space
  63055. * @returns a new Color3 object
  63056. */
  63057. toGammaSpace(): Color3;
  63058. /**
  63059. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63060. * @param convertedColor defines the Color3 object where to store the gamma space version
  63061. * @returns the unmodified Color3
  63062. */
  63063. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63064. private static _BlackReadOnly;
  63065. /**
  63066. * Convert Hue, saturation and value to a Color3 (RGB)
  63067. * @param hue defines the hue
  63068. * @param saturation defines the saturation
  63069. * @param value defines the value
  63070. * @param result defines the Color3 where to store the RGB values
  63071. */
  63072. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63073. /**
  63074. * Creates a new Color3 from the string containing valid hexadecimal values
  63075. * @param hex defines a string containing valid hexadecimal values
  63076. * @returns a new Color3 object
  63077. */
  63078. static FromHexString(hex: string): Color3;
  63079. /**
  63080. * Creates a new Color3 from the starting index of the given array
  63081. * @param array defines the source array
  63082. * @param offset defines an offset in the source array
  63083. * @returns a new Color3 object
  63084. */
  63085. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63086. /**
  63087. * Creates a new Color3 from integer values (< 256)
  63088. * @param r defines the red component to read from (value between 0 and 255)
  63089. * @param g defines the green component to read from (value between 0 and 255)
  63090. * @param b defines the blue component to read from (value between 0 and 255)
  63091. * @returns a new Color3 object
  63092. */
  63093. static FromInts(r: number, g: number, b: number): Color3;
  63094. /**
  63095. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63096. * @param start defines the start Color3 value
  63097. * @param end defines the end Color3 value
  63098. * @param amount defines the gradient value between start and end
  63099. * @returns a new Color3 object
  63100. */
  63101. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63102. /**
  63103. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63104. * @param left defines the start value
  63105. * @param right defines the end value
  63106. * @param amount defines the gradient factor
  63107. * @param result defines the Color3 object where to store the result
  63108. */
  63109. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63110. /**
  63111. * Returns a Color3 value containing a red color
  63112. * @returns a new Color3 object
  63113. */
  63114. static Red(): Color3;
  63115. /**
  63116. * Returns a Color3 value containing a green color
  63117. * @returns a new Color3 object
  63118. */
  63119. static Green(): Color3;
  63120. /**
  63121. * Returns a Color3 value containing a blue color
  63122. * @returns a new Color3 object
  63123. */
  63124. static Blue(): Color3;
  63125. /**
  63126. * Returns a Color3 value containing a black color
  63127. * @returns a new Color3 object
  63128. */
  63129. static Black(): Color3;
  63130. /**
  63131. * Gets a Color3 value containing a black color that must not be updated
  63132. */
  63133. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63134. /**
  63135. * Returns a Color3 value containing a white color
  63136. * @returns a new Color3 object
  63137. */
  63138. static White(): Color3;
  63139. /**
  63140. * Returns a Color3 value containing a purple color
  63141. * @returns a new Color3 object
  63142. */
  63143. static Purple(): Color3;
  63144. /**
  63145. * Returns a Color3 value containing a magenta color
  63146. * @returns a new Color3 object
  63147. */
  63148. static Magenta(): Color3;
  63149. /**
  63150. * Returns a Color3 value containing a yellow color
  63151. * @returns a new Color3 object
  63152. */
  63153. static Yellow(): Color3;
  63154. /**
  63155. * Returns a Color3 value containing a gray color
  63156. * @returns a new Color3 object
  63157. */
  63158. static Gray(): Color3;
  63159. /**
  63160. * Returns a Color3 value containing a teal color
  63161. * @returns a new Color3 object
  63162. */
  63163. static Teal(): Color3;
  63164. /**
  63165. * Returns a Color3 value containing a random color
  63166. * @returns a new Color3 object
  63167. */
  63168. static Random(): Color3;
  63169. }
  63170. /**
  63171. * Class used to hold a RBGA color
  63172. */
  63173. export class Color4 {
  63174. /**
  63175. * Defines the red component (between 0 and 1, default is 0)
  63176. */
  63177. r: number;
  63178. /**
  63179. * Defines the green component (between 0 and 1, default is 0)
  63180. */
  63181. g: number;
  63182. /**
  63183. * Defines the blue component (between 0 and 1, default is 0)
  63184. */
  63185. b: number;
  63186. /**
  63187. * Defines the alpha component (between 0 and 1, default is 1)
  63188. */
  63189. a: number;
  63190. /**
  63191. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63192. * @param r defines the red component (between 0 and 1, default is 0)
  63193. * @param g defines the green component (between 0 and 1, default is 0)
  63194. * @param b defines the blue component (between 0 and 1, default is 0)
  63195. * @param a defines the alpha component (between 0 and 1, default is 1)
  63196. */
  63197. constructor(
  63198. /**
  63199. * Defines the red component (between 0 and 1, default is 0)
  63200. */
  63201. r?: number,
  63202. /**
  63203. * Defines the green component (between 0 and 1, default is 0)
  63204. */
  63205. g?: number,
  63206. /**
  63207. * Defines the blue component (between 0 and 1, default is 0)
  63208. */
  63209. b?: number,
  63210. /**
  63211. * Defines the alpha component (between 0 and 1, default is 1)
  63212. */
  63213. a?: number);
  63214. /**
  63215. * Adds in place the given Color4 values to the current Color4 object
  63216. * @param right defines the second operand
  63217. * @returns the current updated Color4 object
  63218. */
  63219. addInPlace(right: DeepImmutable<Color4>): Color4;
  63220. /**
  63221. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63222. * @returns the new array
  63223. */
  63224. asArray(): number[];
  63225. /**
  63226. * Stores from the starting index in the given array the Color4 successive values
  63227. * @param array defines the array where to store the r,g,b components
  63228. * @param index defines an optional index in the target array to define where to start storing values
  63229. * @returns the current Color4 object
  63230. */
  63231. toArray(array: number[], index?: number): Color4;
  63232. /**
  63233. * Determines equality between Color4 objects
  63234. * @param otherColor defines the second operand
  63235. * @returns true if the rgba values are equal to the given ones
  63236. */
  63237. equals(otherColor: DeepImmutable<Color4>): boolean;
  63238. /**
  63239. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63240. * @param right defines the second operand
  63241. * @returns a new Color4 object
  63242. */
  63243. add(right: DeepImmutable<Color4>): Color4;
  63244. /**
  63245. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63246. * @param right defines the second operand
  63247. * @returns a new Color4 object
  63248. */
  63249. subtract(right: DeepImmutable<Color4>): Color4;
  63250. /**
  63251. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63252. * @param right defines the second operand
  63253. * @param result defines the Color4 object where to store the result
  63254. * @returns the current Color4 object
  63255. */
  63256. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63257. /**
  63258. * Creates a new Color4 with the current Color4 values multiplied by scale
  63259. * @param scale defines the scaling factor to apply
  63260. * @returns a new Color4 object
  63261. */
  63262. scale(scale: number): Color4;
  63263. /**
  63264. * Multiplies the current Color4 values by scale and stores the result in "result"
  63265. * @param scale defines the scaling factor to apply
  63266. * @param result defines the Color4 object where to store the result
  63267. * @returns the current unmodified Color4
  63268. */
  63269. scaleToRef(scale: number, result: Color4): Color4;
  63270. /**
  63271. * Scale the current Color4 values by a factor and add the result to a given Color4
  63272. * @param scale defines the scale factor
  63273. * @param result defines the Color4 object where to store the result
  63274. * @returns the unmodified current Color4
  63275. */
  63276. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63277. /**
  63278. * Clamps the rgb values by the min and max values and stores the result into "result"
  63279. * @param min defines minimum clamping value (default is 0)
  63280. * @param max defines maximum clamping value (default is 1)
  63281. * @param result defines color to store the result into.
  63282. * @returns the cuurent Color4
  63283. */
  63284. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63285. /**
  63286. * Multipy an Color4 value by another and return a new Color4 object
  63287. * @param color defines the Color4 value to multiply by
  63288. * @returns a new Color4 object
  63289. */
  63290. multiply(color: Color4): Color4;
  63291. /**
  63292. * Multipy a Color4 value by another and push the result in a reference value
  63293. * @param color defines the Color4 value to multiply by
  63294. * @param result defines the Color4 to fill the result in
  63295. * @returns the result Color4
  63296. */
  63297. multiplyToRef(color: Color4, result: Color4): Color4;
  63298. /**
  63299. * Creates a string with the Color4 current values
  63300. * @returns the string representation of the Color4 object
  63301. */
  63302. toString(): string;
  63303. /**
  63304. * Returns the string "Color4"
  63305. * @returns "Color4"
  63306. */
  63307. getClassName(): string;
  63308. /**
  63309. * Compute the Color4 hash code
  63310. * @returns an unique number that can be used to hash Color4 objects
  63311. */
  63312. getHashCode(): number;
  63313. /**
  63314. * Creates a new Color4 copied from the current one
  63315. * @returns a new Color4 object
  63316. */
  63317. clone(): Color4;
  63318. /**
  63319. * Copies the given Color4 values into the current one
  63320. * @param source defines the source Color4 object
  63321. * @returns the current updated Color4 object
  63322. */
  63323. copyFrom(source: Color4): Color4;
  63324. /**
  63325. * Copies the given float values into the current one
  63326. * @param r defines the red component to read from
  63327. * @param g defines the green component to read from
  63328. * @param b defines the blue component to read from
  63329. * @param a defines the alpha component to read from
  63330. * @returns the current updated Color4 object
  63331. */
  63332. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63333. /**
  63334. * Copies the given float values into the current one
  63335. * @param r defines the red component to read from
  63336. * @param g defines the green component to read from
  63337. * @param b defines the blue component to read from
  63338. * @param a defines the alpha component to read from
  63339. * @returns the current updated Color4 object
  63340. */
  63341. set(r: number, g: number, b: number, a: number): Color4;
  63342. /**
  63343. * Compute the Color4 hexadecimal code as a string
  63344. * @returns a string containing the hexadecimal representation of the Color4 object
  63345. */
  63346. toHexString(): string;
  63347. /**
  63348. * Computes a new Color4 converted from the current one to linear space
  63349. * @returns a new Color4 object
  63350. */
  63351. toLinearSpace(): Color4;
  63352. /**
  63353. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63354. * @param convertedColor defines the Color4 object where to store the linear space version
  63355. * @returns the unmodified Color4
  63356. */
  63357. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63358. /**
  63359. * Computes a new Color4 converted from the current one to gamma space
  63360. * @returns a new Color4 object
  63361. */
  63362. toGammaSpace(): Color4;
  63363. /**
  63364. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63365. * @param convertedColor defines the Color4 object where to store the gamma space version
  63366. * @returns the unmodified Color4
  63367. */
  63368. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63369. /**
  63370. * Creates a new Color4 from the string containing valid hexadecimal values
  63371. * @param hex defines a string containing valid hexadecimal values
  63372. * @returns a new Color4 object
  63373. */
  63374. static FromHexString(hex: string): Color4;
  63375. /**
  63376. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63377. * @param left defines the start value
  63378. * @param right defines the end value
  63379. * @param amount defines the gradient factor
  63380. * @returns a new Color4 object
  63381. */
  63382. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63383. /**
  63384. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63385. * @param left defines the start value
  63386. * @param right defines the end value
  63387. * @param amount defines the gradient factor
  63388. * @param result defines the Color4 object where to store data
  63389. */
  63390. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63391. /**
  63392. * Creates a new Color4 from a Color3 and an alpha value
  63393. * @param color3 defines the source Color3 to read from
  63394. * @param alpha defines the alpha component (1.0 by default)
  63395. * @returns a new Color4 object
  63396. */
  63397. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63398. /**
  63399. * Creates a new Color4 from the starting index element of the given array
  63400. * @param array defines the source array to read from
  63401. * @param offset defines the offset in the source array
  63402. * @returns a new Color4 object
  63403. */
  63404. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63405. /**
  63406. * Creates a new Color3 from integer values (< 256)
  63407. * @param r defines the red component to read from (value between 0 and 255)
  63408. * @param g defines the green component to read from (value between 0 and 255)
  63409. * @param b defines the blue component to read from (value between 0 and 255)
  63410. * @param a defines the alpha component to read from (value between 0 and 255)
  63411. * @returns a new Color3 object
  63412. */
  63413. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63414. /**
  63415. * Check the content of a given array and convert it to an array containing RGBA data
  63416. * If the original array was already containing count * 4 values then it is returned directly
  63417. * @param colors defines the array to check
  63418. * @param count defines the number of RGBA data to expect
  63419. * @returns an array containing count * 4 values (RGBA)
  63420. */
  63421. static CheckColors4(colors: number[], count: number): number[];
  63422. }
  63423. /**
  63424. * Class representing a vector containing 2 coordinates
  63425. */
  63426. export class Vector2 {
  63427. /** defines the first coordinate */
  63428. x: number;
  63429. /** defines the second coordinate */
  63430. y: number;
  63431. /**
  63432. * Creates a new Vector2 from the given x and y coordinates
  63433. * @param x defines the first coordinate
  63434. * @param y defines the second coordinate
  63435. */
  63436. constructor(
  63437. /** defines the first coordinate */
  63438. x?: number,
  63439. /** defines the second coordinate */
  63440. y?: number);
  63441. /**
  63442. * Gets a string with the Vector2 coordinates
  63443. * @returns a string with the Vector2 coordinates
  63444. */
  63445. toString(): string;
  63446. /**
  63447. * Gets class name
  63448. * @returns the string "Vector2"
  63449. */
  63450. getClassName(): string;
  63451. /**
  63452. * Gets current vector hash code
  63453. * @returns the Vector2 hash code as a number
  63454. */
  63455. getHashCode(): number;
  63456. /**
  63457. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63458. * @param array defines the source array
  63459. * @param index defines the offset in source array
  63460. * @returns the current Vector2
  63461. */
  63462. toArray(array: FloatArray, index?: number): Vector2;
  63463. /**
  63464. * Copy the current vector to an array
  63465. * @returns a new array with 2 elements: the Vector2 coordinates.
  63466. */
  63467. asArray(): number[];
  63468. /**
  63469. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63470. * @param source defines the source Vector2
  63471. * @returns the current updated Vector2
  63472. */
  63473. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63474. /**
  63475. * Sets the Vector2 coordinates with the given floats
  63476. * @param x defines the first coordinate
  63477. * @param y defines the second coordinate
  63478. * @returns the current updated Vector2
  63479. */
  63480. copyFromFloats(x: number, y: number): Vector2;
  63481. /**
  63482. * Sets the Vector2 coordinates with the given floats
  63483. * @param x defines the first coordinate
  63484. * @param y defines the second coordinate
  63485. * @returns the current updated Vector2
  63486. */
  63487. set(x: number, y: number): Vector2;
  63488. /**
  63489. * Add another vector with the current one
  63490. * @param otherVector defines the other vector
  63491. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63492. */
  63493. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63494. /**
  63495. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63496. * @param otherVector defines the other vector
  63497. * @param result defines the target vector
  63498. * @returns the unmodified current Vector2
  63499. */
  63500. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63501. /**
  63502. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63503. * @param otherVector defines the other vector
  63504. * @returns the current updated Vector2
  63505. */
  63506. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63507. /**
  63508. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63509. * @param otherVector defines the other vector
  63510. * @returns a new Vector2
  63511. */
  63512. addVector3(otherVector: Vector3): Vector2;
  63513. /**
  63514. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63515. * @param otherVector defines the other vector
  63516. * @returns a new Vector2
  63517. */
  63518. subtract(otherVector: Vector2): Vector2;
  63519. /**
  63520. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63521. * @param otherVector defines the other vector
  63522. * @param result defines the target vector
  63523. * @returns the unmodified current Vector2
  63524. */
  63525. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63526. /**
  63527. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63528. * @param otherVector defines the other vector
  63529. * @returns the current updated Vector2
  63530. */
  63531. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63532. /**
  63533. * Multiplies in place the current Vector2 coordinates by the given ones
  63534. * @param otherVector defines the other vector
  63535. * @returns the current updated Vector2
  63536. */
  63537. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63538. /**
  63539. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63540. * @param otherVector defines the other vector
  63541. * @returns a new Vector2
  63542. */
  63543. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63544. /**
  63545. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63546. * @param otherVector defines the other vector
  63547. * @param result defines the target vector
  63548. * @returns the unmodified current Vector2
  63549. */
  63550. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63551. /**
  63552. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63553. * @param x defines the first coordinate
  63554. * @param y defines the second coordinate
  63555. * @returns a new Vector2
  63556. */
  63557. multiplyByFloats(x: number, y: number): Vector2;
  63558. /**
  63559. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63560. * @param otherVector defines the other vector
  63561. * @returns a new Vector2
  63562. */
  63563. divide(otherVector: Vector2): Vector2;
  63564. /**
  63565. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63566. * @param otherVector defines the other vector
  63567. * @param result defines the target vector
  63568. * @returns the unmodified current Vector2
  63569. */
  63570. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63571. /**
  63572. * Divides the current Vector2 coordinates by the given ones
  63573. * @param otherVector defines the other vector
  63574. * @returns the current updated Vector2
  63575. */
  63576. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63577. /**
  63578. * Gets a new Vector2 with current Vector2 negated coordinates
  63579. * @returns a new Vector2
  63580. */
  63581. negate(): Vector2;
  63582. /**
  63583. * Multiply the Vector2 coordinates by scale
  63584. * @param scale defines the scaling factor
  63585. * @returns the current updated Vector2
  63586. */
  63587. scaleInPlace(scale: number): Vector2;
  63588. /**
  63589. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63590. * @param scale defines the scaling factor
  63591. * @returns a new Vector2
  63592. */
  63593. scale(scale: number): Vector2;
  63594. /**
  63595. * Scale the current Vector2 values by a factor to a given Vector2
  63596. * @param scale defines the scale factor
  63597. * @param result defines the Vector2 object where to store the result
  63598. * @returns the unmodified current Vector2
  63599. */
  63600. scaleToRef(scale: number, result: Vector2): Vector2;
  63601. /**
  63602. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63603. * @param scale defines the scale factor
  63604. * @param result defines the Vector2 object where to store the result
  63605. * @returns the unmodified current Vector2
  63606. */
  63607. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63608. /**
  63609. * Gets a boolean if two vectors are equals
  63610. * @param otherVector defines the other vector
  63611. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63612. */
  63613. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63614. /**
  63615. * Gets a boolean if two vectors are equals (using an epsilon value)
  63616. * @param otherVector defines the other vector
  63617. * @param epsilon defines the minimal distance to consider equality
  63618. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63619. */
  63620. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63621. /**
  63622. * Gets a new Vector2 from current Vector2 floored values
  63623. * @returns a new Vector2
  63624. */
  63625. floor(): Vector2;
  63626. /**
  63627. * Gets a new Vector2 from current Vector2 floored values
  63628. * @returns a new Vector2
  63629. */
  63630. fract(): Vector2;
  63631. /**
  63632. * Gets the length of the vector
  63633. * @returns the vector length (float)
  63634. */
  63635. length(): number;
  63636. /**
  63637. * Gets the vector squared length
  63638. * @returns the vector squared length (float)
  63639. */
  63640. lengthSquared(): number;
  63641. /**
  63642. * Normalize the vector
  63643. * @returns the current updated Vector2
  63644. */
  63645. normalize(): Vector2;
  63646. /**
  63647. * Gets a new Vector2 copied from the Vector2
  63648. * @returns a new Vector2
  63649. */
  63650. clone(): Vector2;
  63651. /**
  63652. * Gets a new Vector2(0, 0)
  63653. * @returns a new Vector2
  63654. */
  63655. static Zero(): Vector2;
  63656. /**
  63657. * Gets a new Vector2(1, 1)
  63658. * @returns a new Vector2
  63659. */
  63660. static One(): Vector2;
  63661. /**
  63662. * Gets a new Vector2 set from the given index element of the given array
  63663. * @param array defines the data source
  63664. * @param offset defines the offset in the data source
  63665. * @returns a new Vector2
  63666. */
  63667. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63668. /**
  63669. * Sets "result" from the given index element of the given array
  63670. * @param array defines the data source
  63671. * @param offset defines the offset in the data source
  63672. * @param result defines the target vector
  63673. */
  63674. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63675. /**
  63676. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63677. * @param value1 defines 1st point of control
  63678. * @param value2 defines 2nd point of control
  63679. * @param value3 defines 3rd point of control
  63680. * @param value4 defines 4th point of control
  63681. * @param amount defines the interpolation factor
  63682. * @returns a new Vector2
  63683. */
  63684. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63685. /**
  63686. * 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".
  63687. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63688. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63689. * @param value defines the value to clamp
  63690. * @param min defines the lower limit
  63691. * @param max defines the upper limit
  63692. * @returns a new Vector2
  63693. */
  63694. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63695. /**
  63696. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63697. * @param value1 defines the 1st control point
  63698. * @param tangent1 defines the outgoing tangent
  63699. * @param value2 defines the 2nd control point
  63700. * @param tangent2 defines the incoming tangent
  63701. * @param amount defines the interpolation factor
  63702. * @returns a new Vector2
  63703. */
  63704. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63705. /**
  63706. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63707. * @param start defines the start vector
  63708. * @param end defines the end vector
  63709. * @param amount defines the interpolation factor
  63710. * @returns a new Vector2
  63711. */
  63712. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63713. /**
  63714. * Gets the dot product of the vector "left" and the vector "right"
  63715. * @param left defines first vector
  63716. * @param right defines second vector
  63717. * @returns the dot product (float)
  63718. */
  63719. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63720. /**
  63721. * Returns a new Vector2 equal to the normalized given vector
  63722. * @param vector defines the vector to normalize
  63723. * @returns a new Vector2
  63724. */
  63725. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63726. /**
  63727. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63728. * @param left defines 1st vector
  63729. * @param right defines 2nd vector
  63730. * @returns a new Vector2
  63731. */
  63732. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63733. /**
  63734. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63735. * @param left defines 1st vector
  63736. * @param right defines 2nd vector
  63737. * @returns a new Vector2
  63738. */
  63739. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63740. /**
  63741. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63742. * @param vector defines the vector to transform
  63743. * @param transformation defines the matrix to apply
  63744. * @returns a new Vector2
  63745. */
  63746. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63747. /**
  63748. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63749. * @param vector defines the vector to transform
  63750. * @param transformation defines the matrix to apply
  63751. * @param result defines the target vector
  63752. */
  63753. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63754. /**
  63755. * Determines if a given vector is included in a triangle
  63756. * @param p defines the vector to test
  63757. * @param p0 defines 1st triangle point
  63758. * @param p1 defines 2nd triangle point
  63759. * @param p2 defines 3rd triangle point
  63760. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63761. */
  63762. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63763. /**
  63764. * Gets the distance between the vectors "value1" and "value2"
  63765. * @param value1 defines first vector
  63766. * @param value2 defines second vector
  63767. * @returns the distance between vectors
  63768. */
  63769. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63770. /**
  63771. * Returns the squared distance between the vectors "value1" and "value2"
  63772. * @param value1 defines first vector
  63773. * @param value2 defines second vector
  63774. * @returns the squared distance between vectors
  63775. */
  63776. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63777. /**
  63778. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63779. * @param value1 defines first vector
  63780. * @param value2 defines second vector
  63781. * @returns a new Vector2
  63782. */
  63783. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63784. /**
  63785. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63786. * @param p defines the middle point
  63787. * @param segA defines one point of the segment
  63788. * @param segB defines the other point of the segment
  63789. * @returns the shortest distance
  63790. */
  63791. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63792. }
  63793. /**
  63794. * Classed used to store (x,y,z) vector representation
  63795. * A Vector3 is the main object used in 3D geometry
  63796. * It can represent etiher the coordinates of a point the space, either a direction
  63797. * Reminder: js uses a left handed forward facing system
  63798. */
  63799. export class Vector3 {
  63800. /**
  63801. * Defines the first coordinates (on X axis)
  63802. */
  63803. x: number;
  63804. /**
  63805. * Defines the second coordinates (on Y axis)
  63806. */
  63807. y: number;
  63808. /**
  63809. * Defines the third coordinates (on Z axis)
  63810. */
  63811. z: number;
  63812. private static _UpReadOnly;
  63813. private static _ZeroReadOnly;
  63814. /**
  63815. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63816. * @param x defines the first coordinates (on X axis)
  63817. * @param y defines the second coordinates (on Y axis)
  63818. * @param z defines the third coordinates (on Z axis)
  63819. */
  63820. constructor(
  63821. /**
  63822. * Defines the first coordinates (on X axis)
  63823. */
  63824. x?: number,
  63825. /**
  63826. * Defines the second coordinates (on Y axis)
  63827. */
  63828. y?: number,
  63829. /**
  63830. * Defines the third coordinates (on Z axis)
  63831. */
  63832. z?: number);
  63833. /**
  63834. * Creates a string representation of the Vector3
  63835. * @returns a string with the Vector3 coordinates.
  63836. */
  63837. toString(): string;
  63838. /**
  63839. * Gets the class name
  63840. * @returns the string "Vector3"
  63841. */
  63842. getClassName(): string;
  63843. /**
  63844. * Creates the Vector3 hash code
  63845. * @returns a number which tends to be unique between Vector3 instances
  63846. */
  63847. getHashCode(): number;
  63848. /**
  63849. * Creates an array containing three elements : the coordinates of the Vector3
  63850. * @returns a new array of numbers
  63851. */
  63852. asArray(): number[];
  63853. /**
  63854. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63855. * @param array defines the destination array
  63856. * @param index defines the offset in the destination array
  63857. * @returns the current Vector3
  63858. */
  63859. toArray(array: FloatArray, index?: number): Vector3;
  63860. /**
  63861. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63862. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63863. */
  63864. toQuaternion(): Quaternion;
  63865. /**
  63866. * Adds the given vector to the current Vector3
  63867. * @param otherVector defines the second operand
  63868. * @returns the current updated Vector3
  63869. */
  63870. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63871. /**
  63872. * Adds the given coordinates to the current Vector3
  63873. * @param x defines the x coordinate of the operand
  63874. * @param y defines the y coordinate of the operand
  63875. * @param z defines the z coordinate of the operand
  63876. * @returns the current updated Vector3
  63877. */
  63878. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63879. /**
  63880. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63881. * @param otherVector defines the second operand
  63882. * @returns the resulting Vector3
  63883. */
  63884. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63885. /**
  63886. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63887. * @param otherVector defines the second operand
  63888. * @param result defines the Vector3 object where to store the result
  63889. * @returns the current Vector3
  63890. */
  63891. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63892. /**
  63893. * Subtract the given vector from the current Vector3
  63894. * @param otherVector defines the second operand
  63895. * @returns the current updated Vector3
  63896. */
  63897. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63898. /**
  63899. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63900. * @param otherVector defines the second operand
  63901. * @returns the resulting Vector3
  63902. */
  63903. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63904. /**
  63905. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63906. * @param otherVector defines the second operand
  63907. * @param result defines the Vector3 object where to store the result
  63908. * @returns the current Vector3
  63909. */
  63910. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63911. /**
  63912. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63913. * @param x defines the x coordinate of the operand
  63914. * @param y defines the y coordinate of the operand
  63915. * @param z defines the z coordinate of the operand
  63916. * @returns the resulting Vector3
  63917. */
  63918. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63919. /**
  63920. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63921. * @param x defines the x coordinate of the operand
  63922. * @param y defines the y coordinate of the operand
  63923. * @param z defines the z coordinate of the operand
  63924. * @param result defines the Vector3 object where to store the result
  63925. * @returns the current Vector3
  63926. */
  63927. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63928. /**
  63929. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63930. * @returns a new Vector3
  63931. */
  63932. negate(): Vector3;
  63933. /**
  63934. * Multiplies the Vector3 coordinates by the float "scale"
  63935. * @param scale defines the multiplier factor
  63936. * @returns the current updated Vector3
  63937. */
  63938. scaleInPlace(scale: number): Vector3;
  63939. /**
  63940. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63941. * @param scale defines the multiplier factor
  63942. * @returns a new Vector3
  63943. */
  63944. scale(scale: number): Vector3;
  63945. /**
  63946. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63947. * @param scale defines the multiplier factor
  63948. * @param result defines the Vector3 object where to store the result
  63949. * @returns the current Vector3
  63950. */
  63951. scaleToRef(scale: number, result: Vector3): Vector3;
  63952. /**
  63953. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63954. * @param scale defines the scale factor
  63955. * @param result defines the Vector3 object where to store the result
  63956. * @returns the unmodified current Vector3
  63957. */
  63958. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63959. /**
  63960. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63961. * @param otherVector defines the second operand
  63962. * @returns true if both vectors are equals
  63963. */
  63964. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63965. /**
  63966. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  63967. * @param otherVector defines the second operand
  63968. * @param epsilon defines the minimal distance to define values as equals
  63969. * @returns true if both vectors are distant less than epsilon
  63970. */
  63971. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  63972. /**
  63973. * Returns true if the current Vector3 coordinates equals the given floats
  63974. * @param x defines the x coordinate of the operand
  63975. * @param y defines the y coordinate of the operand
  63976. * @param z defines the z coordinate of the operand
  63977. * @returns true if both vectors are equals
  63978. */
  63979. equalsToFloats(x: number, y: number, z: number): boolean;
  63980. /**
  63981. * Multiplies the current Vector3 coordinates by the given ones
  63982. * @param otherVector defines the second operand
  63983. * @returns the current updated Vector3
  63984. */
  63985. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63986. /**
  63987. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  63988. * @param otherVector defines the second operand
  63989. * @returns the new Vector3
  63990. */
  63991. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  63992. /**
  63993. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  63994. * @param otherVector defines the second operand
  63995. * @param result defines the Vector3 object where to store the result
  63996. * @returns the current Vector3
  63997. */
  63998. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63999. /**
  64000. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64001. * @param x defines the x coordinate of the operand
  64002. * @param y defines the y coordinate of the operand
  64003. * @param z defines the z coordinate of the operand
  64004. * @returns the new Vector3
  64005. */
  64006. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64007. /**
  64008. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64009. * @param otherVector defines the second operand
  64010. * @returns the new Vector3
  64011. */
  64012. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64013. /**
  64014. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64015. * @param otherVector defines the second operand
  64016. * @param result defines the Vector3 object where to store the result
  64017. * @returns the current Vector3
  64018. */
  64019. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64020. /**
  64021. * Divides the current Vector3 coordinates by the given ones.
  64022. * @param otherVector defines the second operand
  64023. * @returns the current updated Vector3
  64024. */
  64025. divideInPlace(otherVector: Vector3): Vector3;
  64026. /**
  64027. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64028. * @param other defines the second operand
  64029. * @returns the current updated Vector3
  64030. */
  64031. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64032. /**
  64033. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64034. * @param other defines the second operand
  64035. * @returns the current updated Vector3
  64036. */
  64037. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64038. /**
  64039. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64040. * @param x defines the x coordinate of the operand
  64041. * @param y defines the y coordinate of the operand
  64042. * @param z defines the z coordinate of the operand
  64043. * @returns the current updated Vector3
  64044. */
  64045. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64046. /**
  64047. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64048. * @param x defines the x coordinate of the operand
  64049. * @param y defines the y coordinate of the operand
  64050. * @param z defines the z coordinate of the operand
  64051. * @returns the current updated Vector3
  64052. */
  64053. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64054. /**
  64055. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64056. * Check if is non uniform within a certain amount of decimal places to account for this
  64057. * @param epsilon the amount the values can differ
  64058. * @returns if the the vector is non uniform to a certain number of decimal places
  64059. */
  64060. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64061. /**
  64062. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64063. */
  64064. readonly isNonUniform: boolean;
  64065. /**
  64066. * Gets a new Vector3 from current Vector3 floored values
  64067. * @returns a new Vector3
  64068. */
  64069. floor(): Vector3;
  64070. /**
  64071. * Gets a new Vector3 from current Vector3 floored values
  64072. * @returns a new Vector3
  64073. */
  64074. fract(): Vector3;
  64075. /**
  64076. * Gets the length of the Vector3
  64077. * @returns the length of the Vector3
  64078. */
  64079. length(): number;
  64080. /**
  64081. * Gets the squared length of the Vector3
  64082. * @returns squared length of the Vector3
  64083. */
  64084. lengthSquared(): number;
  64085. /**
  64086. * Normalize the current Vector3.
  64087. * Please note that this is an in place operation.
  64088. * @returns the current updated Vector3
  64089. */
  64090. normalize(): Vector3;
  64091. /**
  64092. * Reorders the x y z properties of the vector in place
  64093. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64094. * @returns the current updated vector
  64095. */
  64096. reorderInPlace(order: string): this;
  64097. /**
  64098. * Rotates the vector around 0,0,0 by a quaternion
  64099. * @param quaternion the rotation quaternion
  64100. * @param result vector to store the result
  64101. * @returns the resulting vector
  64102. */
  64103. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64104. /**
  64105. * Rotates a vector around a given point
  64106. * @param quaternion the rotation quaternion
  64107. * @param point the point to rotate around
  64108. * @param result vector to store the result
  64109. * @returns the resulting vector
  64110. */
  64111. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64112. /**
  64113. * Normalize the current Vector3 with the given input length.
  64114. * Please note that this is an in place operation.
  64115. * @param len the length of the vector
  64116. * @returns the current updated Vector3
  64117. */
  64118. normalizeFromLength(len: number): Vector3;
  64119. /**
  64120. * Normalize the current Vector3 to a new vector
  64121. * @returns the new Vector3
  64122. */
  64123. normalizeToNew(): Vector3;
  64124. /**
  64125. * Normalize the current Vector3 to the reference
  64126. * @param reference define the Vector3 to update
  64127. * @returns the updated Vector3
  64128. */
  64129. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64130. /**
  64131. * Creates a new Vector3 copied from the current Vector3
  64132. * @returns the new Vector3
  64133. */
  64134. clone(): Vector3;
  64135. /**
  64136. * Copies the given vector coordinates to the current Vector3 ones
  64137. * @param source defines the source Vector3
  64138. * @returns the current updated Vector3
  64139. */
  64140. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64141. /**
  64142. * Copies the given floats to the current Vector3 coordinates
  64143. * @param x defines the x coordinate of the operand
  64144. * @param y defines the y coordinate of the operand
  64145. * @param z defines the z coordinate of the operand
  64146. * @returns the current updated Vector3
  64147. */
  64148. copyFromFloats(x: number, y: number, z: number): Vector3;
  64149. /**
  64150. * Copies the given floats to the current Vector3 coordinates
  64151. * @param x defines the x coordinate of the operand
  64152. * @param y defines the y coordinate of the operand
  64153. * @param z defines the z coordinate of the operand
  64154. * @returns the current updated Vector3
  64155. */
  64156. set(x: number, y: number, z: number): Vector3;
  64157. /**
  64158. * Copies the given float to the current Vector3 coordinates
  64159. * @param v defines the x, y and z coordinates of the operand
  64160. * @returns the current updated Vector3
  64161. */
  64162. setAll(v: number): Vector3;
  64163. /**
  64164. * Get the clip factor between two vectors
  64165. * @param vector0 defines the first operand
  64166. * @param vector1 defines the second operand
  64167. * @param axis defines the axis to use
  64168. * @param size defines the size along the axis
  64169. * @returns the clip factor
  64170. */
  64171. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64172. /**
  64173. * Get angle between two vectors
  64174. * @param vector0 angle between vector0 and vector1
  64175. * @param vector1 angle between vector0 and vector1
  64176. * @param normal direction of the normal
  64177. * @return the angle between vector0 and vector1
  64178. */
  64179. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64180. /**
  64181. * Returns a new Vector3 set from the index "offset" of the given array
  64182. * @param array defines the source array
  64183. * @param offset defines the offset in the source array
  64184. * @returns the new Vector3
  64185. */
  64186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64187. /**
  64188. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64189. * This function is deprecated. Use FromArray instead
  64190. * @param array defines the source array
  64191. * @param offset defines the offset in the source array
  64192. * @returns the new Vector3
  64193. */
  64194. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64195. /**
  64196. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64197. * @param array defines the source array
  64198. * @param offset defines the offset in the source array
  64199. * @param result defines the Vector3 where to store the result
  64200. */
  64201. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64202. /**
  64203. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64204. * This function is deprecated. Use FromArrayToRef instead.
  64205. * @param array defines the source array
  64206. * @param offset defines the offset in the source array
  64207. * @param result defines the Vector3 where to store the result
  64208. */
  64209. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64210. /**
  64211. * Sets the given vector "result" with the given floats.
  64212. * @param x defines the x coordinate of the source
  64213. * @param y defines the y coordinate of the source
  64214. * @param z defines the z coordinate of the source
  64215. * @param result defines the Vector3 where to store the result
  64216. */
  64217. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64218. /**
  64219. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64220. * @returns a new empty Vector3
  64221. */
  64222. static Zero(): Vector3;
  64223. /**
  64224. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64225. * @returns a new unit Vector3
  64226. */
  64227. static One(): Vector3;
  64228. /**
  64229. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64230. * @returns a new up Vector3
  64231. */
  64232. static Up(): Vector3;
  64233. /**
  64234. * Gets a up Vector3 that must not be updated
  64235. */
  64236. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64237. /**
  64238. * Gets a zero Vector3 that must not be updated
  64239. */
  64240. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64241. /**
  64242. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64243. * @returns a new down Vector3
  64244. */
  64245. static Down(): Vector3;
  64246. /**
  64247. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64248. * @returns a new forward Vector3
  64249. */
  64250. static Forward(): Vector3;
  64251. /**
  64252. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64253. * @returns a new forward Vector3
  64254. */
  64255. static Backward(): Vector3;
  64256. /**
  64257. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64258. * @returns a new right Vector3
  64259. */
  64260. static Right(): Vector3;
  64261. /**
  64262. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64263. * @returns a new left Vector3
  64264. */
  64265. static Left(): Vector3;
  64266. /**
  64267. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64268. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64269. * @param vector defines the Vector3 to transform
  64270. * @param transformation defines the transformation matrix
  64271. * @returns the transformed Vector3
  64272. */
  64273. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64274. /**
  64275. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64276. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64277. * @param vector defines the Vector3 to transform
  64278. * @param transformation defines the transformation matrix
  64279. * @param result defines the Vector3 where to store the result
  64280. */
  64281. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64282. /**
  64283. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64284. * This method computes tranformed coordinates only, not transformed direction vectors
  64285. * @param x define the x coordinate of the source vector
  64286. * @param y define the y coordinate of the source vector
  64287. * @param z define the z coordinate of the source vector
  64288. * @param transformation defines the transformation matrix
  64289. * @param result defines the Vector3 where to store the result
  64290. */
  64291. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64292. /**
  64293. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64294. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64295. * @param vector defines the Vector3 to transform
  64296. * @param transformation defines the transformation matrix
  64297. * @returns the new Vector3
  64298. */
  64299. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64300. /**
  64301. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64302. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64303. * @param vector defines the Vector3 to transform
  64304. * @param transformation defines the transformation matrix
  64305. * @param result defines the Vector3 where to store the result
  64306. */
  64307. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64308. /**
  64309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64310. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64311. * @param x define the x coordinate of the source vector
  64312. * @param y define the y coordinate of the source vector
  64313. * @param z define the z coordinate of the source vector
  64314. * @param transformation defines the transformation matrix
  64315. * @param result defines the Vector3 where to store the result
  64316. */
  64317. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64318. /**
  64319. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64320. * @param value1 defines the first control point
  64321. * @param value2 defines the second control point
  64322. * @param value3 defines the third control point
  64323. * @param value4 defines the fourth control point
  64324. * @param amount defines the amount on the spline to use
  64325. * @returns the new Vector3
  64326. */
  64327. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64328. /**
  64329. * 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"
  64330. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64331. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64332. * @param value defines the current value
  64333. * @param min defines the lower range value
  64334. * @param max defines the upper range value
  64335. * @returns the new Vector3
  64336. */
  64337. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64338. /**
  64339. * 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"
  64340. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64341. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64342. * @param value defines the current value
  64343. * @param min defines the lower range value
  64344. * @param max defines the upper range value
  64345. * @param result defines the Vector3 where to store the result
  64346. */
  64347. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64348. /**
  64349. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64350. * @param value1 defines the first control point
  64351. * @param tangent1 defines the first tangent vector
  64352. * @param value2 defines the second control point
  64353. * @param tangent2 defines the second tangent vector
  64354. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64355. * @returns the new Vector3
  64356. */
  64357. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64358. /**
  64359. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64360. * @param start defines the start value
  64361. * @param end defines the end value
  64362. * @param amount max defines amount between both (between 0 and 1)
  64363. * @returns the new Vector3
  64364. */
  64365. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64366. /**
  64367. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64368. * @param start defines the start value
  64369. * @param end defines the end value
  64370. * @param amount max defines amount between both (between 0 and 1)
  64371. * @param result defines the Vector3 where to store the result
  64372. */
  64373. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64374. /**
  64375. * Returns the dot product (float) between the vectors "left" and "right"
  64376. * @param left defines the left operand
  64377. * @param right defines the right operand
  64378. * @returns the dot product
  64379. */
  64380. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64381. /**
  64382. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64383. * The cross product is then orthogonal to both "left" and "right"
  64384. * @param left defines the left operand
  64385. * @param right defines the right operand
  64386. * @returns the cross product
  64387. */
  64388. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64389. /**
  64390. * Sets the given vector "result" with the cross product of "left" and "right"
  64391. * The cross product is then orthogonal to both "left" and "right"
  64392. * @param left defines the left operand
  64393. * @param right defines the right operand
  64394. * @param result defines the Vector3 where to store the result
  64395. */
  64396. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64397. /**
  64398. * Returns a new Vector3 as the normalization of the given vector
  64399. * @param vector defines the Vector3 to normalize
  64400. * @returns the new Vector3
  64401. */
  64402. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64403. /**
  64404. * Sets the given vector "result" with the normalization of the given first vector
  64405. * @param vector defines the Vector3 to normalize
  64406. * @param result defines the Vector3 where to store the result
  64407. */
  64408. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64409. /**
  64410. * Project a Vector3 onto screen space
  64411. * @param vector defines the Vector3 to project
  64412. * @param world defines the world matrix to use
  64413. * @param transform defines the transform (view x projection) matrix to use
  64414. * @param viewport defines the screen viewport to use
  64415. * @returns the new Vector3
  64416. */
  64417. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64418. /** @hidden */
  64419. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64420. /**
  64421. * Unproject from screen space to object space
  64422. * @param source defines the screen space Vector3 to use
  64423. * @param viewportWidth defines the current width of the viewport
  64424. * @param viewportHeight defines the current height of the viewport
  64425. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64426. * @param transform defines the transform (view x projection) matrix to use
  64427. * @returns the new Vector3
  64428. */
  64429. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64430. /**
  64431. * Unproject from screen space to object space
  64432. * @param source defines the screen space Vector3 to use
  64433. * @param viewportWidth defines the current width of the viewport
  64434. * @param viewportHeight defines the current height of the viewport
  64435. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64436. * @param view defines the view matrix to use
  64437. * @param projection defines the projection matrix to use
  64438. * @returns the new Vector3
  64439. */
  64440. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64441. /**
  64442. * Unproject from screen space to object space
  64443. * @param source defines the screen space Vector3 to use
  64444. * @param viewportWidth defines the current width of the viewport
  64445. * @param viewportHeight defines the current height of the viewport
  64446. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64447. * @param view defines the view matrix to use
  64448. * @param projection defines the projection matrix to use
  64449. * @param result defines the Vector3 where to store the result
  64450. */
  64451. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64452. /**
  64453. * Unproject from screen space to object space
  64454. * @param sourceX defines the screen space x coordinate to use
  64455. * @param sourceY defines the screen space y coordinate to use
  64456. * @param sourceZ defines the screen space z coordinate to use
  64457. * @param viewportWidth defines the current width of the viewport
  64458. * @param viewportHeight defines the current height of the viewport
  64459. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64460. * @param view defines the view matrix to use
  64461. * @param projection defines the projection matrix to use
  64462. * @param result defines the Vector3 where to store the result
  64463. */
  64464. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64465. /**
  64466. * Gets the minimal coordinate values between two Vector3
  64467. * @param left defines the first operand
  64468. * @param right defines the second operand
  64469. * @returns the new Vector3
  64470. */
  64471. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64472. /**
  64473. * Gets the maximal coordinate values between two Vector3
  64474. * @param left defines the first operand
  64475. * @param right defines the second operand
  64476. * @returns the new Vector3
  64477. */
  64478. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64479. /**
  64480. * Returns the distance between the vectors "value1" and "value2"
  64481. * @param value1 defines the first operand
  64482. * @param value2 defines the second operand
  64483. * @returns the distance
  64484. */
  64485. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64486. /**
  64487. * Returns the squared distance between the vectors "value1" and "value2"
  64488. * @param value1 defines the first operand
  64489. * @param value2 defines the second operand
  64490. * @returns the squared distance
  64491. */
  64492. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64493. /**
  64494. * Returns a new Vector3 located at the center between "value1" and "value2"
  64495. * @param value1 defines the first operand
  64496. * @param value2 defines the second operand
  64497. * @returns the new Vector3
  64498. */
  64499. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64500. /**
  64501. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64502. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64503. * to something in order to rotate it from its local system to the given target system
  64504. * Note: axis1, axis2 and axis3 are normalized during this operation
  64505. * @param axis1 defines the first axis
  64506. * @param axis2 defines the second axis
  64507. * @param axis3 defines the third axis
  64508. * @returns a new Vector3
  64509. */
  64510. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64511. /**
  64512. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64513. * @param axis1 defines the first axis
  64514. * @param axis2 defines the second axis
  64515. * @param axis3 defines the third axis
  64516. * @param ref defines the Vector3 where to store the result
  64517. */
  64518. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64519. }
  64520. /**
  64521. * Vector4 class created for EulerAngle class conversion to Quaternion
  64522. */
  64523. export class Vector4 {
  64524. /** x value of the vector */
  64525. x: number;
  64526. /** y value of the vector */
  64527. y: number;
  64528. /** z value of the vector */
  64529. z: number;
  64530. /** w value of the vector */
  64531. w: number;
  64532. /**
  64533. * Creates a Vector4 object from the given floats.
  64534. * @param x x value of the vector
  64535. * @param y y value of the vector
  64536. * @param z z value of the vector
  64537. * @param w w value of the vector
  64538. */
  64539. constructor(
  64540. /** x value of the vector */
  64541. x: number,
  64542. /** y value of the vector */
  64543. y: number,
  64544. /** z value of the vector */
  64545. z: number,
  64546. /** w value of the vector */
  64547. w: number);
  64548. /**
  64549. * Returns the string with the Vector4 coordinates.
  64550. * @returns a string containing all the vector values
  64551. */
  64552. toString(): string;
  64553. /**
  64554. * Returns the string "Vector4".
  64555. * @returns "Vector4"
  64556. */
  64557. getClassName(): string;
  64558. /**
  64559. * Returns the Vector4 hash code.
  64560. * @returns a unique hash code
  64561. */
  64562. getHashCode(): number;
  64563. /**
  64564. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64565. * @returns the resulting array
  64566. */
  64567. asArray(): number[];
  64568. /**
  64569. * Populates the given array from the given index with the Vector4 coordinates.
  64570. * @param array array to populate
  64571. * @param index index of the array to start at (default: 0)
  64572. * @returns the Vector4.
  64573. */
  64574. toArray(array: FloatArray, index?: number): Vector4;
  64575. /**
  64576. * Adds the given vector to the current Vector4.
  64577. * @param otherVector the vector to add
  64578. * @returns the updated Vector4.
  64579. */
  64580. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64581. /**
  64582. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64583. * @param otherVector the vector to add
  64584. * @returns the resulting vector
  64585. */
  64586. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64587. /**
  64588. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64589. * @param otherVector the vector to add
  64590. * @param result the vector to store the result
  64591. * @returns the current Vector4.
  64592. */
  64593. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64594. /**
  64595. * Subtract in place the given vector from the current Vector4.
  64596. * @param otherVector the vector to subtract
  64597. * @returns the updated Vector4.
  64598. */
  64599. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64600. /**
  64601. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64602. * @param otherVector the vector to add
  64603. * @returns the new vector with the result
  64604. */
  64605. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64606. /**
  64607. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64608. * @param otherVector the vector to subtract
  64609. * @param result the vector to store the result
  64610. * @returns the current Vector4.
  64611. */
  64612. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64613. /**
  64614. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64615. */
  64616. /**
  64617. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64618. * @param x value to subtract
  64619. * @param y value to subtract
  64620. * @param z value to subtract
  64621. * @param w value to subtract
  64622. * @returns new vector containing the result
  64623. */
  64624. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64625. /**
  64626. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64627. * @param x value to subtract
  64628. * @param y value to subtract
  64629. * @param z value to subtract
  64630. * @param w value to subtract
  64631. * @param result the vector to store the result in
  64632. * @returns the current Vector4.
  64633. */
  64634. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64635. /**
  64636. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64637. * @returns a new vector with the negated values
  64638. */
  64639. negate(): Vector4;
  64640. /**
  64641. * Multiplies the current Vector4 coordinates by scale (float).
  64642. * @param scale the number to scale with
  64643. * @returns the updated Vector4.
  64644. */
  64645. scaleInPlace(scale: number): Vector4;
  64646. /**
  64647. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64648. * @param scale the number to scale with
  64649. * @returns a new vector with the result
  64650. */
  64651. scale(scale: number): Vector4;
  64652. /**
  64653. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64654. * @param scale the number to scale with
  64655. * @param result a vector to store the result in
  64656. * @returns the current Vector4.
  64657. */
  64658. scaleToRef(scale: number, result: Vector4): Vector4;
  64659. /**
  64660. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64661. * @param scale defines the scale factor
  64662. * @param result defines the Vector4 object where to store the result
  64663. * @returns the unmodified current Vector4
  64664. */
  64665. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64666. /**
  64667. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64668. * @param otherVector the vector to compare against
  64669. * @returns true if they are equal
  64670. */
  64671. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64672. /**
  64673. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64674. * @param otherVector vector to compare against
  64675. * @param epsilon (Default: very small number)
  64676. * @returns true if they are equal
  64677. */
  64678. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64679. /**
  64680. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64681. * @param x x value to compare against
  64682. * @param y y value to compare against
  64683. * @param z z value to compare against
  64684. * @param w w value to compare against
  64685. * @returns true if equal
  64686. */
  64687. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64688. /**
  64689. * Multiplies in place the current Vector4 by the given one.
  64690. * @param otherVector vector to multiple with
  64691. * @returns the updated Vector4.
  64692. */
  64693. multiplyInPlace(otherVector: Vector4): Vector4;
  64694. /**
  64695. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64696. * @param otherVector vector to multiple with
  64697. * @returns resulting new vector
  64698. */
  64699. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64700. /**
  64701. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64702. * @param otherVector vector to multiple with
  64703. * @param result vector to store the result
  64704. * @returns the current Vector4.
  64705. */
  64706. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64707. /**
  64708. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64709. * @param x x value multiply with
  64710. * @param y y value multiply with
  64711. * @param z z value multiply with
  64712. * @param w w value multiply with
  64713. * @returns resulting new vector
  64714. */
  64715. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64716. /**
  64717. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64718. * @param otherVector vector to devide with
  64719. * @returns resulting new vector
  64720. */
  64721. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64722. /**
  64723. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64724. * @param otherVector vector to devide with
  64725. * @param result vector to store the result
  64726. * @returns the current Vector4.
  64727. */
  64728. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64729. /**
  64730. * Divides the current Vector3 coordinates by the given ones.
  64731. * @param otherVector vector to devide with
  64732. * @returns the updated Vector3.
  64733. */
  64734. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64735. /**
  64736. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64737. * @param other defines the second operand
  64738. * @returns the current updated Vector4
  64739. */
  64740. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64741. /**
  64742. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64743. * @param other defines the second operand
  64744. * @returns the current updated Vector4
  64745. */
  64746. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64747. /**
  64748. * Gets a new Vector4 from current Vector4 floored values
  64749. * @returns a new Vector4
  64750. */
  64751. floor(): Vector4;
  64752. /**
  64753. * Gets a new Vector4 from current Vector3 floored values
  64754. * @returns a new Vector4
  64755. */
  64756. fract(): Vector4;
  64757. /**
  64758. * Returns the Vector4 length (float).
  64759. * @returns the length
  64760. */
  64761. length(): number;
  64762. /**
  64763. * Returns the Vector4 squared length (float).
  64764. * @returns the length squared
  64765. */
  64766. lengthSquared(): number;
  64767. /**
  64768. * Normalizes in place the Vector4.
  64769. * @returns the updated Vector4.
  64770. */
  64771. normalize(): Vector4;
  64772. /**
  64773. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64774. * @returns this converted to a new vector3
  64775. */
  64776. toVector3(): Vector3;
  64777. /**
  64778. * Returns a new Vector4 copied from the current one.
  64779. * @returns the new cloned vector
  64780. */
  64781. clone(): Vector4;
  64782. /**
  64783. * Updates the current Vector4 with the given one coordinates.
  64784. * @param source the source vector to copy from
  64785. * @returns the updated Vector4.
  64786. */
  64787. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64788. /**
  64789. * Updates the current Vector4 coordinates with the given floats.
  64790. * @param x float to copy from
  64791. * @param y float to copy from
  64792. * @param z float to copy from
  64793. * @param w float to copy from
  64794. * @returns the updated Vector4.
  64795. */
  64796. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64797. /**
  64798. * Updates the current Vector4 coordinates with the given floats.
  64799. * @param x float to set from
  64800. * @param y float to set from
  64801. * @param z float to set from
  64802. * @param w float to set from
  64803. * @returns the updated Vector4.
  64804. */
  64805. set(x: number, y: number, z: number, w: number): Vector4;
  64806. /**
  64807. * Copies the given float to the current Vector3 coordinates
  64808. * @param v defines the x, y, z and w coordinates of the operand
  64809. * @returns the current updated Vector3
  64810. */
  64811. setAll(v: number): Vector4;
  64812. /**
  64813. * Returns a new Vector4 set from the starting index of the given array.
  64814. * @param array the array to pull values from
  64815. * @param offset the offset into the array to start at
  64816. * @returns the new vector
  64817. */
  64818. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64819. /**
  64820. * Updates the given vector "result" from the starting index of the given array.
  64821. * @param array the array to pull values from
  64822. * @param offset the offset into the array to start at
  64823. * @param result the vector to store the result in
  64824. */
  64825. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64826. /**
  64827. * Updates the given vector "result" from the starting index of the given Float32Array.
  64828. * @param array the array to pull values from
  64829. * @param offset the offset into the array to start at
  64830. * @param result the vector to store the result in
  64831. */
  64832. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64833. /**
  64834. * Updates the given vector "result" coordinates from the given floats.
  64835. * @param x float to set from
  64836. * @param y float to set from
  64837. * @param z float to set from
  64838. * @param w float to set from
  64839. * @param result the vector to the floats in
  64840. */
  64841. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64842. /**
  64843. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64844. * @returns the new vector
  64845. */
  64846. static Zero(): Vector4;
  64847. /**
  64848. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64849. * @returns the new vector
  64850. */
  64851. static One(): Vector4;
  64852. /**
  64853. * Returns a new normalized Vector4 from the given one.
  64854. * @param vector the vector to normalize
  64855. * @returns the vector
  64856. */
  64857. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64858. /**
  64859. * Updates the given vector "result" from the normalization of the given one.
  64860. * @param vector the vector to normalize
  64861. * @param result the vector to store the result in
  64862. */
  64863. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64864. /**
  64865. * Returns a vector with the minimum values from the left and right vectors
  64866. * @param left left vector to minimize
  64867. * @param right right vector to minimize
  64868. * @returns a new vector with the minimum of the left and right vector values
  64869. */
  64870. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64871. /**
  64872. * Returns a vector with the maximum values from the left and right vectors
  64873. * @param left left vector to maximize
  64874. * @param right right vector to maximize
  64875. * @returns a new vector with the maximum of the left and right vector values
  64876. */
  64877. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64878. /**
  64879. * Returns the distance (float) between the vectors "value1" and "value2".
  64880. * @param value1 value to calulate the distance between
  64881. * @param value2 value to calulate the distance between
  64882. * @return the distance between the two vectors
  64883. */
  64884. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64885. /**
  64886. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64887. * @param value1 value to calulate the distance between
  64888. * @param value2 value to calulate the distance between
  64889. * @return the distance between the two vectors squared
  64890. */
  64891. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64892. /**
  64893. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64894. * @param value1 value to calulate the center between
  64895. * @param value2 value to calulate the center between
  64896. * @return the center between the two vectors
  64897. */
  64898. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64899. /**
  64900. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64901. * This methods computes transformed normalized direction vectors only.
  64902. * @param vector the vector to transform
  64903. * @param transformation the transformation matrix to apply
  64904. * @returns the new vector
  64905. */
  64906. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64907. /**
  64908. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64909. * This methods computes transformed normalized direction vectors only.
  64910. * @param vector the vector to transform
  64911. * @param transformation the transformation matrix to apply
  64912. * @param result the vector to store the result in
  64913. */
  64914. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64915. /**
  64916. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64917. * This methods computes transformed normalized direction vectors only.
  64918. * @param x value to transform
  64919. * @param y value to transform
  64920. * @param z value to transform
  64921. * @param w value to transform
  64922. * @param transformation the transformation matrix to apply
  64923. * @param result the vector to store the results in
  64924. */
  64925. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64926. /**
  64927. * Creates a new Vector4 from a Vector3
  64928. * @param source defines the source data
  64929. * @param w defines the 4th component (default is 0)
  64930. * @returns a new Vector4
  64931. */
  64932. static FromVector3(source: Vector3, w?: number): Vector4;
  64933. }
  64934. /**
  64935. * Interface for the size containing width and height
  64936. */
  64937. export interface ISize {
  64938. /**
  64939. * Width
  64940. */
  64941. width: number;
  64942. /**
  64943. * Heighht
  64944. */
  64945. height: number;
  64946. }
  64947. /**
  64948. * Size containing widht and height
  64949. */
  64950. export class Size implements ISize {
  64951. /**
  64952. * Width
  64953. */
  64954. width: number;
  64955. /**
  64956. * Height
  64957. */
  64958. height: number;
  64959. /**
  64960. * Creates a Size object from the given width and height (floats).
  64961. * @param width width of the new size
  64962. * @param height height of the new size
  64963. */
  64964. constructor(width: number, height: number);
  64965. /**
  64966. * Returns a string with the Size width and height
  64967. * @returns a string with the Size width and height
  64968. */
  64969. toString(): string;
  64970. /**
  64971. * "Size"
  64972. * @returns the string "Size"
  64973. */
  64974. getClassName(): string;
  64975. /**
  64976. * Returns the Size hash code.
  64977. * @returns a hash code for a unique width and height
  64978. */
  64979. getHashCode(): number;
  64980. /**
  64981. * Updates the current size from the given one.
  64982. * @param src the given size
  64983. */
  64984. copyFrom(src: Size): void;
  64985. /**
  64986. * Updates in place the current Size from the given floats.
  64987. * @param width width of the new size
  64988. * @param height height of the new size
  64989. * @returns the updated Size.
  64990. */
  64991. copyFromFloats(width: number, height: number): Size;
  64992. /**
  64993. * Updates in place the current Size from the given floats.
  64994. * @param width width to set
  64995. * @param height height to set
  64996. * @returns the updated Size.
  64997. */
  64998. set(width: number, height: number): Size;
  64999. /**
  65000. * Multiplies the width and height by numbers
  65001. * @param w factor to multiple the width by
  65002. * @param h factor to multiple the height by
  65003. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65004. */
  65005. multiplyByFloats(w: number, h: number): Size;
  65006. /**
  65007. * Clones the size
  65008. * @returns a new Size copied from the given one.
  65009. */
  65010. clone(): Size;
  65011. /**
  65012. * True if the current Size and the given one width and height are strictly equal.
  65013. * @param other the other size to compare against
  65014. * @returns True if the current Size and the given one width and height are strictly equal.
  65015. */
  65016. equals(other: Size): boolean;
  65017. /**
  65018. * The surface of the Size : width * height (float).
  65019. */
  65020. readonly surface: number;
  65021. /**
  65022. * Create a new size of zero
  65023. * @returns a new Size set to (0.0, 0.0)
  65024. */
  65025. static Zero(): Size;
  65026. /**
  65027. * Sums the width and height of two sizes
  65028. * @param otherSize size to add to this size
  65029. * @returns a new Size set as the addition result of the current Size and the given one.
  65030. */
  65031. add(otherSize: Size): Size;
  65032. /**
  65033. * Subtracts the width and height of two
  65034. * @param otherSize size to subtract to this size
  65035. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65036. */
  65037. subtract(otherSize: Size): Size;
  65038. /**
  65039. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65040. * @param start starting size to lerp between
  65041. * @param end end size to lerp between
  65042. * @param amount amount to lerp between the start and end values
  65043. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65044. */
  65045. static Lerp(start: Size, end: Size, amount: number): Size;
  65046. }
  65047. /**
  65048. * Class used to store quaternion data
  65049. * @see https://en.wikipedia.org/wiki/Quaternion
  65050. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65051. */
  65052. export class Quaternion {
  65053. /** defines the first component (0 by default) */
  65054. x: number;
  65055. /** defines the second component (0 by default) */
  65056. y: number;
  65057. /** defines the third component (0 by default) */
  65058. z: number;
  65059. /** defines the fourth component (1.0 by default) */
  65060. w: number;
  65061. /**
  65062. * Creates a new Quaternion from the given floats
  65063. * @param x defines the first component (0 by default)
  65064. * @param y defines the second component (0 by default)
  65065. * @param z defines the third component (0 by default)
  65066. * @param w defines the fourth component (1.0 by default)
  65067. */
  65068. constructor(
  65069. /** defines the first component (0 by default) */
  65070. x?: number,
  65071. /** defines the second component (0 by default) */
  65072. y?: number,
  65073. /** defines the third component (0 by default) */
  65074. z?: number,
  65075. /** defines the fourth component (1.0 by default) */
  65076. w?: number);
  65077. /**
  65078. * Gets a string representation for the current quaternion
  65079. * @returns a string with the Quaternion coordinates
  65080. */
  65081. toString(): string;
  65082. /**
  65083. * Gets the class name of the quaternion
  65084. * @returns the string "Quaternion"
  65085. */
  65086. getClassName(): string;
  65087. /**
  65088. * Gets a hash code for this quaternion
  65089. * @returns the quaternion hash code
  65090. */
  65091. getHashCode(): number;
  65092. /**
  65093. * Copy the quaternion to an array
  65094. * @returns a new array populated with 4 elements from the quaternion coordinates
  65095. */
  65096. asArray(): number[];
  65097. /**
  65098. * Check if two quaternions are equals
  65099. * @param otherQuaternion defines the second operand
  65100. * @return true if the current quaternion and the given one coordinates are strictly equals
  65101. */
  65102. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65103. /**
  65104. * Clone the current quaternion
  65105. * @returns a new quaternion copied from the current one
  65106. */
  65107. clone(): Quaternion;
  65108. /**
  65109. * Copy a quaternion to the current one
  65110. * @param other defines the other quaternion
  65111. * @returns the updated current quaternion
  65112. */
  65113. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65114. /**
  65115. * Updates the current quaternion with the given float coordinates
  65116. * @param x defines the x coordinate
  65117. * @param y defines the y coordinate
  65118. * @param z defines the z coordinate
  65119. * @param w defines the w coordinate
  65120. * @returns the updated current quaternion
  65121. */
  65122. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65123. /**
  65124. * Updates the current quaternion from the given float coordinates
  65125. * @param x defines the x coordinate
  65126. * @param y defines the y coordinate
  65127. * @param z defines the z coordinate
  65128. * @param w defines the w coordinate
  65129. * @returns the updated current quaternion
  65130. */
  65131. set(x: number, y: number, z: number, w: number): Quaternion;
  65132. /**
  65133. * Adds two quaternions
  65134. * @param other defines the second operand
  65135. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65136. */
  65137. add(other: DeepImmutable<Quaternion>): Quaternion;
  65138. /**
  65139. * Add a quaternion to the current one
  65140. * @param other defines the quaternion to add
  65141. * @returns the current quaternion
  65142. */
  65143. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65144. /**
  65145. * Subtract two quaternions
  65146. * @param other defines the second operand
  65147. * @returns a new quaternion as the subtraction result of the given one from the current one
  65148. */
  65149. subtract(other: Quaternion): Quaternion;
  65150. /**
  65151. * Multiplies the current quaternion by a scale factor
  65152. * @param value defines the scale factor
  65153. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65154. */
  65155. scale(value: number): Quaternion;
  65156. /**
  65157. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65158. * @param scale defines the scale factor
  65159. * @param result defines the Quaternion object where to store the result
  65160. * @returns the unmodified current quaternion
  65161. */
  65162. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65163. /**
  65164. * Multiplies in place the current quaternion by a scale factor
  65165. * @param value defines the scale factor
  65166. * @returns the current modified quaternion
  65167. */
  65168. scaleInPlace(value: number): Quaternion;
  65169. /**
  65170. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65171. * @param scale defines the scale factor
  65172. * @param result defines the Quaternion object where to store the result
  65173. * @returns the unmodified current quaternion
  65174. */
  65175. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65176. /**
  65177. * Multiplies two quaternions
  65178. * @param q1 defines the second operand
  65179. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65180. */
  65181. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65182. /**
  65183. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65184. * @param q1 defines the second operand
  65185. * @param result defines the target quaternion
  65186. * @returns the current quaternion
  65187. */
  65188. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65189. /**
  65190. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65191. * @param q1 defines the second operand
  65192. * @returns the currentupdated quaternion
  65193. */
  65194. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65195. /**
  65196. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65197. * @param ref defines the target quaternion
  65198. * @returns the current quaternion
  65199. */
  65200. conjugateToRef(ref: Quaternion): Quaternion;
  65201. /**
  65202. * Conjugates in place (1-q) the current quaternion
  65203. * @returns the current updated quaternion
  65204. */
  65205. conjugateInPlace(): Quaternion;
  65206. /**
  65207. * Conjugates in place (1-q) the current quaternion
  65208. * @returns a new quaternion
  65209. */
  65210. conjugate(): Quaternion;
  65211. /**
  65212. * Gets length of current quaternion
  65213. * @returns the quaternion length (float)
  65214. */
  65215. length(): number;
  65216. /**
  65217. * Normalize in place the current quaternion
  65218. * @returns the current updated quaternion
  65219. */
  65220. normalize(): Quaternion;
  65221. /**
  65222. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65223. * @param order is a reserved parameter and is ignore for now
  65224. * @returns a new Vector3 containing the Euler angles
  65225. */
  65226. toEulerAngles(order?: string): Vector3;
  65227. /**
  65228. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65229. * @param result defines the vector which will be filled with the Euler angles
  65230. * @param order is a reserved parameter and is ignore for now
  65231. * @returns the current unchanged quaternion
  65232. */
  65233. toEulerAnglesToRef(result: Vector3): Quaternion;
  65234. /**
  65235. * Updates the given rotation matrix with the current quaternion values
  65236. * @param result defines the target matrix
  65237. * @returns the current unchanged quaternion
  65238. */
  65239. toRotationMatrix(result: Matrix): Quaternion;
  65240. /**
  65241. * Updates the current quaternion from the given rotation matrix values
  65242. * @param matrix defines the source matrix
  65243. * @returns the current updated quaternion
  65244. */
  65245. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65246. /**
  65247. * Creates a new quaternion from a rotation matrix
  65248. * @param matrix defines the source matrix
  65249. * @returns a new quaternion created from the given rotation matrix values
  65250. */
  65251. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65252. /**
  65253. * Updates the given quaternion with the given rotation matrix values
  65254. * @param matrix defines the source matrix
  65255. * @param result defines the target quaternion
  65256. */
  65257. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65258. /**
  65259. * Returns the dot product (float) between the quaternions "left" and "right"
  65260. * @param left defines the left operand
  65261. * @param right defines the right operand
  65262. * @returns the dot product
  65263. */
  65264. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65265. /**
  65266. * Checks if the two quaternions are close to each other
  65267. * @param quat0 defines the first quaternion to check
  65268. * @param quat1 defines the second quaternion to check
  65269. * @returns true if the two quaternions are close to each other
  65270. */
  65271. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65272. /**
  65273. * Creates an empty quaternion
  65274. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65275. */
  65276. static Zero(): Quaternion;
  65277. /**
  65278. * Inverse a given quaternion
  65279. * @param q defines the source quaternion
  65280. * @returns a new quaternion as the inverted current quaternion
  65281. */
  65282. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65283. /**
  65284. * Inverse a given quaternion
  65285. * @param q defines the source quaternion
  65286. * @param result the quaternion the result will be stored in
  65287. * @returns the result quaternion
  65288. */
  65289. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65290. /**
  65291. * Creates an identity quaternion
  65292. * @returns the identity quaternion
  65293. */
  65294. static Identity(): Quaternion;
  65295. /**
  65296. * Gets a boolean indicating if the given quaternion is identity
  65297. * @param quaternion defines the quaternion to check
  65298. * @returns true if the quaternion is identity
  65299. */
  65300. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65301. /**
  65302. * Creates a quaternion from a rotation around an axis
  65303. * @param axis defines the axis to use
  65304. * @param angle defines the angle to use
  65305. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65306. */
  65307. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65308. /**
  65309. * Creates a rotation around an axis and stores it into the given quaternion
  65310. * @param axis defines the axis to use
  65311. * @param angle defines the angle to use
  65312. * @param result defines the target quaternion
  65313. * @returns the target quaternion
  65314. */
  65315. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65316. /**
  65317. * Creates a new quaternion from data stored into an array
  65318. * @param array defines the data source
  65319. * @param offset defines the offset in the source array where the data starts
  65320. * @returns a new quaternion
  65321. */
  65322. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65323. /**
  65324. * Create a quaternion from Euler rotation angles
  65325. * @param x Pitch
  65326. * @param y Yaw
  65327. * @param z Roll
  65328. * @returns the new Quaternion
  65329. */
  65330. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65331. /**
  65332. * Updates a quaternion from Euler rotation angles
  65333. * @param x Pitch
  65334. * @param y Yaw
  65335. * @param z Roll
  65336. * @param result the quaternion to store the result
  65337. * @returns the updated quaternion
  65338. */
  65339. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65340. /**
  65341. * Create a quaternion from Euler rotation vector
  65342. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65343. * @returns the new Quaternion
  65344. */
  65345. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65346. /**
  65347. * Updates a quaternion from Euler rotation vector
  65348. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65349. * @param result the quaternion to store the result
  65350. * @returns the updated quaternion
  65351. */
  65352. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65353. /**
  65354. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65355. * @param yaw defines the rotation around Y axis
  65356. * @param pitch defines the rotation around X axis
  65357. * @param roll defines the rotation around Z axis
  65358. * @returns the new quaternion
  65359. */
  65360. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65361. /**
  65362. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65363. * @param yaw defines the rotation around Y axis
  65364. * @param pitch defines the rotation around X axis
  65365. * @param roll defines the rotation around Z axis
  65366. * @param result defines the target quaternion
  65367. */
  65368. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65369. /**
  65370. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65371. * @param alpha defines the rotation around first axis
  65372. * @param beta defines the rotation around second axis
  65373. * @param gamma defines the rotation around third axis
  65374. * @returns the new quaternion
  65375. */
  65376. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65377. /**
  65378. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65379. * @param alpha defines the rotation around first axis
  65380. * @param beta defines the rotation around second axis
  65381. * @param gamma defines the rotation around third axis
  65382. * @param result defines the target quaternion
  65383. */
  65384. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65385. /**
  65386. * 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)
  65387. * @param axis1 defines the first axis
  65388. * @param axis2 defines the second axis
  65389. * @param axis3 defines the third axis
  65390. * @returns the new quaternion
  65391. */
  65392. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65393. /**
  65394. * 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
  65395. * @param axis1 defines the first axis
  65396. * @param axis2 defines the second axis
  65397. * @param axis3 defines the third axis
  65398. * @param ref defines the target quaternion
  65399. */
  65400. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65401. /**
  65402. * Interpolates between two quaternions
  65403. * @param left defines first quaternion
  65404. * @param right defines second quaternion
  65405. * @param amount defines the gradient to use
  65406. * @returns the new interpolated quaternion
  65407. */
  65408. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65409. /**
  65410. * Interpolates between two quaternions and stores it into a target quaternion
  65411. * @param left defines first quaternion
  65412. * @param right defines second quaternion
  65413. * @param amount defines the gradient to use
  65414. * @param result defines the target quaternion
  65415. */
  65416. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65417. /**
  65418. * Interpolate between two quaternions using Hermite interpolation
  65419. * @param value1 defines first quaternion
  65420. * @param tangent1 defines the incoming tangent
  65421. * @param value2 defines second quaternion
  65422. * @param tangent2 defines the outgoing tangent
  65423. * @param amount defines the target quaternion
  65424. * @returns the new interpolated quaternion
  65425. */
  65426. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65427. }
  65428. /**
  65429. * Class used to store matrix data (4x4)
  65430. */
  65431. export class Matrix {
  65432. private static _updateFlagSeed;
  65433. private static _identityReadOnly;
  65434. private _isIdentity;
  65435. private _isIdentityDirty;
  65436. private _isIdentity3x2;
  65437. private _isIdentity3x2Dirty;
  65438. /**
  65439. * Gets the update flag of the matrix which is an unique number for the matrix.
  65440. * It will be incremented every time the matrix data change.
  65441. * You can use it to speed the comparison between two versions of the same matrix.
  65442. */
  65443. updateFlag: number;
  65444. private readonly _m;
  65445. /**
  65446. * Gets the internal data of the matrix
  65447. */
  65448. readonly m: DeepImmutable<Float32Array>;
  65449. /** @hidden */
  65450. _markAsUpdated(): void;
  65451. /** @hidden */
  65452. private _updateIdentityStatus;
  65453. /**
  65454. * Creates an empty matrix (filled with zeros)
  65455. */
  65456. constructor();
  65457. /**
  65458. * Check if the current matrix is identity
  65459. * @returns true is the matrix is the identity matrix
  65460. */
  65461. isIdentity(): boolean;
  65462. /**
  65463. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65464. * @returns true is the matrix is the identity matrix
  65465. */
  65466. isIdentityAs3x2(): boolean;
  65467. /**
  65468. * Gets the determinant of the matrix
  65469. * @returns the matrix determinant
  65470. */
  65471. determinant(): number;
  65472. /**
  65473. * Returns the matrix as a Float32Array
  65474. * @returns the matrix underlying array
  65475. */
  65476. toArray(): DeepImmutable<Float32Array>;
  65477. /**
  65478. * Returns the matrix as a Float32Array
  65479. * @returns the matrix underlying array.
  65480. */
  65481. asArray(): DeepImmutable<Float32Array>;
  65482. /**
  65483. * Inverts the current matrix in place
  65484. * @returns the current inverted matrix
  65485. */
  65486. invert(): Matrix;
  65487. /**
  65488. * Sets all the matrix elements to zero
  65489. * @returns the current matrix
  65490. */
  65491. reset(): Matrix;
  65492. /**
  65493. * Adds the current matrix with a second one
  65494. * @param other defines the matrix to add
  65495. * @returns a new matrix as the addition of the current matrix and the given one
  65496. */
  65497. add(other: DeepImmutable<Matrix>): Matrix;
  65498. /**
  65499. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65500. * @param other defines the matrix to add
  65501. * @param result defines the target matrix
  65502. * @returns the current matrix
  65503. */
  65504. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65505. /**
  65506. * Adds in place the given matrix to the current matrix
  65507. * @param other defines the second operand
  65508. * @returns the current updated matrix
  65509. */
  65510. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65511. /**
  65512. * Sets the given matrix to the current inverted Matrix
  65513. * @param other defines the target matrix
  65514. * @returns the unmodified current matrix
  65515. */
  65516. invertToRef(other: Matrix): Matrix;
  65517. /**
  65518. * add a value at the specified position in the current Matrix
  65519. * @param index the index of the value within the matrix. between 0 and 15.
  65520. * @param value the value to be added
  65521. * @returns the current updated matrix
  65522. */
  65523. addAtIndex(index: number, value: number): Matrix;
  65524. /**
  65525. * mutiply the specified position in the current Matrix by a value
  65526. * @param index the index of the value within the matrix. between 0 and 15.
  65527. * @param value the value to be added
  65528. * @returns the current updated matrix
  65529. */
  65530. multiplyAtIndex(index: number, value: number): Matrix;
  65531. /**
  65532. * Inserts the translation vector (using 3 floats) in the current matrix
  65533. * @param x defines the 1st component of the translation
  65534. * @param y defines the 2nd component of the translation
  65535. * @param z defines the 3rd component of the translation
  65536. * @returns the current updated matrix
  65537. */
  65538. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65539. /**
  65540. * Adds the translation vector (using 3 floats) in the current matrix
  65541. * @param x defines the 1st component of the translation
  65542. * @param y defines the 2nd component of the translation
  65543. * @param z defines the 3rd component of the translation
  65544. * @returns the current updated matrix
  65545. */
  65546. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65547. /**
  65548. * Inserts the translation vector in the current matrix
  65549. * @param vector3 defines the translation to insert
  65550. * @returns the current updated matrix
  65551. */
  65552. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65553. /**
  65554. * Gets the translation value of the current matrix
  65555. * @returns a new Vector3 as the extracted translation from the matrix
  65556. */
  65557. getTranslation(): Vector3;
  65558. /**
  65559. * Fill a Vector3 with the extracted translation from the matrix
  65560. * @param result defines the Vector3 where to store the translation
  65561. * @returns the current matrix
  65562. */
  65563. getTranslationToRef(result: Vector3): Matrix;
  65564. /**
  65565. * Remove rotation and scaling part from the matrix
  65566. * @returns the updated matrix
  65567. */
  65568. removeRotationAndScaling(): Matrix;
  65569. /**
  65570. * Multiply two matrices
  65571. * @param other defines the second operand
  65572. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65573. */
  65574. multiply(other: DeepImmutable<Matrix>): Matrix;
  65575. /**
  65576. * Copy the current matrix from the given one
  65577. * @param other defines the source matrix
  65578. * @returns the current updated matrix
  65579. */
  65580. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65581. /**
  65582. * Populates the given array from the starting index with the current matrix values
  65583. * @param array defines the target array
  65584. * @param offset defines the offset in the target array where to start storing values
  65585. * @returns the current matrix
  65586. */
  65587. copyToArray(array: Float32Array, offset?: number): Matrix;
  65588. /**
  65589. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65590. * @param other defines the second operand
  65591. * @param result defines the matrix where to store the multiplication
  65592. * @returns the current matrix
  65593. */
  65594. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65595. /**
  65596. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65597. * @param other defines the second operand
  65598. * @param result defines the array where to store the multiplication
  65599. * @param offset defines the offset in the target array where to start storing values
  65600. * @returns the current matrix
  65601. */
  65602. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65603. /**
  65604. * Check equality between this matrix and a second one
  65605. * @param value defines the second matrix to compare
  65606. * @returns true is the current matrix and the given one values are strictly equal
  65607. */
  65608. equals(value: DeepImmutable<Matrix>): boolean;
  65609. /**
  65610. * Clone the current matrix
  65611. * @returns a new matrix from the current matrix
  65612. */
  65613. clone(): Matrix;
  65614. /**
  65615. * Returns the name of the current matrix class
  65616. * @returns the string "Matrix"
  65617. */
  65618. getClassName(): string;
  65619. /**
  65620. * Gets the hash code of the current matrix
  65621. * @returns the hash code
  65622. */
  65623. getHashCode(): number;
  65624. /**
  65625. * Decomposes the current Matrix into a translation, rotation and scaling components
  65626. * @param scale defines the scale vector3 given as a reference to update
  65627. * @param rotation defines the rotation quaternion given as a reference to update
  65628. * @param translation defines the translation vector3 given as a reference to update
  65629. * @returns true if operation was successful
  65630. */
  65631. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65632. /**
  65633. * Gets specific row of the matrix
  65634. * @param index defines the number of the row to get
  65635. * @returns the index-th row of the current matrix as a new Vector4
  65636. */
  65637. getRow(index: number): Nullable<Vector4>;
  65638. /**
  65639. * Sets the index-th row of the current matrix to the vector4 values
  65640. * @param index defines the number of the row to set
  65641. * @param row defines the target vector4
  65642. * @returns the updated current matrix
  65643. */
  65644. setRow(index: number, row: Vector4): Matrix;
  65645. /**
  65646. * Compute the transpose of the matrix
  65647. * @returns the new transposed matrix
  65648. */
  65649. transpose(): Matrix;
  65650. /**
  65651. * Compute the transpose of the matrix and store it in a given matrix
  65652. * @param result defines the target matrix
  65653. * @returns the current matrix
  65654. */
  65655. transposeToRef(result: Matrix): Matrix;
  65656. /**
  65657. * Sets the index-th row of the current matrix with the given 4 x float values
  65658. * @param index defines the row index
  65659. * @param x defines the x component to set
  65660. * @param y defines the y component to set
  65661. * @param z defines the z component to set
  65662. * @param w defines the w component to set
  65663. * @returns the updated current matrix
  65664. */
  65665. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65666. /**
  65667. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65668. * @param scale defines the scale factor
  65669. * @returns a new matrix
  65670. */
  65671. scale(scale: number): Matrix;
  65672. /**
  65673. * Scale the current matrix values by a factor to a given result matrix
  65674. * @param scale defines the scale factor
  65675. * @param result defines the matrix to store the result
  65676. * @returns the current matrix
  65677. */
  65678. scaleToRef(scale: number, result: Matrix): Matrix;
  65679. /**
  65680. * Scale the current matrix values by a factor and add the result to a given matrix
  65681. * @param scale defines the scale factor
  65682. * @param result defines the Matrix to store the result
  65683. * @returns the current matrix
  65684. */
  65685. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65686. /**
  65687. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65688. * @param ref matrix to store the result
  65689. */
  65690. toNormalMatrix(ref: Matrix): void;
  65691. /**
  65692. * Gets only rotation part of the current matrix
  65693. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65694. */
  65695. getRotationMatrix(): Matrix;
  65696. /**
  65697. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65698. * @param result defines the target matrix to store data to
  65699. * @returns the current matrix
  65700. */
  65701. getRotationMatrixToRef(result: Matrix): Matrix;
  65702. /**
  65703. * Toggles model matrix from being right handed to left handed in place and vice versa
  65704. */
  65705. toggleModelMatrixHandInPlace(): void;
  65706. /**
  65707. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65708. */
  65709. toggleProjectionMatrixHandInPlace(): void;
  65710. /**
  65711. * Creates a matrix from an array
  65712. * @param array defines the source array
  65713. * @param offset defines an offset in the source array
  65714. * @returns a new Matrix set from the starting index of the given array
  65715. */
  65716. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65717. /**
  65718. * Copy the content of an array into a given matrix
  65719. * @param array defines the source array
  65720. * @param offset defines an offset in the source array
  65721. * @param result defines the target matrix
  65722. */
  65723. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65724. /**
  65725. * Stores an array into a matrix after having multiplied each component by a given factor
  65726. * @param array defines the source array
  65727. * @param offset defines the offset in the source array
  65728. * @param scale defines the scaling factor
  65729. * @param result defines the target matrix
  65730. */
  65731. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65732. /**
  65733. * Gets an identity matrix that must not be updated
  65734. */
  65735. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65736. /**
  65737. * Stores a list of values (16) inside a given matrix
  65738. * @param initialM11 defines 1st value of 1st row
  65739. * @param initialM12 defines 2nd value of 1st row
  65740. * @param initialM13 defines 3rd value of 1st row
  65741. * @param initialM14 defines 4th value of 1st row
  65742. * @param initialM21 defines 1st value of 2nd row
  65743. * @param initialM22 defines 2nd value of 2nd row
  65744. * @param initialM23 defines 3rd value of 2nd row
  65745. * @param initialM24 defines 4th value of 2nd row
  65746. * @param initialM31 defines 1st value of 3rd row
  65747. * @param initialM32 defines 2nd value of 3rd row
  65748. * @param initialM33 defines 3rd value of 3rd row
  65749. * @param initialM34 defines 4th value of 3rd row
  65750. * @param initialM41 defines 1st value of 4th row
  65751. * @param initialM42 defines 2nd value of 4th row
  65752. * @param initialM43 defines 3rd value of 4th row
  65753. * @param initialM44 defines 4th value of 4th row
  65754. * @param result defines the target matrix
  65755. */
  65756. 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;
  65757. /**
  65758. * Creates new matrix from a list of values (16)
  65759. * @param initialM11 defines 1st value of 1st row
  65760. * @param initialM12 defines 2nd value of 1st row
  65761. * @param initialM13 defines 3rd value of 1st row
  65762. * @param initialM14 defines 4th value of 1st row
  65763. * @param initialM21 defines 1st value of 2nd row
  65764. * @param initialM22 defines 2nd value of 2nd row
  65765. * @param initialM23 defines 3rd value of 2nd row
  65766. * @param initialM24 defines 4th value of 2nd row
  65767. * @param initialM31 defines 1st value of 3rd row
  65768. * @param initialM32 defines 2nd value of 3rd row
  65769. * @param initialM33 defines 3rd value of 3rd row
  65770. * @param initialM34 defines 4th value of 3rd row
  65771. * @param initialM41 defines 1st value of 4th row
  65772. * @param initialM42 defines 2nd value of 4th row
  65773. * @param initialM43 defines 3rd value of 4th row
  65774. * @param initialM44 defines 4th value of 4th row
  65775. * @returns the new matrix
  65776. */
  65777. 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;
  65778. /**
  65779. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65780. * @param scale defines the scale vector3
  65781. * @param rotation defines the rotation quaternion
  65782. * @param translation defines the translation vector3
  65783. * @returns a new matrix
  65784. */
  65785. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65786. /**
  65787. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65788. * @param scale defines the scale vector3
  65789. * @param rotation defines the rotation quaternion
  65790. * @param translation defines the translation vector3
  65791. * @param result defines the target matrix
  65792. */
  65793. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65794. /**
  65795. * Creates a new identity matrix
  65796. * @returns a new identity matrix
  65797. */
  65798. static Identity(): Matrix;
  65799. /**
  65800. * Creates a new identity matrix and stores the result in a given matrix
  65801. * @param result defines the target matrix
  65802. */
  65803. static IdentityToRef(result: Matrix): void;
  65804. /**
  65805. * Creates a new zero matrix
  65806. * @returns a new zero matrix
  65807. */
  65808. static Zero(): Matrix;
  65809. /**
  65810. * Creates a new rotation matrix for "angle" radians around the X axis
  65811. * @param angle defines the angle (in radians) to use
  65812. * @return the new matrix
  65813. */
  65814. static RotationX(angle: number): Matrix;
  65815. /**
  65816. * Creates a new matrix as the invert of a given matrix
  65817. * @param source defines the source matrix
  65818. * @returns the new matrix
  65819. */
  65820. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65821. /**
  65822. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65823. * @param angle defines the angle (in radians) to use
  65824. * @param result defines the target matrix
  65825. */
  65826. static RotationXToRef(angle: number, result: Matrix): void;
  65827. /**
  65828. * Creates a new rotation matrix for "angle" radians around the Y axis
  65829. * @param angle defines the angle (in radians) to use
  65830. * @return the new matrix
  65831. */
  65832. static RotationY(angle: number): Matrix;
  65833. /**
  65834. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65835. * @param angle defines the angle (in radians) to use
  65836. * @param result defines the target matrix
  65837. */
  65838. static RotationYToRef(angle: number, result: Matrix): void;
  65839. /**
  65840. * Creates a new rotation matrix for "angle" radians around the Z axis
  65841. * @param angle defines the angle (in radians) to use
  65842. * @return the new matrix
  65843. */
  65844. static RotationZ(angle: number): Matrix;
  65845. /**
  65846. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65847. * @param angle defines the angle (in radians) to use
  65848. * @param result defines the target matrix
  65849. */
  65850. static RotationZToRef(angle: number, result: Matrix): void;
  65851. /**
  65852. * Creates a new rotation matrix for "angle" radians around the given axis
  65853. * @param axis defines the axis to use
  65854. * @param angle defines the angle (in radians) to use
  65855. * @return the new matrix
  65856. */
  65857. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65858. /**
  65859. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65860. * @param axis defines the axis to use
  65861. * @param angle defines the angle (in radians) to use
  65862. * @param result defines the target matrix
  65863. */
  65864. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65865. /**
  65866. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65867. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65868. * @param from defines the vector to align
  65869. * @param to defines the vector to align to
  65870. * @param result defines the target matrix
  65871. */
  65872. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65873. /**
  65874. * Creates a rotation matrix
  65875. * @param yaw defines the yaw angle in radians (Y axis)
  65876. * @param pitch defines the pitch angle in radians (X axis)
  65877. * @param roll defines the roll angle in radians (X axis)
  65878. * @returns the new rotation matrix
  65879. */
  65880. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65881. /**
  65882. * Creates a rotation matrix and stores it in a given matrix
  65883. * @param yaw defines the yaw angle in radians (Y axis)
  65884. * @param pitch defines the pitch angle in radians (X axis)
  65885. * @param roll defines the roll angle in radians (X axis)
  65886. * @param result defines the target matrix
  65887. */
  65888. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65889. /**
  65890. * Creates a scaling matrix
  65891. * @param x defines the scale factor on X axis
  65892. * @param y defines the scale factor on Y axis
  65893. * @param z defines the scale factor on Z axis
  65894. * @returns the new matrix
  65895. */
  65896. static Scaling(x: number, y: number, z: number): Matrix;
  65897. /**
  65898. * Creates a scaling matrix and stores it in a given matrix
  65899. * @param x defines the scale factor on X axis
  65900. * @param y defines the scale factor on Y axis
  65901. * @param z defines the scale factor on Z axis
  65902. * @param result defines the target matrix
  65903. */
  65904. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65905. /**
  65906. * Creates a translation matrix
  65907. * @param x defines the translation on X axis
  65908. * @param y defines the translation on Y axis
  65909. * @param z defines the translationon Z axis
  65910. * @returns the new matrix
  65911. */
  65912. static Translation(x: number, y: number, z: number): Matrix;
  65913. /**
  65914. * Creates a translation matrix and stores it in a given matrix
  65915. * @param x defines the translation on X axis
  65916. * @param y defines the translation on Y axis
  65917. * @param z defines the translationon Z axis
  65918. * @param result defines the target matrix
  65919. */
  65920. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65921. /**
  65922. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65923. * @param startValue defines the start value
  65924. * @param endValue defines the end value
  65925. * @param gradient defines the gradient factor
  65926. * @returns the new matrix
  65927. */
  65928. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65929. /**
  65930. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65931. * @param startValue defines the start value
  65932. * @param endValue defines the end value
  65933. * @param gradient defines the gradient factor
  65934. * @param result defines the Matrix object where to store data
  65935. */
  65936. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65937. /**
  65938. * Builds a new matrix whose values are computed by:
  65939. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65940. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65941. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65942. * @param startValue defines the first matrix
  65943. * @param endValue defines the second matrix
  65944. * @param gradient defines the gradient between the two matrices
  65945. * @returns the new matrix
  65946. */
  65947. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65948. /**
  65949. * Update a matrix to values which are computed by:
  65950. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65951. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65952. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65953. * @param startValue defines the first matrix
  65954. * @param endValue defines the second matrix
  65955. * @param gradient defines the gradient between the two matrices
  65956. * @param result defines the target matrix
  65957. */
  65958. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65959. /**
  65960. * 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"
  65961. * This function works in left handed mode
  65962. * @param eye defines the final position of the entity
  65963. * @param target defines where the entity should look at
  65964. * @param up defines the up vector for the entity
  65965. * @returns the new matrix
  65966. */
  65967. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65968. /**
  65969. * 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".
  65970. * This function works in left handed mode
  65971. * @param eye defines the final position of the entity
  65972. * @param target defines where the entity should look at
  65973. * @param up defines the up vector for the entity
  65974. * @param result defines the target matrix
  65975. */
  65976. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65977. /**
  65978. * 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"
  65979. * This function works in right handed mode
  65980. * @param eye defines the final position of the entity
  65981. * @param target defines where the entity should look at
  65982. * @param up defines the up vector for the entity
  65983. * @returns the new matrix
  65984. */
  65985. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65986. /**
  65987. * 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".
  65988. * This function works in right handed mode
  65989. * @param eye defines the final position of the entity
  65990. * @param target defines where the entity should look at
  65991. * @param up defines the up vector for the entity
  65992. * @param result defines the target matrix
  65993. */
  65994. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65995. /**
  65996. * Create a left-handed orthographic projection matrix
  65997. * @param width defines the viewport width
  65998. * @param height defines the viewport height
  65999. * @param znear defines the near clip plane
  66000. * @param zfar defines the far clip plane
  66001. * @returns a new matrix as a left-handed orthographic projection matrix
  66002. */
  66003. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66004. /**
  66005. * Store a left-handed orthographic projection to a given matrix
  66006. * @param width defines the viewport width
  66007. * @param height defines the viewport height
  66008. * @param znear defines the near clip plane
  66009. * @param zfar defines the far clip plane
  66010. * @param result defines the target matrix
  66011. */
  66012. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66013. /**
  66014. * Create a left-handed orthographic projection matrix
  66015. * @param left defines the viewport left coordinate
  66016. * @param right defines the viewport right coordinate
  66017. * @param bottom defines the viewport bottom coordinate
  66018. * @param top defines the viewport top coordinate
  66019. * @param znear defines the near clip plane
  66020. * @param zfar defines the far clip plane
  66021. * @returns a new matrix as a left-handed orthographic projection matrix
  66022. */
  66023. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66024. /**
  66025. * Stores a left-handed orthographic projection into a given matrix
  66026. * @param left defines the viewport left coordinate
  66027. * @param right defines the viewport right coordinate
  66028. * @param bottom defines the viewport bottom coordinate
  66029. * @param top defines the viewport top coordinate
  66030. * @param znear defines the near clip plane
  66031. * @param zfar defines the far clip plane
  66032. * @param result defines the target matrix
  66033. */
  66034. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66035. /**
  66036. * Creates a right-handed orthographic projection matrix
  66037. * @param left defines the viewport left coordinate
  66038. * @param right defines the viewport right coordinate
  66039. * @param bottom defines the viewport bottom coordinate
  66040. * @param top defines the viewport top coordinate
  66041. * @param znear defines the near clip plane
  66042. * @param zfar defines the far clip plane
  66043. * @returns a new matrix as a right-handed orthographic projection matrix
  66044. */
  66045. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66046. /**
  66047. * Stores a right-handed orthographic projection into a given matrix
  66048. * @param left defines the viewport left coordinate
  66049. * @param right defines the viewport right coordinate
  66050. * @param bottom defines the viewport bottom coordinate
  66051. * @param top defines the viewport top coordinate
  66052. * @param znear defines the near clip plane
  66053. * @param zfar defines the far clip plane
  66054. * @param result defines the target matrix
  66055. */
  66056. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66057. /**
  66058. * Creates a left-handed perspective projection matrix
  66059. * @param width defines the viewport width
  66060. * @param height defines the viewport height
  66061. * @param znear defines the near clip plane
  66062. * @param zfar defines the far clip plane
  66063. * @returns a new matrix as a left-handed perspective projection matrix
  66064. */
  66065. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66066. /**
  66067. * Creates a left-handed perspective projection matrix
  66068. * @param fov defines the horizontal field of view
  66069. * @param aspect defines the aspect ratio
  66070. * @param znear defines the near clip plane
  66071. * @param zfar defines the far clip plane
  66072. * @returns a new matrix as a left-handed perspective projection matrix
  66073. */
  66074. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66075. /**
  66076. * Stores a left-handed perspective projection into a given matrix
  66077. * @param fov defines the horizontal field of view
  66078. * @param aspect defines the aspect ratio
  66079. * @param znear defines the near clip plane
  66080. * @param zfar defines the far clip plane
  66081. * @param result defines the target matrix
  66082. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66083. */
  66084. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66085. /**
  66086. * Creates a right-handed perspective projection matrix
  66087. * @param fov defines the horizontal field of view
  66088. * @param aspect defines the aspect ratio
  66089. * @param znear defines the near clip plane
  66090. * @param zfar defines the far clip plane
  66091. * @returns a new matrix as a right-handed perspective projection matrix
  66092. */
  66093. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66094. /**
  66095. * Stores a right-handed perspective projection into a given matrix
  66096. * @param fov defines the horizontal field of view
  66097. * @param aspect defines the aspect ratio
  66098. * @param znear defines the near clip plane
  66099. * @param zfar defines the far clip plane
  66100. * @param result defines the target matrix
  66101. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66102. */
  66103. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66104. /**
  66105. * Stores a perspective projection for WebVR info a given matrix
  66106. * @param fov defines the field of view
  66107. * @param znear defines the near clip plane
  66108. * @param zfar defines the far clip plane
  66109. * @param result defines the target matrix
  66110. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66111. */
  66112. static PerspectiveFovWebVRToRef(fov: {
  66113. upDegrees: number;
  66114. downDegrees: number;
  66115. leftDegrees: number;
  66116. rightDegrees: number;
  66117. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66118. /**
  66119. * Computes a complete transformation matrix
  66120. * @param viewport defines the viewport to use
  66121. * @param world defines the world matrix
  66122. * @param view defines the view matrix
  66123. * @param projection defines the projection matrix
  66124. * @param zmin defines the near clip plane
  66125. * @param zmax defines the far clip plane
  66126. * @returns the transformation matrix
  66127. */
  66128. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66129. /**
  66130. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66131. * @param matrix defines the matrix to use
  66132. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66133. */
  66134. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66135. /**
  66136. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66137. * @param matrix defines the matrix to use
  66138. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66139. */
  66140. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66141. /**
  66142. * Compute the transpose of a given matrix
  66143. * @param matrix defines the matrix to transpose
  66144. * @returns the new matrix
  66145. */
  66146. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66147. /**
  66148. * Compute the transpose of a matrix and store it in a target matrix
  66149. * @param matrix defines the matrix to transpose
  66150. * @param result defines the target matrix
  66151. */
  66152. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66153. /**
  66154. * Computes a reflection matrix from a plane
  66155. * @param plane defines the reflection plane
  66156. * @returns a new matrix
  66157. */
  66158. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66159. /**
  66160. * Computes a reflection matrix from a plane
  66161. * @param plane defines the reflection plane
  66162. * @param result defines the target matrix
  66163. */
  66164. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66165. /**
  66166. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66167. * @param xaxis defines the value of the 1st axis
  66168. * @param yaxis defines the value of the 2nd axis
  66169. * @param zaxis defines the value of the 3rd axis
  66170. * @param result defines the target matrix
  66171. */
  66172. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66173. /**
  66174. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66175. * @param quat defines the quaternion to use
  66176. * @param result defines the target matrix
  66177. */
  66178. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66179. }
  66180. /**
  66181. * Represens a plane by the equation ax + by + cz + d = 0
  66182. */
  66183. export class Plane {
  66184. /**
  66185. * Normal of the plane (a,b,c)
  66186. */
  66187. normal: Vector3;
  66188. /**
  66189. * d component of the plane
  66190. */
  66191. d: number;
  66192. /**
  66193. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66194. * @param a a component of the plane
  66195. * @param b b component of the plane
  66196. * @param c c component of the plane
  66197. * @param d d component of the plane
  66198. */
  66199. constructor(a: number, b: number, c: number, d: number);
  66200. /**
  66201. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66202. */
  66203. asArray(): number[];
  66204. /**
  66205. * @returns a new plane copied from the current Plane.
  66206. */
  66207. clone(): Plane;
  66208. /**
  66209. * @returns the string "Plane".
  66210. */
  66211. getClassName(): string;
  66212. /**
  66213. * @returns the Plane hash code.
  66214. */
  66215. getHashCode(): number;
  66216. /**
  66217. * Normalize the current Plane in place.
  66218. * @returns the updated Plane.
  66219. */
  66220. normalize(): Plane;
  66221. /**
  66222. * Applies a transformation the plane and returns the result
  66223. * @param transformation the transformation matrix to be applied to the plane
  66224. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66225. */
  66226. transform(transformation: DeepImmutable<Matrix>): Plane;
  66227. /**
  66228. * Calcualtte the dot product between the point and the plane normal
  66229. * @param point point to calculate the dot product with
  66230. * @returns the dot product (float) of the point coordinates and the plane normal.
  66231. */
  66232. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66233. /**
  66234. * Updates the current Plane from the plane defined by the three given points.
  66235. * @param point1 one of the points used to contruct the plane
  66236. * @param point2 one of the points used to contruct the plane
  66237. * @param point3 one of the points used to contruct the plane
  66238. * @returns the updated Plane.
  66239. */
  66240. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66241. /**
  66242. * Checks if the plane is facing a given direction
  66243. * @param direction the direction to check if the plane is facing
  66244. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66245. * @returns True is the vector "direction" is the same side than the plane normal.
  66246. */
  66247. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66248. /**
  66249. * Calculates the distance to a point
  66250. * @param point point to calculate distance to
  66251. * @returns the signed distance (float) from the given point to the Plane.
  66252. */
  66253. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66254. /**
  66255. * Creates a plane from an array
  66256. * @param array the array to create a plane from
  66257. * @returns a new Plane from the given array.
  66258. */
  66259. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66260. /**
  66261. * Creates a plane from three points
  66262. * @param point1 point used to create the plane
  66263. * @param point2 point used to create the plane
  66264. * @param point3 point used to create the plane
  66265. * @returns a new Plane defined by the three given points.
  66266. */
  66267. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66268. /**
  66269. * Creates a plane from an origin point and a normal
  66270. * @param origin origin of the plane to be constructed
  66271. * @param normal normal of the plane to be constructed
  66272. * @returns a new Plane the normal vector to this plane at the given origin point.
  66273. * Note : the vector "normal" is updated because normalized.
  66274. */
  66275. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66276. /**
  66277. * Calculates the distance from a plane and a point
  66278. * @param origin origin of the plane to be constructed
  66279. * @param normal normal of the plane to be constructed
  66280. * @param point point to calculate distance to
  66281. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66282. */
  66283. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66284. }
  66285. /**
  66286. * Class used to represent a viewport on screen
  66287. */
  66288. export class Viewport {
  66289. /** viewport left coordinate */
  66290. x: number;
  66291. /** viewport top coordinate */
  66292. y: number;
  66293. /**viewport width */
  66294. width: number;
  66295. /** viewport height */
  66296. height: number;
  66297. /**
  66298. * Creates a Viewport object located at (x, y) and sized (width, height)
  66299. * @param x defines viewport left coordinate
  66300. * @param y defines viewport top coordinate
  66301. * @param width defines the viewport width
  66302. * @param height defines the viewport height
  66303. */
  66304. constructor(
  66305. /** viewport left coordinate */
  66306. x: number,
  66307. /** viewport top coordinate */
  66308. y: number,
  66309. /**viewport width */
  66310. width: number,
  66311. /** viewport height */
  66312. height: number);
  66313. /**
  66314. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66315. * @param renderWidth defines the rendering width
  66316. * @param renderHeight defines the rendering height
  66317. * @returns a new Viewport
  66318. */
  66319. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66320. /**
  66321. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66322. * @param renderWidth defines the rendering width
  66323. * @param renderHeight defines the rendering height
  66324. * @param ref defines the target viewport
  66325. * @returns the current viewport
  66326. */
  66327. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66328. /**
  66329. * Returns a new Viewport copied from the current one
  66330. * @returns a new Viewport
  66331. */
  66332. clone(): Viewport;
  66333. }
  66334. /**
  66335. * Reprasents a camera frustum
  66336. */
  66337. export class Frustum {
  66338. /**
  66339. * Gets the planes representing the frustum
  66340. * @param transform matrix to be applied to the returned planes
  66341. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66342. */
  66343. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66344. /**
  66345. * Gets the near frustum plane transformed by the transform matrix
  66346. * @param transform transformation matrix to be applied to the resulting frustum plane
  66347. * @param frustumPlane the resuling frustum plane
  66348. */
  66349. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66350. /**
  66351. * Gets the far frustum plane transformed by the transform matrix
  66352. * @param transform transformation matrix to be applied to the resulting frustum plane
  66353. * @param frustumPlane the resuling frustum plane
  66354. */
  66355. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66356. /**
  66357. * Gets the left frustum plane transformed by the transform matrix
  66358. * @param transform transformation matrix to be applied to the resulting frustum plane
  66359. * @param frustumPlane the resuling frustum plane
  66360. */
  66361. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66362. /**
  66363. * Gets the right frustum plane transformed by the transform matrix
  66364. * @param transform transformation matrix to be applied to the resulting frustum plane
  66365. * @param frustumPlane the resuling frustum plane
  66366. */
  66367. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66368. /**
  66369. * Gets the top frustum plane transformed by the transform matrix
  66370. * @param transform transformation matrix to be applied to the resulting frustum plane
  66371. * @param frustumPlane the resuling frustum plane
  66372. */
  66373. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66374. /**
  66375. * Gets the bottom frustum plane transformed by the transform matrix
  66376. * @param transform transformation matrix to be applied to the resulting frustum plane
  66377. * @param frustumPlane the resuling frustum plane
  66378. */
  66379. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66380. /**
  66381. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66382. * @param transform transformation matrix to be applied to the resulting frustum planes
  66383. * @param frustumPlanes the resuling frustum planes
  66384. */
  66385. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66386. }
  66387. /** Defines supported spaces */
  66388. export enum Space {
  66389. /** Local (object) space */
  66390. LOCAL = 0,
  66391. /** World space */
  66392. WORLD = 1,
  66393. /** Bone space */
  66394. BONE = 2
  66395. }
  66396. /** Defines the 3 main axes */
  66397. export class Axis {
  66398. /** X axis */
  66399. static X: Vector3;
  66400. /** Y axis */
  66401. static Y: Vector3;
  66402. /** Z axis */
  66403. static Z: Vector3;
  66404. }
  66405. /** Class used to represent a Bezier curve */
  66406. export class BezierCurve {
  66407. /**
  66408. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66409. * @param t defines the time
  66410. * @param x1 defines the left coordinate on X axis
  66411. * @param y1 defines the left coordinate on Y axis
  66412. * @param x2 defines the right coordinate on X axis
  66413. * @param y2 defines the right coordinate on Y axis
  66414. * @returns the interpolated value
  66415. */
  66416. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66417. }
  66418. /**
  66419. * Defines potential orientation for back face culling
  66420. */
  66421. export enum Orientation {
  66422. /**
  66423. * Clockwise
  66424. */
  66425. CW = 0,
  66426. /** Counter clockwise */
  66427. CCW = 1
  66428. }
  66429. /**
  66430. * Defines angle representation
  66431. */
  66432. export class Angle {
  66433. private _radians;
  66434. /**
  66435. * Creates an Angle object of "radians" radians (float).
  66436. * @param radians the angle in radians
  66437. */
  66438. constructor(radians: number);
  66439. /**
  66440. * Get value in degrees
  66441. * @returns the Angle value in degrees (float)
  66442. */
  66443. degrees(): number;
  66444. /**
  66445. * Get value in radians
  66446. * @returns the Angle value in radians (float)
  66447. */
  66448. radians(): number;
  66449. /**
  66450. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66451. * @param a defines first vector
  66452. * @param b defines second vector
  66453. * @returns a new Angle
  66454. */
  66455. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66456. /**
  66457. * Gets a new Angle object from the given float in radians
  66458. * @param radians defines the angle value in radians
  66459. * @returns a new Angle
  66460. */
  66461. static FromRadians(radians: number): Angle;
  66462. /**
  66463. * Gets a new Angle object from the given float in degrees
  66464. * @param degrees defines the angle value in degrees
  66465. * @returns a new Angle
  66466. */
  66467. static FromDegrees(degrees: number): Angle;
  66468. }
  66469. /**
  66470. * This represents an arc in a 2d space.
  66471. */
  66472. export class Arc2 {
  66473. /** Defines the start point of the arc */
  66474. startPoint: Vector2;
  66475. /** Defines the mid point of the arc */
  66476. midPoint: Vector2;
  66477. /** Defines the end point of the arc */
  66478. endPoint: Vector2;
  66479. /**
  66480. * Defines the center point of the arc.
  66481. */
  66482. centerPoint: Vector2;
  66483. /**
  66484. * Defines the radius of the arc.
  66485. */
  66486. radius: number;
  66487. /**
  66488. * Defines the angle of the arc (from mid point to end point).
  66489. */
  66490. angle: Angle;
  66491. /**
  66492. * Defines the start angle of the arc (from start point to middle point).
  66493. */
  66494. startAngle: Angle;
  66495. /**
  66496. * Defines the orientation of the arc (clock wise/counter clock wise).
  66497. */
  66498. orientation: Orientation;
  66499. /**
  66500. * Creates an Arc object from the three given points : start, middle and end.
  66501. * @param startPoint Defines the start point of the arc
  66502. * @param midPoint Defines the midlle point of the arc
  66503. * @param endPoint Defines the end point of the arc
  66504. */
  66505. constructor(
  66506. /** Defines the start point of the arc */
  66507. startPoint: Vector2,
  66508. /** Defines the mid point of the arc */
  66509. midPoint: Vector2,
  66510. /** Defines the end point of the arc */
  66511. endPoint: Vector2);
  66512. }
  66513. /**
  66514. * Represents a 2D path made up of multiple 2D points
  66515. */
  66516. export class Path2 {
  66517. private _points;
  66518. private _length;
  66519. /**
  66520. * If the path start and end point are the same
  66521. */
  66522. closed: boolean;
  66523. /**
  66524. * Creates a Path2 object from the starting 2D coordinates x and y.
  66525. * @param x the starting points x value
  66526. * @param y the starting points y value
  66527. */
  66528. constructor(x: number, y: number);
  66529. /**
  66530. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66531. * @param x the added points x value
  66532. * @param y the added points y value
  66533. * @returns the updated Path2.
  66534. */
  66535. addLineTo(x: number, y: number): Path2;
  66536. /**
  66537. * 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.
  66538. * @param midX middle point x value
  66539. * @param midY middle point y value
  66540. * @param endX end point x value
  66541. * @param endY end point y value
  66542. * @param numberOfSegments (default: 36)
  66543. * @returns the updated Path2.
  66544. */
  66545. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66546. /**
  66547. * Closes the Path2.
  66548. * @returns the Path2.
  66549. */
  66550. close(): Path2;
  66551. /**
  66552. * Gets the sum of the distance between each sequential point in the path
  66553. * @returns the Path2 total length (float).
  66554. */
  66555. length(): number;
  66556. /**
  66557. * Gets the points which construct the path
  66558. * @returns the Path2 internal array of points.
  66559. */
  66560. getPoints(): Vector2[];
  66561. /**
  66562. * Retreives the point at the distance aways from the starting point
  66563. * @param normalizedLengthPosition the length along the path to retreive the point from
  66564. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66565. */
  66566. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66567. /**
  66568. * Creates a new path starting from an x and y position
  66569. * @param x starting x value
  66570. * @param y starting y value
  66571. * @returns a new Path2 starting at the coordinates (x, y).
  66572. */
  66573. static StartingAt(x: number, y: number): Path2;
  66574. }
  66575. /**
  66576. * Represents a 3D path made up of multiple 3D points
  66577. */
  66578. export class Path3D {
  66579. /**
  66580. * an array of Vector3, the curve axis of the Path3D
  66581. */
  66582. path: Vector3[];
  66583. private _curve;
  66584. private _distances;
  66585. private _tangents;
  66586. private _normals;
  66587. private _binormals;
  66588. private _raw;
  66589. /**
  66590. * new Path3D(path, normal, raw)
  66591. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66592. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66593. * @param path an array of Vector3, the curve axis of the Path3D
  66594. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66595. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66596. */
  66597. constructor(
  66598. /**
  66599. * an array of Vector3, the curve axis of the Path3D
  66600. */
  66601. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66602. /**
  66603. * Returns the Path3D array of successive Vector3 designing its curve.
  66604. * @returns the Path3D array of successive Vector3 designing its curve.
  66605. */
  66606. getCurve(): Vector3[];
  66607. /**
  66608. * Returns an array populated with tangent vectors on each Path3D curve point.
  66609. * @returns an array populated with tangent vectors on each Path3D curve point.
  66610. */
  66611. getTangents(): Vector3[];
  66612. /**
  66613. * Returns an array populated with normal vectors on each Path3D curve point.
  66614. * @returns an array populated with normal vectors on each Path3D curve point.
  66615. */
  66616. getNormals(): Vector3[];
  66617. /**
  66618. * Returns an array populated with binormal vectors on each Path3D curve point.
  66619. * @returns an array populated with binormal vectors on each Path3D curve point.
  66620. */
  66621. getBinormals(): Vector3[];
  66622. /**
  66623. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66624. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66625. */
  66626. getDistances(): number[];
  66627. /**
  66628. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66629. * @param path path which all values are copied into the curves points
  66630. * @param firstNormal which should be projected onto the curve
  66631. * @returns the same object updated.
  66632. */
  66633. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66634. private _compute;
  66635. private _getFirstNonNullVector;
  66636. private _getLastNonNullVector;
  66637. private _normalVector;
  66638. }
  66639. /**
  66640. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66641. * A Curve3 is designed from a series of successive Vector3.
  66642. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66643. */
  66644. export class Curve3 {
  66645. private _points;
  66646. private _length;
  66647. /**
  66648. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66649. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66650. * @param v1 (Vector3) the control point
  66651. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66652. * @param nbPoints (integer) the wanted number of points in the curve
  66653. * @returns the created Curve3
  66654. */
  66655. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66656. /**
  66657. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66658. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66659. * @param v1 (Vector3) the first control point
  66660. * @param v2 (Vector3) the second control point
  66661. * @param v3 (Vector3) the end point of the Cubic Bezier
  66662. * @param nbPoints (integer) the wanted number of points in the curve
  66663. * @returns the created Curve3
  66664. */
  66665. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66666. /**
  66667. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66668. * @param p1 (Vector3) the origin point of the Hermite Spline
  66669. * @param t1 (Vector3) the tangent vector at the origin point
  66670. * @param p2 (Vector3) the end point of the Hermite Spline
  66671. * @param t2 (Vector3) the tangent vector at the end point
  66672. * @param nbPoints (integer) the wanted number of points in the curve
  66673. * @returns the created Curve3
  66674. */
  66675. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66676. /**
  66677. * Returns a Curve3 object along a CatmullRom Spline curve :
  66678. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66679. * @param nbPoints (integer) the wanted number of points between each curve control points
  66680. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66681. * @returns the created Curve3
  66682. */
  66683. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66684. /**
  66685. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66686. * A Curve3 is designed from a series of successive Vector3.
  66687. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66688. * @param points points which make up the curve
  66689. */
  66690. constructor(points: Vector3[]);
  66691. /**
  66692. * @returns the Curve3 stored array of successive Vector3
  66693. */
  66694. getPoints(): Vector3[];
  66695. /**
  66696. * @returns the computed length (float) of the curve.
  66697. */
  66698. length(): number;
  66699. /**
  66700. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66701. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66702. * curveA and curveB keep unchanged.
  66703. * @param curve the curve to continue from this curve
  66704. * @returns the newly constructed curve
  66705. */
  66706. continue(curve: DeepImmutable<Curve3>): Curve3;
  66707. private _computeLength;
  66708. }
  66709. /**
  66710. * Contains position and normal vectors for a vertex
  66711. */
  66712. export class PositionNormalVertex {
  66713. /** the position of the vertex (defaut: 0,0,0) */
  66714. position: Vector3;
  66715. /** the normal of the vertex (defaut: 0,1,0) */
  66716. normal: Vector3;
  66717. /**
  66718. * Creates a PositionNormalVertex
  66719. * @param position the position of the vertex (defaut: 0,0,0)
  66720. * @param normal the normal of the vertex (defaut: 0,1,0)
  66721. */
  66722. constructor(
  66723. /** the position of the vertex (defaut: 0,0,0) */
  66724. position?: Vector3,
  66725. /** the normal of the vertex (defaut: 0,1,0) */
  66726. normal?: Vector3);
  66727. /**
  66728. * Clones the PositionNormalVertex
  66729. * @returns the cloned PositionNormalVertex
  66730. */
  66731. clone(): PositionNormalVertex;
  66732. }
  66733. /**
  66734. * Contains position, normal and uv vectors for a vertex
  66735. */
  66736. export class PositionNormalTextureVertex {
  66737. /** the position of the vertex (defaut: 0,0,0) */
  66738. position: Vector3;
  66739. /** the normal of the vertex (defaut: 0,1,0) */
  66740. normal: Vector3;
  66741. /** the uv of the vertex (default: 0,0) */
  66742. uv: Vector2;
  66743. /**
  66744. * Creates a PositionNormalTextureVertex
  66745. * @param position the position of the vertex (defaut: 0,0,0)
  66746. * @param normal the normal of the vertex (defaut: 0,1,0)
  66747. * @param uv the uv of the vertex (default: 0,0)
  66748. */
  66749. constructor(
  66750. /** the position of the vertex (defaut: 0,0,0) */
  66751. position?: Vector3,
  66752. /** the normal of the vertex (defaut: 0,1,0) */
  66753. normal?: Vector3,
  66754. /** the uv of the vertex (default: 0,0) */
  66755. uv?: Vector2);
  66756. /**
  66757. * Clones the PositionNormalTextureVertex
  66758. * @returns the cloned PositionNormalTextureVertex
  66759. */
  66760. clone(): PositionNormalTextureVertex;
  66761. }
  66762. /**
  66763. * @hidden
  66764. */
  66765. export class Tmp {
  66766. static Color3: Color3[];
  66767. static Color4: Color4[];
  66768. static Vector2: Vector2[];
  66769. static Vector3: Vector3[];
  66770. static Vector4: Vector4[];
  66771. static Quaternion: Quaternion[];
  66772. static Matrix: Matrix[];
  66773. }
  66774. }
  66775. declare module BABYLON {
  66776. /**
  66777. * Class used to enable access to offline support
  66778. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66779. */
  66780. export interface IOfflineProvider {
  66781. /**
  66782. * Gets a boolean indicating if scene must be saved in the database
  66783. */
  66784. enableSceneOffline: boolean;
  66785. /**
  66786. * Gets a boolean indicating if textures must be saved in the database
  66787. */
  66788. enableTexturesOffline: boolean;
  66789. /**
  66790. * Open the offline support and make it available
  66791. * @param successCallback defines the callback to call on success
  66792. * @param errorCallback defines the callback to call on error
  66793. */
  66794. open(successCallback: () => void, errorCallback: () => void): void;
  66795. /**
  66796. * Loads an image from the offline support
  66797. * @param url defines the url to load from
  66798. * @param image defines the target DOM image
  66799. */
  66800. loadImage(url: string, image: HTMLImageElement): void;
  66801. /**
  66802. * Loads a file from offline support
  66803. * @param url defines the URL to load from
  66804. * @param sceneLoaded defines a callback to call on success
  66805. * @param progressCallBack defines a callback to call when progress changed
  66806. * @param errorCallback defines a callback to call on error
  66807. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66808. */
  66809. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66810. }
  66811. }
  66812. declare module BABYLON {
  66813. /**
  66814. * A class serves as a medium between the observable and its observers
  66815. */
  66816. export class EventState {
  66817. /**
  66818. * Create a new EventState
  66819. * @param mask defines the mask associated with this state
  66820. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66821. * @param target defines the original target of the state
  66822. * @param currentTarget defines the current target of the state
  66823. */
  66824. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66825. /**
  66826. * Initialize the current event state
  66827. * @param mask defines the mask associated with this state
  66828. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66829. * @param target defines the original target of the state
  66830. * @param currentTarget defines the current target of the state
  66831. * @returns the current event state
  66832. */
  66833. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66834. /**
  66835. * An Observer can set this property to true to prevent subsequent observers of being notified
  66836. */
  66837. skipNextObservers: boolean;
  66838. /**
  66839. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66840. */
  66841. mask: number;
  66842. /**
  66843. * The object that originally notified the event
  66844. */
  66845. target?: any;
  66846. /**
  66847. * The current object in the bubbling phase
  66848. */
  66849. currentTarget?: any;
  66850. /**
  66851. * This will be populated with the return value of the last function that was executed.
  66852. * If it is the first function in the callback chain it will be the event data.
  66853. */
  66854. lastReturnValue?: any;
  66855. }
  66856. /**
  66857. * Represent an Observer registered to a given Observable object.
  66858. */
  66859. export class Observer<T> {
  66860. /**
  66861. * Defines the callback to call when the observer is notified
  66862. */
  66863. callback: (eventData: T, eventState: EventState) => void;
  66864. /**
  66865. * Defines the mask of the observer (used to filter notifications)
  66866. */
  66867. mask: number;
  66868. /**
  66869. * Defines the current scope used to restore the JS context
  66870. */
  66871. scope: any;
  66872. /** @hidden */
  66873. _willBeUnregistered: boolean;
  66874. /**
  66875. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66876. */
  66877. unregisterOnNextCall: boolean;
  66878. /**
  66879. * Creates a new observer
  66880. * @param callback defines the callback to call when the observer is notified
  66881. * @param mask defines the mask of the observer (used to filter notifications)
  66882. * @param scope defines the current scope used to restore the JS context
  66883. */
  66884. constructor(
  66885. /**
  66886. * Defines the callback to call when the observer is notified
  66887. */
  66888. callback: (eventData: T, eventState: EventState) => void,
  66889. /**
  66890. * Defines the mask of the observer (used to filter notifications)
  66891. */
  66892. mask: number,
  66893. /**
  66894. * Defines the current scope used to restore the JS context
  66895. */
  66896. scope?: any);
  66897. }
  66898. /**
  66899. * Represent a list of observers registered to multiple Observables object.
  66900. */
  66901. export class MultiObserver<T> {
  66902. private _observers;
  66903. private _observables;
  66904. /**
  66905. * Release associated resources
  66906. */
  66907. dispose(): void;
  66908. /**
  66909. * Raise a callback when one of the observable will notify
  66910. * @param observables defines a list of observables to watch
  66911. * @param callback defines the callback to call on notification
  66912. * @param mask defines the mask used to filter notifications
  66913. * @param scope defines the current scope used to restore the JS context
  66914. * @returns the new MultiObserver
  66915. */
  66916. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66917. }
  66918. /**
  66919. * The Observable class is a simple implementation of the Observable pattern.
  66920. *
  66921. * 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.
  66922. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66923. * 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).
  66924. * 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.
  66925. */
  66926. export class Observable<T> {
  66927. private _observers;
  66928. private _eventState;
  66929. private _onObserverAdded;
  66930. /**
  66931. * Creates a new observable
  66932. * @param onObserverAdded defines a callback to call when a new observer is added
  66933. */
  66934. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66935. /**
  66936. * Create a new Observer with the specified callback
  66937. * @param callback the callback that will be executed for that Observer
  66938. * @param mask the mask used to filter observers
  66939. * @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.
  66940. * @param scope optional scope for the callback to be called from
  66941. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66942. * @returns the new observer created for the callback
  66943. */
  66944. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66945. /**
  66946. * Create a new Observer with the specified callback and unregisters after the next notification
  66947. * @param callback the callback that will be executed for that Observer
  66948. * @returns the new observer created for the callback
  66949. */
  66950. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66951. /**
  66952. * Remove an Observer from the Observable object
  66953. * @param observer the instance of the Observer to remove
  66954. * @returns false if it doesn't belong to this Observable
  66955. */
  66956. remove(observer: Nullable<Observer<T>>): boolean;
  66957. /**
  66958. * Remove a callback from the Observable object
  66959. * @param callback the callback to remove
  66960. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66961. * @returns false if it doesn't belong to this Observable
  66962. */
  66963. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66964. private _deferUnregister;
  66965. private _remove;
  66966. /**
  66967. * Moves the observable to the top of the observer list making it get called first when notified
  66968. * @param observer the observer to move
  66969. */
  66970. makeObserverTopPriority(observer: Observer<T>): void;
  66971. /**
  66972. * Moves the observable to the bottom of the observer list making it get called last when notified
  66973. * @param observer the observer to move
  66974. */
  66975. makeObserverBottomPriority(observer: Observer<T>): void;
  66976. /**
  66977. * Notify all Observers by calling their respective callback with the given data
  66978. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66979. * @param eventData defines the data to send to all observers
  66980. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66981. * @param target defines the original target of the state
  66982. * @param currentTarget defines the current target of the state
  66983. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66984. */
  66985. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66986. /**
  66987. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66988. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66989. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66990. * and it is crucial that all callbacks will be executed.
  66991. * The order of the callbacks is kept, callbacks are not executed parallel.
  66992. *
  66993. * @param eventData The data to be sent to each callback
  66994. * @param mask is used to filter observers defaults to -1
  66995. * @param target defines the callback target (see EventState)
  66996. * @param currentTarget defines he current object in the bubbling phase
  66997. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66998. */
  66999. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67000. /**
  67001. * Notify a specific observer
  67002. * @param observer defines the observer to notify
  67003. * @param eventData defines the data to be sent to each callback
  67004. * @param mask is used to filter observers defaults to -1
  67005. */
  67006. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67007. /**
  67008. * Gets a boolean indicating if the observable has at least one observer
  67009. * @returns true is the Observable has at least one Observer registered
  67010. */
  67011. hasObservers(): boolean;
  67012. /**
  67013. * Clear the list of observers
  67014. */
  67015. clear(): void;
  67016. /**
  67017. * Clone the current observable
  67018. * @returns a new observable
  67019. */
  67020. clone(): Observable<T>;
  67021. /**
  67022. * Does this observable handles observer registered with a given mask
  67023. * @param mask defines the mask to be tested
  67024. * @return whether or not one observer registered with the given mask is handeled
  67025. **/
  67026. hasSpecificMask(mask?: number): boolean;
  67027. }
  67028. }
  67029. declare module BABYLON {
  67030. /**
  67031. * Class used to help managing file picking and drag'n'drop
  67032. * File Storage
  67033. */
  67034. export class FilesInputStore {
  67035. /**
  67036. * List of files ready to be loaded
  67037. */
  67038. static FilesToLoad: {
  67039. [key: string]: File;
  67040. };
  67041. }
  67042. }
  67043. declare module BABYLON {
  67044. /** Defines the cross module used constants to avoid circular dependncies */
  67045. export class Constants {
  67046. /** Defines that alpha blending is disabled */
  67047. static readonly ALPHA_DISABLE: number;
  67048. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67049. static readonly ALPHA_ADD: number;
  67050. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67051. static readonly ALPHA_COMBINE: number;
  67052. /** Defines that alpha blending to DEST - SRC * DEST */
  67053. static readonly ALPHA_SUBTRACT: number;
  67054. /** Defines that alpha blending to SRC * DEST */
  67055. static readonly ALPHA_MULTIPLY: number;
  67056. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67057. static readonly ALPHA_MAXIMIZED: number;
  67058. /** Defines that alpha blending to SRC + DEST */
  67059. static readonly ALPHA_ONEONE: number;
  67060. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67061. static readonly ALPHA_PREMULTIPLIED: number;
  67062. /**
  67063. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67064. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67065. */
  67066. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67067. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67068. static readonly ALPHA_INTERPOLATE: number;
  67069. /**
  67070. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67071. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67072. */
  67073. static readonly ALPHA_SCREENMODE: number;
  67074. /** Defines that the ressource is not delayed*/
  67075. static readonly DELAYLOADSTATE_NONE: number;
  67076. /** Defines that the ressource was successfully delay loaded */
  67077. static readonly DELAYLOADSTATE_LOADED: number;
  67078. /** Defines that the ressource is currently delay loading */
  67079. static readonly DELAYLOADSTATE_LOADING: number;
  67080. /** Defines that the ressource is delayed and has not started loading */
  67081. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67083. static readonly NEVER: number;
  67084. /** 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 */
  67085. static readonly ALWAYS: number;
  67086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67087. static readonly LESS: number;
  67088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67089. static readonly EQUAL: number;
  67090. /** 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 */
  67091. static readonly LEQUAL: number;
  67092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67093. static readonly GREATER: number;
  67094. /** 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 */
  67095. static readonly GEQUAL: number;
  67096. /** 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 */
  67097. static readonly NOTEQUAL: number;
  67098. /** Passed to stencilOperation to specify that stencil value must be kept */
  67099. static readonly KEEP: number;
  67100. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67101. static readonly REPLACE: number;
  67102. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67103. static readonly INCR: number;
  67104. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67105. static readonly DECR: number;
  67106. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67107. static readonly INVERT: number;
  67108. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67109. static readonly INCR_WRAP: number;
  67110. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67111. static readonly DECR_WRAP: number;
  67112. /** Texture is not repeating outside of 0..1 UVs */
  67113. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67114. /** Texture is repeating outside of 0..1 UVs */
  67115. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67116. /** Texture is repeating and mirrored */
  67117. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67118. /** ALPHA */
  67119. static readonly TEXTUREFORMAT_ALPHA: number;
  67120. /** LUMINANCE */
  67121. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67122. /** LUMINANCE_ALPHA */
  67123. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67124. /** RGB */
  67125. static readonly TEXTUREFORMAT_RGB: number;
  67126. /** RGBA */
  67127. static readonly TEXTUREFORMAT_RGBA: number;
  67128. /** RED */
  67129. static readonly TEXTUREFORMAT_RED: number;
  67130. /** RED (2nd reference) */
  67131. static readonly TEXTUREFORMAT_R: number;
  67132. /** RG */
  67133. static readonly TEXTUREFORMAT_RG: number;
  67134. /** RED_INTEGER */
  67135. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67136. /** RED_INTEGER (2nd reference) */
  67137. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67138. /** RG_INTEGER */
  67139. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67140. /** RGB_INTEGER */
  67141. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67142. /** RGBA_INTEGER */
  67143. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67144. /** UNSIGNED_BYTE */
  67145. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67146. /** UNSIGNED_BYTE (2nd reference) */
  67147. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67148. /** FLOAT */
  67149. static readonly TEXTURETYPE_FLOAT: number;
  67150. /** HALF_FLOAT */
  67151. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67152. /** BYTE */
  67153. static readonly TEXTURETYPE_BYTE: number;
  67154. /** SHORT */
  67155. static readonly TEXTURETYPE_SHORT: number;
  67156. /** UNSIGNED_SHORT */
  67157. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67158. /** INT */
  67159. static readonly TEXTURETYPE_INT: number;
  67160. /** UNSIGNED_INT */
  67161. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67162. /** UNSIGNED_SHORT_4_4_4_4 */
  67163. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67164. /** UNSIGNED_SHORT_5_5_5_1 */
  67165. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67166. /** UNSIGNED_SHORT_5_6_5 */
  67167. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67168. /** UNSIGNED_INT_2_10_10_10_REV */
  67169. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67170. /** UNSIGNED_INT_24_8 */
  67171. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67172. /** UNSIGNED_INT_10F_11F_11F_REV */
  67173. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67174. /** UNSIGNED_INT_5_9_9_9_REV */
  67175. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67176. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67177. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67178. /** nearest is mag = nearest and min = nearest and mip = linear */
  67179. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67181. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67182. /** Trilinear is mag = linear and min = linear and mip = linear */
  67183. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67184. /** nearest is mag = nearest and min = nearest and mip = linear */
  67185. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67187. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67188. /** Trilinear is mag = linear and min = linear and mip = linear */
  67189. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67190. /** mag = nearest and min = nearest and mip = nearest */
  67191. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67192. /** mag = nearest and min = linear and mip = nearest */
  67193. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67194. /** mag = nearest and min = linear and mip = linear */
  67195. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67196. /** mag = nearest and min = linear and mip = none */
  67197. static readonly TEXTURE_NEAREST_LINEAR: number;
  67198. /** mag = nearest and min = nearest and mip = none */
  67199. static readonly TEXTURE_NEAREST_NEAREST: number;
  67200. /** mag = linear and min = nearest and mip = nearest */
  67201. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67202. /** mag = linear and min = nearest and mip = linear */
  67203. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67204. /** mag = linear and min = linear and mip = none */
  67205. static readonly TEXTURE_LINEAR_LINEAR: number;
  67206. /** mag = linear and min = nearest and mip = none */
  67207. static readonly TEXTURE_LINEAR_NEAREST: number;
  67208. /** Explicit coordinates mode */
  67209. static readonly TEXTURE_EXPLICIT_MODE: number;
  67210. /** Spherical coordinates mode */
  67211. static readonly TEXTURE_SPHERICAL_MODE: number;
  67212. /** Planar coordinates mode */
  67213. static readonly TEXTURE_PLANAR_MODE: number;
  67214. /** Cubic coordinates mode */
  67215. static readonly TEXTURE_CUBIC_MODE: number;
  67216. /** Projection coordinates mode */
  67217. static readonly TEXTURE_PROJECTION_MODE: number;
  67218. /** Skybox coordinates mode */
  67219. static readonly TEXTURE_SKYBOX_MODE: number;
  67220. /** Inverse Cubic coordinates mode */
  67221. static readonly TEXTURE_INVCUBIC_MODE: number;
  67222. /** Equirectangular coordinates mode */
  67223. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67224. /** Equirectangular Fixed coordinates mode */
  67225. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67226. /** Equirectangular Fixed Mirrored coordinates mode */
  67227. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67228. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67229. static readonly SCALEMODE_FLOOR: number;
  67230. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67231. static readonly SCALEMODE_NEAREST: number;
  67232. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67233. static readonly SCALEMODE_CEILING: number;
  67234. /**
  67235. * The dirty texture flag value
  67236. */
  67237. static readonly MATERIAL_TextureDirtyFlag: number;
  67238. /**
  67239. * The dirty light flag value
  67240. */
  67241. static readonly MATERIAL_LightDirtyFlag: number;
  67242. /**
  67243. * The dirty fresnel flag value
  67244. */
  67245. static readonly MATERIAL_FresnelDirtyFlag: number;
  67246. /**
  67247. * The dirty attribute flag value
  67248. */
  67249. static readonly MATERIAL_AttributesDirtyFlag: number;
  67250. /**
  67251. * The dirty misc flag value
  67252. */
  67253. static readonly MATERIAL_MiscDirtyFlag: number;
  67254. /**
  67255. * The all dirty flag value
  67256. */
  67257. static readonly MATERIAL_AllDirtyFlag: number;
  67258. /**
  67259. * Returns the triangle fill mode
  67260. */
  67261. static readonly MATERIAL_TriangleFillMode: number;
  67262. /**
  67263. * Returns the wireframe mode
  67264. */
  67265. static readonly MATERIAL_WireFrameFillMode: number;
  67266. /**
  67267. * Returns the point fill mode
  67268. */
  67269. static readonly MATERIAL_PointFillMode: number;
  67270. /**
  67271. * Returns the point list draw mode
  67272. */
  67273. static readonly MATERIAL_PointListDrawMode: number;
  67274. /**
  67275. * Returns the line list draw mode
  67276. */
  67277. static readonly MATERIAL_LineListDrawMode: number;
  67278. /**
  67279. * Returns the line loop draw mode
  67280. */
  67281. static readonly MATERIAL_LineLoopDrawMode: number;
  67282. /**
  67283. * Returns the line strip draw mode
  67284. */
  67285. static readonly MATERIAL_LineStripDrawMode: number;
  67286. /**
  67287. * Returns the triangle strip draw mode
  67288. */
  67289. static readonly MATERIAL_TriangleStripDrawMode: number;
  67290. /**
  67291. * Returns the triangle fan draw mode
  67292. */
  67293. static readonly MATERIAL_TriangleFanDrawMode: number;
  67294. /**
  67295. * Stores the clock-wise side orientation
  67296. */
  67297. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67298. /**
  67299. * Stores the counter clock-wise side orientation
  67300. */
  67301. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67302. /**
  67303. * Nothing
  67304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67305. */
  67306. static readonly ACTION_NothingTrigger: number;
  67307. /**
  67308. * On pick
  67309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67310. */
  67311. static readonly ACTION_OnPickTrigger: number;
  67312. /**
  67313. * On left pick
  67314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67315. */
  67316. static readonly ACTION_OnLeftPickTrigger: number;
  67317. /**
  67318. * On right pick
  67319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67320. */
  67321. static readonly ACTION_OnRightPickTrigger: number;
  67322. /**
  67323. * On center pick
  67324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67325. */
  67326. static readonly ACTION_OnCenterPickTrigger: number;
  67327. /**
  67328. * On pick down
  67329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67330. */
  67331. static readonly ACTION_OnPickDownTrigger: number;
  67332. /**
  67333. * On double pick
  67334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67335. */
  67336. static readonly ACTION_OnDoublePickTrigger: number;
  67337. /**
  67338. * On pick up
  67339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67340. */
  67341. static readonly ACTION_OnPickUpTrigger: number;
  67342. /**
  67343. * On pick out.
  67344. * This trigger will only be raised if you also declared a OnPickDown
  67345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67346. */
  67347. static readonly ACTION_OnPickOutTrigger: number;
  67348. /**
  67349. * On long press
  67350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67351. */
  67352. static readonly ACTION_OnLongPressTrigger: number;
  67353. /**
  67354. * On pointer over
  67355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67356. */
  67357. static readonly ACTION_OnPointerOverTrigger: number;
  67358. /**
  67359. * On pointer out
  67360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67361. */
  67362. static readonly ACTION_OnPointerOutTrigger: number;
  67363. /**
  67364. * On every frame
  67365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67366. */
  67367. static readonly ACTION_OnEveryFrameTrigger: number;
  67368. /**
  67369. * On intersection enter
  67370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67371. */
  67372. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67373. /**
  67374. * On intersection exit
  67375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67376. */
  67377. static readonly ACTION_OnIntersectionExitTrigger: number;
  67378. /**
  67379. * On key down
  67380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67381. */
  67382. static readonly ACTION_OnKeyDownTrigger: number;
  67383. /**
  67384. * On key up
  67385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67386. */
  67387. static readonly ACTION_OnKeyUpTrigger: number;
  67388. /**
  67389. * Billboard mode will only apply to Y axis
  67390. */
  67391. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67392. /**
  67393. * Billboard mode will apply to all axes
  67394. */
  67395. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67396. /**
  67397. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67398. */
  67399. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67400. /**
  67401. * Gets or sets base Assets URL
  67402. */
  67403. static PARTICLES_BaseAssetsUrl: string;
  67404. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67405. * Test order :
  67406. * Is the bounding sphere outside the frustum ?
  67407. * If not, are the bounding box vertices outside the frustum ?
  67408. * It not, then the cullable object is in the frustum.
  67409. */
  67410. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67411. /** Culling strategy : Bounding Sphere Only.
  67412. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67413. * It's also less accurate than the standard because some not visible objects can still be selected.
  67414. * Test : is the bounding sphere outside the frustum ?
  67415. * If not, then the cullable object is in the frustum.
  67416. */
  67417. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67418. /** Culling strategy : Optimistic Inclusion.
  67419. * This in an inclusion test first, then the standard exclusion test.
  67420. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67421. * 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.
  67422. * Anyway, it's as accurate as the standard strategy.
  67423. * Test :
  67424. * Is the cullable object bounding sphere center in the frustum ?
  67425. * If not, apply the default culling strategy.
  67426. */
  67427. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67428. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67429. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67430. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67431. * 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.
  67432. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67433. * Test :
  67434. * Is the cullable object bounding sphere center in the frustum ?
  67435. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67436. */
  67437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67438. /**
  67439. * No logging while loading
  67440. */
  67441. static readonly SCENELOADER_NO_LOGGING: number;
  67442. /**
  67443. * Minimal logging while loading
  67444. */
  67445. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67446. /**
  67447. * Summary logging while loading
  67448. */
  67449. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67450. /**
  67451. * Detailled logging while loading
  67452. */
  67453. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67454. }
  67455. }
  67456. declare module BABYLON {
  67457. /**
  67458. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67459. * Babylon.js
  67460. */
  67461. export class DomManagement {
  67462. /**
  67463. * Checks if the window object exists
  67464. * @returns true if the window object exists
  67465. */
  67466. static IsWindowObjectExist(): boolean;
  67467. /**
  67468. * Extracts text content from a DOM element hierarchy
  67469. * @param element defines the root element
  67470. * @returns a string
  67471. */
  67472. static GetDOMTextContent(element: HTMLElement): string;
  67473. }
  67474. }
  67475. declare module BABYLON {
  67476. /**
  67477. * Logger used througouht the application to allow configuration of
  67478. * the log level required for the messages.
  67479. */
  67480. export class Logger {
  67481. /**
  67482. * No log
  67483. */
  67484. static readonly NoneLogLevel: number;
  67485. /**
  67486. * Only message logs
  67487. */
  67488. static readonly MessageLogLevel: number;
  67489. /**
  67490. * Only warning logs
  67491. */
  67492. static readonly WarningLogLevel: number;
  67493. /**
  67494. * Only error logs
  67495. */
  67496. static readonly ErrorLogLevel: number;
  67497. /**
  67498. * All logs
  67499. */
  67500. static readonly AllLogLevel: number;
  67501. private static _LogCache;
  67502. /**
  67503. * Gets a value indicating the number of loading errors
  67504. * @ignorenaming
  67505. */
  67506. static errorsCount: number;
  67507. /**
  67508. * Callback called when a new log is added
  67509. */
  67510. static OnNewCacheEntry: (entry: string) => void;
  67511. private static _AddLogEntry;
  67512. private static _FormatMessage;
  67513. private static _LogDisabled;
  67514. private static _LogEnabled;
  67515. private static _WarnDisabled;
  67516. private static _WarnEnabled;
  67517. private static _ErrorDisabled;
  67518. private static _ErrorEnabled;
  67519. /**
  67520. * Log a message to the console
  67521. */
  67522. static Log: (message: string) => void;
  67523. /**
  67524. * Write a warning message to the console
  67525. */
  67526. static Warn: (message: string) => void;
  67527. /**
  67528. * Write an error message to the console
  67529. */
  67530. static Error: (message: string) => void;
  67531. /**
  67532. * Gets current log cache (list of logs)
  67533. */
  67534. static readonly LogCache: string;
  67535. /**
  67536. * Clears the log cache
  67537. */
  67538. static ClearLogCache(): void;
  67539. /**
  67540. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67541. */
  67542. static LogLevels: number;
  67543. }
  67544. }
  67545. declare module BABYLON {
  67546. /** @hidden */
  67547. export class _TypeStore {
  67548. /** @hidden */
  67549. static RegisteredTypes: {
  67550. [key: string]: Object;
  67551. };
  67552. /** @hidden */
  67553. static GetClass(fqdn: string): any;
  67554. }
  67555. }
  67556. declare module BABYLON {
  67557. /**
  67558. * Class containing a set of static utilities functions for deep copy.
  67559. */
  67560. export class DeepCopier {
  67561. /**
  67562. * Tries to copy an object by duplicating every property
  67563. * @param source defines the source object
  67564. * @param destination defines the target object
  67565. * @param doNotCopyList defines a list of properties to avoid
  67566. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67567. */
  67568. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67569. }
  67570. }
  67571. declare module BABYLON {
  67572. /**
  67573. * Class containing a set of static utilities functions for precision date
  67574. */
  67575. export class PrecisionDate {
  67576. /**
  67577. * Gets either window.performance.now() if supported or Date.now() else
  67578. */
  67579. static readonly Now: number;
  67580. }
  67581. }
  67582. declare module BABYLON {
  67583. /** @hidden */
  67584. export class _DevTools {
  67585. static WarnImport(name: string): string;
  67586. }
  67587. }
  67588. declare module BABYLON {
  67589. /**
  67590. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67591. */
  67592. export class WebRequest {
  67593. private _xhr;
  67594. /**
  67595. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67596. * i.e. when loading files, where the server/service expects an Authorization header
  67597. */
  67598. static CustomRequestHeaders: {
  67599. [key: string]: string;
  67600. };
  67601. /**
  67602. * Add callback functions in this array to update all the requests before they get sent to the network
  67603. */
  67604. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67605. private _injectCustomRequestHeaders;
  67606. /**
  67607. * Gets or sets a function to be called when loading progress changes
  67608. */
  67609. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67610. /**
  67611. * Returns client's state
  67612. */
  67613. readonly readyState: number;
  67614. /**
  67615. * Returns client's status
  67616. */
  67617. readonly status: number;
  67618. /**
  67619. * Returns client's status as a text
  67620. */
  67621. readonly statusText: string;
  67622. /**
  67623. * Returns client's response
  67624. */
  67625. readonly response: any;
  67626. /**
  67627. * Returns client's response url
  67628. */
  67629. readonly responseURL: string;
  67630. /**
  67631. * Returns client's response as text
  67632. */
  67633. readonly responseText: string;
  67634. /**
  67635. * Gets or sets the expected response type
  67636. */
  67637. responseType: XMLHttpRequestResponseType;
  67638. /** @hidden */
  67639. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67640. /** @hidden */
  67641. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67642. /**
  67643. * Cancels any network activity
  67644. */
  67645. abort(): void;
  67646. /**
  67647. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67648. * @param body defines an optional request body
  67649. */
  67650. send(body?: Document | BodyInit | null): void;
  67651. /**
  67652. * Sets the request method, request URL
  67653. * @param method defines the method to use (GET, POST, etc..)
  67654. * @param url defines the url to connect with
  67655. */
  67656. open(method: string, url: string): void;
  67657. }
  67658. }
  67659. declare module BABYLON {
  67660. /**
  67661. * Class used to evalaute queries containing `and` and `or` operators
  67662. */
  67663. export class AndOrNotEvaluator {
  67664. /**
  67665. * Evaluate a query
  67666. * @param query defines the query to evaluate
  67667. * @param evaluateCallback defines the callback used to filter result
  67668. * @returns true if the query matches
  67669. */
  67670. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67671. private static _HandleParenthesisContent;
  67672. private static _SimplifyNegation;
  67673. }
  67674. }
  67675. declare module BABYLON {
  67676. /**
  67677. * Class used to store custom tags
  67678. */
  67679. export class Tags {
  67680. /**
  67681. * Adds support for tags on the given object
  67682. * @param obj defines the object to use
  67683. */
  67684. static EnableFor(obj: any): void;
  67685. /**
  67686. * Removes tags support
  67687. * @param obj defines the object to use
  67688. */
  67689. static DisableFor(obj: any): void;
  67690. /**
  67691. * Gets a boolean indicating if the given object has tags
  67692. * @param obj defines the object to use
  67693. * @returns a boolean
  67694. */
  67695. static HasTags(obj: any): boolean;
  67696. /**
  67697. * Gets the tags available on a given object
  67698. * @param obj defines the object to use
  67699. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67700. * @returns the tags
  67701. */
  67702. static GetTags(obj: any, asString?: boolean): any;
  67703. /**
  67704. * Adds tags to an object
  67705. * @param obj defines the object to use
  67706. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67707. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67708. */
  67709. static AddTagsTo(obj: any, tagsString: string): void;
  67710. /**
  67711. * @hidden
  67712. */
  67713. static _AddTagTo(obj: any, tag: string): void;
  67714. /**
  67715. * Removes specific tags from a specific object
  67716. * @param obj defines the object to use
  67717. * @param tagsString defines the tags to remove
  67718. */
  67719. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67720. /**
  67721. * @hidden
  67722. */
  67723. static _RemoveTagFrom(obj: any, tag: string): void;
  67724. /**
  67725. * Defines if tags hosted on an object match a given query
  67726. * @param obj defines the object to use
  67727. * @param tagsQuery defines the tag query
  67728. * @returns a boolean
  67729. */
  67730. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67731. }
  67732. }
  67733. declare module BABYLON {
  67734. /**
  67735. * Manages the defines for the Material
  67736. */
  67737. export class MaterialDefines {
  67738. /** @hidden */
  67739. protected _keys: string[];
  67740. private _isDirty;
  67741. /** @hidden */
  67742. _renderId: number;
  67743. /** @hidden */
  67744. _areLightsDirty: boolean;
  67745. /** @hidden */
  67746. _areAttributesDirty: boolean;
  67747. /** @hidden */
  67748. _areTexturesDirty: boolean;
  67749. /** @hidden */
  67750. _areFresnelDirty: boolean;
  67751. /** @hidden */
  67752. _areMiscDirty: boolean;
  67753. /** @hidden */
  67754. _areImageProcessingDirty: boolean;
  67755. /** @hidden */
  67756. _normals: boolean;
  67757. /** @hidden */
  67758. _uvs: boolean;
  67759. /** @hidden */
  67760. _needNormals: boolean;
  67761. /** @hidden */
  67762. _needUVs: boolean;
  67763. [id: string]: any;
  67764. /**
  67765. * Specifies if the material needs to be re-calculated
  67766. */
  67767. readonly isDirty: boolean;
  67768. /**
  67769. * Marks the material to indicate that it has been re-calculated
  67770. */
  67771. markAsProcessed(): void;
  67772. /**
  67773. * Marks the material to indicate that it needs to be re-calculated
  67774. */
  67775. markAsUnprocessed(): void;
  67776. /**
  67777. * Marks the material to indicate all of its defines need to be re-calculated
  67778. */
  67779. markAllAsDirty(): void;
  67780. /**
  67781. * Marks the material to indicate that image processing needs to be re-calculated
  67782. */
  67783. markAsImageProcessingDirty(): void;
  67784. /**
  67785. * Marks the material to indicate the lights need to be re-calculated
  67786. */
  67787. markAsLightDirty(): void;
  67788. /**
  67789. * Marks the attribute state as changed
  67790. */
  67791. markAsAttributesDirty(): void;
  67792. /**
  67793. * Marks the texture state as changed
  67794. */
  67795. markAsTexturesDirty(): void;
  67796. /**
  67797. * Marks the fresnel state as changed
  67798. */
  67799. markAsFresnelDirty(): void;
  67800. /**
  67801. * Marks the misc state as changed
  67802. */
  67803. markAsMiscDirty(): void;
  67804. /**
  67805. * Rebuilds the material defines
  67806. */
  67807. rebuild(): void;
  67808. /**
  67809. * Specifies if two material defines are equal
  67810. * @param other - A material define instance to compare to
  67811. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67812. */
  67813. isEqual(other: MaterialDefines): boolean;
  67814. /**
  67815. * Clones this instance's defines to another instance
  67816. * @param other - material defines to clone values to
  67817. */
  67818. cloneTo(other: MaterialDefines): void;
  67819. /**
  67820. * Resets the material define values
  67821. */
  67822. reset(): void;
  67823. /**
  67824. * Converts the material define values to a string
  67825. * @returns - String of material define information
  67826. */
  67827. toString(): string;
  67828. }
  67829. }
  67830. declare module BABYLON {
  67831. /**
  67832. * Class used to store and describe the pipeline context associated with an effect
  67833. */
  67834. export interface IPipelineContext {
  67835. /**
  67836. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67837. */
  67838. isAsync: boolean;
  67839. /**
  67840. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67841. */
  67842. isReady: boolean;
  67843. /** @hidden */
  67844. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67845. }
  67846. }
  67847. declare module BABYLON {
  67848. /**
  67849. * Class used to store gfx data (like WebGLBuffer)
  67850. */
  67851. export class DataBuffer {
  67852. /**
  67853. * Gets or sets the number of objects referencing this buffer
  67854. */
  67855. references: number;
  67856. /** Gets or sets the size of the underlying buffer */
  67857. capacity: number;
  67858. /**
  67859. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67860. */
  67861. is32Bits: boolean;
  67862. /**
  67863. * Gets the underlying buffer
  67864. */
  67865. readonly underlyingResource: any;
  67866. }
  67867. }
  67868. declare module BABYLON {
  67869. /** @hidden */
  67870. export interface IShaderProcessor {
  67871. attributeProcessor?: (attribute: string) => string;
  67872. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67873. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67874. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67875. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67876. lineProcessor?: (line: string, isFragment: boolean) => string;
  67877. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67878. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67879. }
  67880. }
  67881. declare module BABYLON {
  67882. /** @hidden */
  67883. export interface ProcessingOptions {
  67884. defines: string[];
  67885. indexParameters: any;
  67886. isFragment: boolean;
  67887. shouldUseHighPrecisionShader: boolean;
  67888. supportsUniformBuffers: boolean;
  67889. shadersRepository: string;
  67890. includesShadersStore: {
  67891. [key: string]: string;
  67892. };
  67893. processor?: IShaderProcessor;
  67894. version: string;
  67895. platformName: string;
  67896. lookForClosingBracketForUniformBuffer?: boolean;
  67897. }
  67898. }
  67899. declare module BABYLON {
  67900. /** @hidden */
  67901. export class ShaderCodeNode {
  67902. line: string;
  67903. children: ShaderCodeNode[];
  67904. additionalDefineKey?: string;
  67905. additionalDefineValue?: string;
  67906. isValid(preprocessors: {
  67907. [key: string]: string;
  67908. }): boolean;
  67909. process(preprocessors: {
  67910. [key: string]: string;
  67911. }, options: ProcessingOptions): string;
  67912. }
  67913. }
  67914. declare module BABYLON {
  67915. /** @hidden */
  67916. export class ShaderCodeCursor {
  67917. private _lines;
  67918. lineIndex: number;
  67919. readonly currentLine: string;
  67920. readonly canRead: boolean;
  67921. lines: string[];
  67922. }
  67923. }
  67924. declare module BABYLON {
  67925. /** @hidden */
  67926. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67927. process(preprocessors: {
  67928. [key: string]: string;
  67929. }, options: ProcessingOptions): string;
  67930. }
  67931. }
  67932. declare module BABYLON {
  67933. /** @hidden */
  67934. export class ShaderDefineExpression {
  67935. isTrue(preprocessors: {
  67936. [key: string]: string;
  67937. }): boolean;
  67938. }
  67939. }
  67940. declare module BABYLON {
  67941. /** @hidden */
  67942. export class ShaderCodeTestNode extends ShaderCodeNode {
  67943. testExpression: ShaderDefineExpression;
  67944. isValid(preprocessors: {
  67945. [key: string]: string;
  67946. }): boolean;
  67947. }
  67948. }
  67949. declare module BABYLON {
  67950. /** @hidden */
  67951. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67952. define: string;
  67953. not: boolean;
  67954. constructor(define: string, not?: boolean);
  67955. isTrue(preprocessors: {
  67956. [key: string]: string;
  67957. }): boolean;
  67958. }
  67959. }
  67960. declare module BABYLON {
  67961. /** @hidden */
  67962. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  67963. leftOperand: ShaderDefineExpression;
  67964. rightOperand: ShaderDefineExpression;
  67965. isTrue(preprocessors: {
  67966. [key: string]: string;
  67967. }): boolean;
  67968. }
  67969. }
  67970. declare module BABYLON {
  67971. /** @hidden */
  67972. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  67973. leftOperand: ShaderDefineExpression;
  67974. rightOperand: ShaderDefineExpression;
  67975. isTrue(preprocessors: {
  67976. [key: string]: string;
  67977. }): boolean;
  67978. }
  67979. }
  67980. declare module BABYLON {
  67981. /** @hidden */
  67982. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  67983. define: string;
  67984. operand: string;
  67985. testValue: string;
  67986. constructor(define: string, operand: string, testValue: string);
  67987. isTrue(preprocessors: {
  67988. [key: string]: string;
  67989. }): boolean;
  67990. }
  67991. }
  67992. declare module BABYLON {
  67993. /** @hidden */
  67994. export class ShaderProcessor {
  67995. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  67996. private static _ProcessPrecision;
  67997. private static _ExtractOperation;
  67998. private static _BuildSubExpression;
  67999. private static _BuildExpression;
  68000. private static _MoveCursorWithinIf;
  68001. private static _MoveCursor;
  68002. private static _EvaluatePreProcessors;
  68003. private static _PreparePreProcessors;
  68004. private static _ProcessShaderConversion;
  68005. private static _ProcessIncludes;
  68006. }
  68007. }
  68008. declare module BABYLON {
  68009. /**
  68010. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68011. */
  68012. export class PerformanceMonitor {
  68013. private _enabled;
  68014. private _rollingFrameTime;
  68015. private _lastFrameTimeMs;
  68016. /**
  68017. * constructor
  68018. * @param frameSampleSize The number of samples required to saturate the sliding window
  68019. */
  68020. constructor(frameSampleSize?: number);
  68021. /**
  68022. * Samples current frame
  68023. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68024. */
  68025. sampleFrame(timeMs?: number): void;
  68026. /**
  68027. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68028. */
  68029. readonly averageFrameTime: number;
  68030. /**
  68031. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68032. */
  68033. readonly averageFrameTimeVariance: number;
  68034. /**
  68035. * Returns the frame time of the most recent frame
  68036. */
  68037. readonly instantaneousFrameTime: number;
  68038. /**
  68039. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68040. */
  68041. readonly averageFPS: number;
  68042. /**
  68043. * Returns the average framerate in frames per second using the most recent frame time
  68044. */
  68045. readonly instantaneousFPS: number;
  68046. /**
  68047. * Returns true if enough samples have been taken to completely fill the sliding window
  68048. */
  68049. readonly isSaturated: boolean;
  68050. /**
  68051. * Enables contributions to the sliding window sample set
  68052. */
  68053. enable(): void;
  68054. /**
  68055. * Disables contributions to the sliding window sample set
  68056. * Samples will not be interpolated over the disabled period
  68057. */
  68058. disable(): void;
  68059. /**
  68060. * Returns true if sampling is enabled
  68061. */
  68062. readonly isEnabled: boolean;
  68063. /**
  68064. * Resets performance monitor
  68065. */
  68066. reset(): void;
  68067. }
  68068. /**
  68069. * RollingAverage
  68070. *
  68071. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68072. */
  68073. export class RollingAverage {
  68074. /**
  68075. * Current average
  68076. */
  68077. average: number;
  68078. /**
  68079. * Current variance
  68080. */
  68081. variance: number;
  68082. protected _samples: Array<number>;
  68083. protected _sampleCount: number;
  68084. protected _pos: number;
  68085. protected _m2: number;
  68086. /**
  68087. * constructor
  68088. * @param length The number of samples required to saturate the sliding window
  68089. */
  68090. constructor(length: number);
  68091. /**
  68092. * Adds a sample to the sample set
  68093. * @param v The sample value
  68094. */
  68095. add(v: number): void;
  68096. /**
  68097. * Returns previously added values or null if outside of history or outside the sliding window domain
  68098. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68099. * @return Value previously recorded with add() or null if outside of range
  68100. */
  68101. history(i: number): number;
  68102. /**
  68103. * Returns true if enough samples have been taken to completely fill the sliding window
  68104. * @return true if sample-set saturated
  68105. */
  68106. isSaturated(): boolean;
  68107. /**
  68108. * Resets the rolling average (equivalent to 0 samples taken so far)
  68109. */
  68110. reset(): void;
  68111. /**
  68112. * Wraps a value around the sample range boundaries
  68113. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68114. * @return Wrapped position in sample range
  68115. */
  68116. protected _wrapPosition(i: number): number;
  68117. }
  68118. }
  68119. declare module BABYLON {
  68120. /**
  68121. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68122. * The underlying implementation relies on an associative array to ensure the best performances.
  68123. * The value can be anything including 'null' but except 'undefined'
  68124. */
  68125. export class StringDictionary<T> {
  68126. /**
  68127. * This will clear this dictionary and copy the content from the 'source' one.
  68128. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68129. * @param source the dictionary to take the content from and copy to this dictionary
  68130. */
  68131. copyFrom(source: StringDictionary<T>): void;
  68132. /**
  68133. * Get a value based from its key
  68134. * @param key the given key to get the matching value from
  68135. * @return the value if found, otherwise undefined is returned
  68136. */
  68137. get(key: string): T | undefined;
  68138. /**
  68139. * Get a value from its key or add it if it doesn't exist.
  68140. * This method will ensure you that a given key/data will be present in the dictionary.
  68141. * @param key the given key to get the matching value from
  68142. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68143. * The factory will only be invoked if there's no data for the given key.
  68144. * @return the value corresponding to the key.
  68145. */
  68146. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68147. /**
  68148. * Get a value from its key if present in the dictionary otherwise add it
  68149. * @param key the key to get the value from
  68150. * @param val if there's no such key/value pair in the dictionary add it with this value
  68151. * @return the value corresponding to the key
  68152. */
  68153. getOrAdd(key: string, val: T): T;
  68154. /**
  68155. * Check if there's a given key in the dictionary
  68156. * @param key the key to check for
  68157. * @return true if the key is present, false otherwise
  68158. */
  68159. contains(key: string): boolean;
  68160. /**
  68161. * Add a new key and its corresponding value
  68162. * @param key the key to add
  68163. * @param value the value corresponding to the key
  68164. * @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
  68165. */
  68166. add(key: string, value: T): boolean;
  68167. /**
  68168. * Update a specific value associated to a key
  68169. * @param key defines the key to use
  68170. * @param value defines the value to store
  68171. * @returns true if the value was updated (or false if the key was not found)
  68172. */
  68173. set(key: string, value: T): boolean;
  68174. /**
  68175. * Get the element of the given key and remove it from the dictionary
  68176. * @param key defines the key to search
  68177. * @returns the value associated with the key or null if not found
  68178. */
  68179. getAndRemove(key: string): Nullable<T>;
  68180. /**
  68181. * Remove a key/value from the dictionary.
  68182. * @param key the key to remove
  68183. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68184. */
  68185. remove(key: string): boolean;
  68186. /**
  68187. * Clear the whole content of the dictionary
  68188. */
  68189. clear(): void;
  68190. /**
  68191. * Gets the current count
  68192. */
  68193. readonly count: number;
  68194. /**
  68195. * Execute a callback on each key/val of the dictionary.
  68196. * Note that you can remove any element in this dictionary in the callback implementation
  68197. * @param callback the callback to execute on a given key/value pair
  68198. */
  68199. forEach(callback: (key: string, val: T) => void): void;
  68200. /**
  68201. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68202. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68203. * Note that you can remove any element in this dictionary in the callback implementation
  68204. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68205. * @returns the first item
  68206. */
  68207. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68208. private _count;
  68209. private _data;
  68210. }
  68211. }
  68212. declare module BABYLON {
  68213. /**
  68214. * Helper class that provides a small promise polyfill
  68215. */
  68216. export class PromisePolyfill {
  68217. /**
  68218. * Static function used to check if the polyfill is required
  68219. * If this is the case then the function will inject the polyfill to window.Promise
  68220. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68221. */
  68222. static Apply(force?: boolean): void;
  68223. }
  68224. }
  68225. declare module BABYLON {
  68226. /**
  68227. * Class used to store data that will be store in GPU memory
  68228. */
  68229. export class Buffer {
  68230. private _engine;
  68231. private _buffer;
  68232. /** @hidden */
  68233. _data: Nullable<DataArray>;
  68234. private _updatable;
  68235. private _instanced;
  68236. /**
  68237. * Gets the byte stride.
  68238. */
  68239. readonly byteStride: number;
  68240. /**
  68241. * Constructor
  68242. * @param engine the engine
  68243. * @param data the data to use for this buffer
  68244. * @param updatable whether the data is updatable
  68245. * @param stride the stride (optional)
  68246. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68247. * @param instanced whether the buffer is instanced (optional)
  68248. * @param useBytes set to true if the stride in in bytes (optional)
  68249. */
  68250. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68251. /**
  68252. * Create a new VertexBuffer based on the current buffer
  68253. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68254. * @param offset defines offset in the buffer (0 by default)
  68255. * @param size defines the size in floats of attributes (position is 3 for instance)
  68256. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68257. * @param instanced defines if the vertex buffer contains indexed data
  68258. * @param useBytes defines if the offset and stride are in bytes
  68259. * @returns the new vertex buffer
  68260. */
  68261. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68262. /**
  68263. * Gets a boolean indicating if the Buffer is updatable?
  68264. * @returns true if the buffer is updatable
  68265. */
  68266. isUpdatable(): boolean;
  68267. /**
  68268. * Gets current buffer's data
  68269. * @returns a DataArray or null
  68270. */
  68271. getData(): Nullable<DataArray>;
  68272. /**
  68273. * Gets underlying native buffer
  68274. * @returns underlying native buffer
  68275. */
  68276. getBuffer(): Nullable<DataBuffer>;
  68277. /**
  68278. * Gets the stride in float32 units (i.e. byte stride / 4).
  68279. * May not be an integer if the byte stride is not divisible by 4.
  68280. * DEPRECATED. Use byteStride instead.
  68281. * @returns the stride in float32 units
  68282. */
  68283. getStrideSize(): number;
  68284. /**
  68285. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68286. * @param data defines the data to store
  68287. */
  68288. create(data?: Nullable<DataArray>): void;
  68289. /** @hidden */
  68290. _rebuild(): void;
  68291. /**
  68292. * Update current buffer data
  68293. * @param data defines the data to store
  68294. */
  68295. update(data: DataArray): void;
  68296. /**
  68297. * Updates the data directly.
  68298. * @param data the new data
  68299. * @param offset the new offset
  68300. * @param vertexCount the vertex count (optional)
  68301. * @param useBytes set to true if the offset is in bytes
  68302. */
  68303. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68304. /**
  68305. * Release all resources
  68306. */
  68307. dispose(): void;
  68308. }
  68309. /**
  68310. * Specialized buffer used to store vertex data
  68311. */
  68312. export class VertexBuffer {
  68313. /** @hidden */
  68314. _buffer: Buffer;
  68315. private _kind;
  68316. private _size;
  68317. private _ownsBuffer;
  68318. private _instanced;
  68319. private _instanceDivisor;
  68320. /**
  68321. * The byte type.
  68322. */
  68323. static readonly BYTE: number;
  68324. /**
  68325. * The unsigned byte type.
  68326. */
  68327. static readonly UNSIGNED_BYTE: number;
  68328. /**
  68329. * The short type.
  68330. */
  68331. static readonly SHORT: number;
  68332. /**
  68333. * The unsigned short type.
  68334. */
  68335. static readonly UNSIGNED_SHORT: number;
  68336. /**
  68337. * The integer type.
  68338. */
  68339. static readonly INT: number;
  68340. /**
  68341. * The unsigned integer type.
  68342. */
  68343. static readonly UNSIGNED_INT: number;
  68344. /**
  68345. * The float type.
  68346. */
  68347. static readonly FLOAT: number;
  68348. /**
  68349. * Gets or sets the instance divisor when in instanced mode
  68350. */
  68351. instanceDivisor: number;
  68352. /**
  68353. * Gets the byte stride.
  68354. */
  68355. readonly byteStride: number;
  68356. /**
  68357. * Gets the byte offset.
  68358. */
  68359. readonly byteOffset: number;
  68360. /**
  68361. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68362. */
  68363. readonly normalized: boolean;
  68364. /**
  68365. * Gets the data type of each component in the array.
  68366. */
  68367. readonly type: number;
  68368. /**
  68369. * Constructor
  68370. * @param engine the engine
  68371. * @param data the data to use for this vertex buffer
  68372. * @param kind the vertex buffer kind
  68373. * @param updatable whether the data is updatable
  68374. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68375. * @param stride the stride (optional)
  68376. * @param instanced whether the buffer is instanced (optional)
  68377. * @param offset the offset of the data (optional)
  68378. * @param size the number of components (optional)
  68379. * @param type the type of the component (optional)
  68380. * @param normalized whether the data contains normalized data (optional)
  68381. * @param useBytes set to true if stride and offset are in bytes (optional)
  68382. */
  68383. 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);
  68384. /** @hidden */
  68385. _rebuild(): void;
  68386. /**
  68387. * Returns the kind of the VertexBuffer (string)
  68388. * @returns a string
  68389. */
  68390. getKind(): string;
  68391. /**
  68392. * Gets a boolean indicating if the VertexBuffer is updatable?
  68393. * @returns true if the buffer is updatable
  68394. */
  68395. isUpdatable(): boolean;
  68396. /**
  68397. * Gets current buffer's data
  68398. * @returns a DataArray or null
  68399. */
  68400. getData(): Nullable<DataArray>;
  68401. /**
  68402. * Gets underlying native buffer
  68403. * @returns underlying native buffer
  68404. */
  68405. getBuffer(): Nullable<DataBuffer>;
  68406. /**
  68407. * Gets the stride in float32 units (i.e. byte stride / 4).
  68408. * May not be an integer if the byte stride is not divisible by 4.
  68409. * DEPRECATED. Use byteStride instead.
  68410. * @returns the stride in float32 units
  68411. */
  68412. getStrideSize(): number;
  68413. /**
  68414. * Returns the offset as a multiple of the type byte length.
  68415. * DEPRECATED. Use byteOffset instead.
  68416. * @returns the offset in bytes
  68417. */
  68418. getOffset(): number;
  68419. /**
  68420. * Returns the number of components per vertex attribute (integer)
  68421. * @returns the size in float
  68422. */
  68423. getSize(): number;
  68424. /**
  68425. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68426. * @returns true if this buffer is instanced
  68427. */
  68428. getIsInstanced(): boolean;
  68429. /**
  68430. * Returns the instancing divisor, zero for non-instanced (integer).
  68431. * @returns a number
  68432. */
  68433. getInstanceDivisor(): number;
  68434. /**
  68435. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68436. * @param data defines the data to store
  68437. */
  68438. create(data?: DataArray): void;
  68439. /**
  68440. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68441. * This function will create a new buffer if the current one is not updatable
  68442. * @param data defines the data to store
  68443. */
  68444. update(data: DataArray): void;
  68445. /**
  68446. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68447. * Returns the directly updated WebGLBuffer.
  68448. * @param data the new data
  68449. * @param offset the new offset
  68450. * @param useBytes set to true if the offset is in bytes
  68451. */
  68452. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68453. /**
  68454. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68455. */
  68456. dispose(): void;
  68457. /**
  68458. * Enumerates each value of this vertex buffer as numbers.
  68459. * @param count the number of values to enumerate
  68460. * @param callback the callback function called for each value
  68461. */
  68462. forEach(count: number, callback: (value: number, index: number) => void): void;
  68463. /**
  68464. * Positions
  68465. */
  68466. static readonly PositionKind: string;
  68467. /**
  68468. * Normals
  68469. */
  68470. static readonly NormalKind: string;
  68471. /**
  68472. * Tangents
  68473. */
  68474. static readonly TangentKind: string;
  68475. /**
  68476. * Texture coordinates
  68477. */
  68478. static readonly UVKind: string;
  68479. /**
  68480. * Texture coordinates 2
  68481. */
  68482. static readonly UV2Kind: string;
  68483. /**
  68484. * Texture coordinates 3
  68485. */
  68486. static readonly UV3Kind: string;
  68487. /**
  68488. * Texture coordinates 4
  68489. */
  68490. static readonly UV4Kind: string;
  68491. /**
  68492. * Texture coordinates 5
  68493. */
  68494. static readonly UV5Kind: string;
  68495. /**
  68496. * Texture coordinates 6
  68497. */
  68498. static readonly UV6Kind: string;
  68499. /**
  68500. * Colors
  68501. */
  68502. static readonly ColorKind: string;
  68503. /**
  68504. * Matrix indices (for bones)
  68505. */
  68506. static readonly MatricesIndicesKind: string;
  68507. /**
  68508. * Matrix weights (for bones)
  68509. */
  68510. static readonly MatricesWeightsKind: string;
  68511. /**
  68512. * Additional matrix indices (for bones)
  68513. */
  68514. static readonly MatricesIndicesExtraKind: string;
  68515. /**
  68516. * Additional matrix weights (for bones)
  68517. */
  68518. static readonly MatricesWeightsExtraKind: string;
  68519. /**
  68520. * Deduces the stride given a kind.
  68521. * @param kind The kind string to deduce
  68522. * @returns The deduced stride
  68523. */
  68524. static DeduceStride(kind: string): number;
  68525. /**
  68526. * Gets the byte length of the given type.
  68527. * @param type the type
  68528. * @returns the number of bytes
  68529. */
  68530. static GetTypeByteLength(type: number): number;
  68531. /**
  68532. * Enumerates each value of the given parameters as numbers.
  68533. * @param data the data to enumerate
  68534. * @param byteOffset the byte offset of the data
  68535. * @param byteStride the byte stride of the data
  68536. * @param componentCount the number of components per element
  68537. * @param componentType the type of the component
  68538. * @param count the total number of components
  68539. * @param normalized whether the data is normalized
  68540. * @param callback the callback function called for each value
  68541. */
  68542. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68543. private static _GetFloatValue;
  68544. }
  68545. }
  68546. declare module BABYLON {
  68547. /**
  68548. * Class representing spherical harmonics coefficients to the 3rd degree
  68549. */
  68550. export class SphericalHarmonics {
  68551. /**
  68552. * Defines whether or not the harmonics have been prescaled for rendering.
  68553. */
  68554. preScaled: boolean;
  68555. /**
  68556. * The l0,0 coefficients of the spherical harmonics
  68557. */
  68558. l00: Vector3;
  68559. /**
  68560. * The l1,-1 coefficients of the spherical harmonics
  68561. */
  68562. l1_1: Vector3;
  68563. /**
  68564. * The l1,0 coefficients of the spherical harmonics
  68565. */
  68566. l10: Vector3;
  68567. /**
  68568. * The l1,1 coefficients of the spherical harmonics
  68569. */
  68570. l11: Vector3;
  68571. /**
  68572. * The l2,-2 coefficients of the spherical harmonics
  68573. */
  68574. l2_2: Vector3;
  68575. /**
  68576. * The l2,-1 coefficients of the spherical harmonics
  68577. */
  68578. l2_1: Vector3;
  68579. /**
  68580. * The l2,0 coefficients of the spherical harmonics
  68581. */
  68582. l20: Vector3;
  68583. /**
  68584. * The l2,1 coefficients of the spherical harmonics
  68585. */
  68586. l21: Vector3;
  68587. /**
  68588. * The l2,2 coefficients of the spherical harmonics
  68589. */
  68590. l22: Vector3;
  68591. /**
  68592. * Adds a light to the spherical harmonics
  68593. * @param direction the direction of the light
  68594. * @param color the color of the light
  68595. * @param deltaSolidAngle the delta solid angle of the light
  68596. */
  68597. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68598. /**
  68599. * Scales the spherical harmonics by the given amount
  68600. * @param scale the amount to scale
  68601. */
  68602. scaleInPlace(scale: number): void;
  68603. /**
  68604. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68605. *
  68606. * ```
  68607. * E_lm = A_l * L_lm
  68608. * ```
  68609. *
  68610. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68611. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68612. * the scaling factors are given in equation 9.
  68613. */
  68614. convertIncidentRadianceToIrradiance(): void;
  68615. /**
  68616. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68617. *
  68618. * ```
  68619. * L = (1/pi) * E * rho
  68620. * ```
  68621. *
  68622. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68623. */
  68624. convertIrradianceToLambertianRadiance(): void;
  68625. /**
  68626. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68627. * required operations at run time.
  68628. *
  68629. * This is simply done by scaling back the SH with Ylm constants parameter.
  68630. * The trigonometric part being applied by the shader at run time.
  68631. */
  68632. preScaleForRendering(): void;
  68633. /**
  68634. * Constructs a spherical harmonics from an array.
  68635. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68636. * @returns the spherical harmonics
  68637. */
  68638. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68639. /**
  68640. * Gets the spherical harmonics from polynomial
  68641. * @param polynomial the spherical polynomial
  68642. * @returns the spherical harmonics
  68643. */
  68644. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68645. }
  68646. /**
  68647. * Class representing spherical polynomial coefficients to the 3rd degree
  68648. */
  68649. export class SphericalPolynomial {
  68650. private _harmonics;
  68651. /**
  68652. * The spherical harmonics used to create the polynomials.
  68653. */
  68654. readonly preScaledHarmonics: SphericalHarmonics;
  68655. /**
  68656. * The x coefficients of the spherical polynomial
  68657. */
  68658. x: Vector3;
  68659. /**
  68660. * The y coefficients of the spherical polynomial
  68661. */
  68662. y: Vector3;
  68663. /**
  68664. * The z coefficients of the spherical polynomial
  68665. */
  68666. z: Vector3;
  68667. /**
  68668. * The xx coefficients of the spherical polynomial
  68669. */
  68670. xx: Vector3;
  68671. /**
  68672. * The yy coefficients of the spherical polynomial
  68673. */
  68674. yy: Vector3;
  68675. /**
  68676. * The zz coefficients of the spherical polynomial
  68677. */
  68678. zz: Vector3;
  68679. /**
  68680. * The xy coefficients of the spherical polynomial
  68681. */
  68682. xy: Vector3;
  68683. /**
  68684. * The yz coefficients of the spherical polynomial
  68685. */
  68686. yz: Vector3;
  68687. /**
  68688. * The zx coefficients of the spherical polynomial
  68689. */
  68690. zx: Vector3;
  68691. /**
  68692. * Adds an ambient color to the spherical polynomial
  68693. * @param color the color to add
  68694. */
  68695. addAmbient(color: Color3): void;
  68696. /**
  68697. * Scales the spherical polynomial by the given amount
  68698. * @param scale the amount to scale
  68699. */
  68700. scaleInPlace(scale: number): void;
  68701. /**
  68702. * Gets the spherical polynomial from harmonics
  68703. * @param harmonics the spherical harmonics
  68704. * @returns the spherical polynomial
  68705. */
  68706. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68707. /**
  68708. * Constructs a spherical polynomial from an array.
  68709. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68710. * @returns the spherical polynomial
  68711. */
  68712. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68713. }
  68714. }
  68715. declare module BABYLON {
  68716. /**
  68717. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68718. */
  68719. export interface CubeMapInfo {
  68720. /**
  68721. * The pixel array for the front face.
  68722. * This is stored in format, left to right, up to down format.
  68723. */
  68724. front: Nullable<ArrayBufferView>;
  68725. /**
  68726. * The pixel array for the back face.
  68727. * This is stored in format, left to right, up to down format.
  68728. */
  68729. back: Nullable<ArrayBufferView>;
  68730. /**
  68731. * The pixel array for the left face.
  68732. * This is stored in format, left to right, up to down format.
  68733. */
  68734. left: Nullable<ArrayBufferView>;
  68735. /**
  68736. * The pixel array for the right face.
  68737. * This is stored in format, left to right, up to down format.
  68738. */
  68739. right: Nullable<ArrayBufferView>;
  68740. /**
  68741. * The pixel array for the up face.
  68742. * This is stored in format, left to right, up to down format.
  68743. */
  68744. up: Nullable<ArrayBufferView>;
  68745. /**
  68746. * The pixel array for the down face.
  68747. * This is stored in format, left to right, up to down format.
  68748. */
  68749. down: Nullable<ArrayBufferView>;
  68750. /**
  68751. * The size of the cubemap stored.
  68752. *
  68753. * Each faces will be size * size pixels.
  68754. */
  68755. size: number;
  68756. /**
  68757. * The format of the texture.
  68758. *
  68759. * RGBA, RGB.
  68760. */
  68761. format: number;
  68762. /**
  68763. * The type of the texture data.
  68764. *
  68765. * UNSIGNED_INT, FLOAT.
  68766. */
  68767. type: number;
  68768. /**
  68769. * Specifies whether the texture is in gamma space.
  68770. */
  68771. gammaSpace: boolean;
  68772. }
  68773. /**
  68774. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68775. */
  68776. export class PanoramaToCubeMapTools {
  68777. private static FACE_FRONT;
  68778. private static FACE_BACK;
  68779. private static FACE_RIGHT;
  68780. private static FACE_LEFT;
  68781. private static FACE_DOWN;
  68782. private static FACE_UP;
  68783. /**
  68784. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68785. *
  68786. * @param float32Array The source data.
  68787. * @param inputWidth The width of the input panorama.
  68788. * @param inputHeight The height of the input panorama.
  68789. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68790. * @return The cubemap data
  68791. */
  68792. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68793. private static CreateCubemapTexture;
  68794. private static CalcProjectionSpherical;
  68795. }
  68796. }
  68797. declare module BABYLON {
  68798. /**
  68799. * Helper class dealing with the extraction of spherical polynomial dataArray
  68800. * from a cube map.
  68801. */
  68802. export class CubeMapToSphericalPolynomialTools {
  68803. private static FileFaces;
  68804. /**
  68805. * Converts a texture to the according Spherical Polynomial data.
  68806. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68807. *
  68808. * @param texture The texture to extract the information from.
  68809. * @return The Spherical Polynomial data.
  68810. */
  68811. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68812. /**
  68813. * Converts a cubemap to the according Spherical Polynomial data.
  68814. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68815. *
  68816. * @param cubeInfo The Cube map to extract the information from.
  68817. * @return The Spherical Polynomial data.
  68818. */
  68819. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68820. }
  68821. }
  68822. declare module BABYLON {
  68823. /**
  68824. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68825. * during the life time of the application.
  68826. */
  68827. export class EngineStore {
  68828. /** Gets the list of created engines */
  68829. static Instances: Engine[];
  68830. /** @hidden */
  68831. static _LastCreatedScene: Nullable<Scene>;
  68832. /**
  68833. * Gets the latest created engine
  68834. */
  68835. static readonly LastCreatedEngine: Nullable<Engine>;
  68836. /**
  68837. * Gets the latest created scene
  68838. */
  68839. static readonly LastCreatedScene: Nullable<Scene>;
  68840. }
  68841. }
  68842. declare module BABYLON {
  68843. /**
  68844. * Define options used to create a render target texture
  68845. */
  68846. export class RenderTargetCreationOptions {
  68847. /**
  68848. * Specifies is mipmaps must be generated
  68849. */
  68850. generateMipMaps?: boolean;
  68851. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68852. generateDepthBuffer?: boolean;
  68853. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68854. generateStencilBuffer?: boolean;
  68855. /** Defines texture type (int by default) */
  68856. type?: number;
  68857. /** Defines sampling mode (trilinear by default) */
  68858. samplingMode?: number;
  68859. /** Defines format (RGBA by default) */
  68860. format?: number;
  68861. }
  68862. }
  68863. declare module BABYLON {
  68864. /**
  68865. * @hidden
  68866. **/
  68867. export class _AlphaState {
  68868. private _isAlphaBlendDirty;
  68869. private _isBlendFunctionParametersDirty;
  68870. private _isBlendEquationParametersDirty;
  68871. private _isBlendConstantsDirty;
  68872. private _alphaBlend;
  68873. private _blendFunctionParameters;
  68874. private _blendEquationParameters;
  68875. private _blendConstants;
  68876. /**
  68877. * Initializes the state.
  68878. */
  68879. constructor();
  68880. readonly isDirty: boolean;
  68881. alphaBlend: boolean;
  68882. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68883. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68884. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68885. reset(): void;
  68886. apply(gl: WebGLRenderingContext): void;
  68887. }
  68888. }
  68889. declare module BABYLON {
  68890. /**
  68891. * @hidden
  68892. **/
  68893. export class _DepthCullingState {
  68894. private _isDepthTestDirty;
  68895. private _isDepthMaskDirty;
  68896. private _isDepthFuncDirty;
  68897. private _isCullFaceDirty;
  68898. private _isCullDirty;
  68899. private _isZOffsetDirty;
  68900. private _isFrontFaceDirty;
  68901. private _depthTest;
  68902. private _depthMask;
  68903. private _depthFunc;
  68904. private _cull;
  68905. private _cullFace;
  68906. private _zOffset;
  68907. private _frontFace;
  68908. /**
  68909. * Initializes the state.
  68910. */
  68911. constructor();
  68912. readonly isDirty: boolean;
  68913. zOffset: number;
  68914. cullFace: Nullable<number>;
  68915. cull: Nullable<boolean>;
  68916. depthFunc: Nullable<number>;
  68917. depthMask: boolean;
  68918. depthTest: boolean;
  68919. frontFace: Nullable<number>;
  68920. reset(): void;
  68921. apply(gl: WebGLRenderingContext): void;
  68922. }
  68923. }
  68924. declare module BABYLON {
  68925. /**
  68926. * @hidden
  68927. **/
  68928. export class _StencilState {
  68929. /** 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 */
  68930. static readonly ALWAYS: number;
  68931. /** Passed to stencilOperation to specify that stencil value must be kept */
  68932. static readonly KEEP: number;
  68933. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68934. static readonly REPLACE: number;
  68935. private _isStencilTestDirty;
  68936. private _isStencilMaskDirty;
  68937. private _isStencilFuncDirty;
  68938. private _isStencilOpDirty;
  68939. private _stencilTest;
  68940. private _stencilMask;
  68941. private _stencilFunc;
  68942. private _stencilFuncRef;
  68943. private _stencilFuncMask;
  68944. private _stencilOpStencilFail;
  68945. private _stencilOpDepthFail;
  68946. private _stencilOpStencilDepthPass;
  68947. readonly isDirty: boolean;
  68948. stencilFunc: number;
  68949. stencilFuncRef: number;
  68950. stencilFuncMask: number;
  68951. stencilOpStencilFail: number;
  68952. stencilOpDepthFail: number;
  68953. stencilOpStencilDepthPass: number;
  68954. stencilMask: number;
  68955. stencilTest: boolean;
  68956. constructor();
  68957. reset(): void;
  68958. apply(gl: WebGLRenderingContext): void;
  68959. }
  68960. }
  68961. declare module BABYLON {
  68962. /**
  68963. * @hidden
  68964. **/
  68965. export class _TimeToken {
  68966. _startTimeQuery: Nullable<WebGLQuery>;
  68967. _endTimeQuery: Nullable<WebGLQuery>;
  68968. _timeElapsedQuery: Nullable<WebGLQuery>;
  68969. _timeElapsedQueryEnded: boolean;
  68970. }
  68971. }
  68972. declare module BABYLON {
  68973. /**
  68974. * Class used to store data associated with WebGL texture data for the engine
  68975. * This class should not be used directly
  68976. */
  68977. export class InternalTexture {
  68978. /** @hidden */
  68979. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  68980. /**
  68981. * The source of the texture data is unknown
  68982. */
  68983. static DATASOURCE_UNKNOWN: number;
  68984. /**
  68985. * Texture data comes from an URL
  68986. */
  68987. static DATASOURCE_URL: number;
  68988. /**
  68989. * Texture data is only used for temporary storage
  68990. */
  68991. static DATASOURCE_TEMP: number;
  68992. /**
  68993. * Texture data comes from raw data (ArrayBuffer)
  68994. */
  68995. static DATASOURCE_RAW: number;
  68996. /**
  68997. * Texture content is dynamic (video or dynamic texture)
  68998. */
  68999. static DATASOURCE_DYNAMIC: number;
  69000. /**
  69001. * Texture content is generated by rendering to it
  69002. */
  69003. static DATASOURCE_RENDERTARGET: number;
  69004. /**
  69005. * Texture content is part of a multi render target process
  69006. */
  69007. static DATASOURCE_MULTIRENDERTARGET: number;
  69008. /**
  69009. * Texture data comes from a cube data file
  69010. */
  69011. static DATASOURCE_CUBE: number;
  69012. /**
  69013. * Texture data comes from a raw cube data
  69014. */
  69015. static DATASOURCE_CUBERAW: number;
  69016. /**
  69017. * Texture data come from a prefiltered cube data file
  69018. */
  69019. static DATASOURCE_CUBEPREFILTERED: number;
  69020. /**
  69021. * Texture content is raw 3D data
  69022. */
  69023. static DATASOURCE_RAW3D: number;
  69024. /**
  69025. * Texture content is a depth texture
  69026. */
  69027. static DATASOURCE_DEPTHTEXTURE: number;
  69028. /**
  69029. * Texture data comes from a raw cube data encoded with RGBD
  69030. */
  69031. static DATASOURCE_CUBERAW_RGBD: number;
  69032. /**
  69033. * Defines if the texture is ready
  69034. */
  69035. isReady: boolean;
  69036. /**
  69037. * Defines if the texture is a cube texture
  69038. */
  69039. isCube: boolean;
  69040. /**
  69041. * Defines if the texture contains 3D data
  69042. */
  69043. is3D: boolean;
  69044. /**
  69045. * Defines if the texture contains multiview data
  69046. */
  69047. isMultiview: boolean;
  69048. /**
  69049. * Gets the URL used to load this texture
  69050. */
  69051. url: string;
  69052. /**
  69053. * Gets the sampling mode of the texture
  69054. */
  69055. samplingMode: number;
  69056. /**
  69057. * Gets a boolean indicating if the texture needs mipmaps generation
  69058. */
  69059. generateMipMaps: boolean;
  69060. /**
  69061. * Gets the number of samples used by the texture (WebGL2+ only)
  69062. */
  69063. samples: number;
  69064. /**
  69065. * Gets the type of the texture (int, float...)
  69066. */
  69067. type: number;
  69068. /**
  69069. * Gets the format of the texture (RGB, RGBA...)
  69070. */
  69071. format: number;
  69072. /**
  69073. * Observable called when the texture is loaded
  69074. */
  69075. onLoadedObservable: Observable<InternalTexture>;
  69076. /**
  69077. * Gets the width of the texture
  69078. */
  69079. width: number;
  69080. /**
  69081. * Gets the height of the texture
  69082. */
  69083. height: number;
  69084. /**
  69085. * Gets the depth of the texture
  69086. */
  69087. depth: number;
  69088. /**
  69089. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69090. */
  69091. baseWidth: number;
  69092. /**
  69093. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69094. */
  69095. baseHeight: number;
  69096. /**
  69097. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69098. */
  69099. baseDepth: number;
  69100. /**
  69101. * Gets a boolean indicating if the texture is inverted on Y axis
  69102. */
  69103. invertY: boolean;
  69104. /** @hidden */
  69105. _invertVScale: boolean;
  69106. /** @hidden */
  69107. _associatedChannel: number;
  69108. /** @hidden */
  69109. _dataSource: number;
  69110. /** @hidden */
  69111. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69112. /** @hidden */
  69113. _bufferView: Nullable<ArrayBufferView>;
  69114. /** @hidden */
  69115. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69116. /** @hidden */
  69117. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69118. /** @hidden */
  69119. _size: number;
  69120. /** @hidden */
  69121. _extension: string;
  69122. /** @hidden */
  69123. _files: Nullable<string[]>;
  69124. /** @hidden */
  69125. _workingCanvas: Nullable<HTMLCanvasElement>;
  69126. /** @hidden */
  69127. _workingContext: Nullable<CanvasRenderingContext2D>;
  69128. /** @hidden */
  69129. _framebuffer: Nullable<WebGLFramebuffer>;
  69130. /** @hidden */
  69131. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69132. /** @hidden */
  69133. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69134. /** @hidden */
  69135. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69136. /** @hidden */
  69137. _attachments: Nullable<number[]>;
  69138. /** @hidden */
  69139. _cachedCoordinatesMode: Nullable<number>;
  69140. /** @hidden */
  69141. _cachedWrapU: Nullable<number>;
  69142. /** @hidden */
  69143. _cachedWrapV: Nullable<number>;
  69144. /** @hidden */
  69145. _cachedWrapR: Nullable<number>;
  69146. /** @hidden */
  69147. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69148. /** @hidden */
  69149. _isDisabled: boolean;
  69150. /** @hidden */
  69151. _compression: Nullable<string>;
  69152. /** @hidden */
  69153. _generateStencilBuffer: boolean;
  69154. /** @hidden */
  69155. _generateDepthBuffer: boolean;
  69156. /** @hidden */
  69157. _comparisonFunction: number;
  69158. /** @hidden */
  69159. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69160. /** @hidden */
  69161. _lodGenerationScale: number;
  69162. /** @hidden */
  69163. _lodGenerationOffset: number;
  69164. /** @hidden */
  69165. _colorTextureArray: Nullable<WebGLTexture>;
  69166. /** @hidden */
  69167. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69168. /** @hidden */
  69169. _lodTextureHigh: Nullable<BaseTexture>;
  69170. /** @hidden */
  69171. _lodTextureMid: Nullable<BaseTexture>;
  69172. /** @hidden */
  69173. _lodTextureLow: Nullable<BaseTexture>;
  69174. /** @hidden */
  69175. _isRGBD: boolean;
  69176. /** @hidden */
  69177. _linearSpecularLOD: boolean;
  69178. /** @hidden */
  69179. _irradianceTexture: Nullable<BaseTexture>;
  69180. /** @hidden */
  69181. _webGLTexture: Nullable<WebGLTexture>;
  69182. /** @hidden */
  69183. _references: number;
  69184. private _engine;
  69185. /**
  69186. * Gets the Engine the texture belongs to.
  69187. * @returns The babylon engine
  69188. */
  69189. getEngine(): Engine;
  69190. /**
  69191. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69192. */
  69193. readonly dataSource: number;
  69194. /**
  69195. * Creates a new InternalTexture
  69196. * @param engine defines the engine to use
  69197. * @param dataSource defines the type of data that will be used
  69198. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69199. */
  69200. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69201. /**
  69202. * Increments the number of references (ie. the number of Texture that point to it)
  69203. */
  69204. incrementReferences(): void;
  69205. /**
  69206. * Change the size of the texture (not the size of the content)
  69207. * @param width defines the new width
  69208. * @param height defines the new height
  69209. * @param depth defines the new depth (1 by default)
  69210. */
  69211. updateSize(width: int, height: int, depth?: int): void;
  69212. /** @hidden */
  69213. _rebuild(): void;
  69214. /** @hidden */
  69215. _swapAndDie(target: InternalTexture): void;
  69216. /**
  69217. * Dispose the current allocated resources
  69218. */
  69219. dispose(): void;
  69220. }
  69221. }
  69222. declare module BABYLON {
  69223. /**
  69224. * This represents the main contract an easing function should follow.
  69225. * Easing functions are used throughout the animation system.
  69226. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69227. */
  69228. export interface IEasingFunction {
  69229. /**
  69230. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69231. * of the easing function.
  69232. * The link below provides some of the most common examples of easing functions.
  69233. * @see https://easings.net/
  69234. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69235. * @returns the corresponding value on the curve defined by the easing function
  69236. */
  69237. ease(gradient: number): number;
  69238. }
  69239. /**
  69240. * Base class used for every default easing function.
  69241. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69242. */
  69243. export class EasingFunction implements IEasingFunction {
  69244. /**
  69245. * Interpolation follows the mathematical formula associated with the easing function.
  69246. */
  69247. static readonly EASINGMODE_EASEIN: number;
  69248. /**
  69249. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69250. */
  69251. static readonly EASINGMODE_EASEOUT: number;
  69252. /**
  69253. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69254. */
  69255. static readonly EASINGMODE_EASEINOUT: number;
  69256. private _easingMode;
  69257. /**
  69258. * Sets the easing mode of the current function.
  69259. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69260. */
  69261. setEasingMode(easingMode: number): void;
  69262. /**
  69263. * Gets the current easing mode.
  69264. * @returns the easing mode
  69265. */
  69266. getEasingMode(): number;
  69267. /**
  69268. * @hidden
  69269. */
  69270. easeInCore(gradient: number): number;
  69271. /**
  69272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69273. * of the easing function.
  69274. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69275. * @returns the corresponding value on the curve defined by the easing function
  69276. */
  69277. ease(gradient: number): number;
  69278. }
  69279. /**
  69280. * Easing function with a circle shape (see link below).
  69281. * @see https://easings.net/#easeInCirc
  69282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69283. */
  69284. export class CircleEase extends EasingFunction implements IEasingFunction {
  69285. /** @hidden */
  69286. easeInCore(gradient: number): number;
  69287. }
  69288. /**
  69289. * Easing function with a ease back shape (see link below).
  69290. * @see https://easings.net/#easeInBack
  69291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69292. */
  69293. export class BackEase extends EasingFunction implements IEasingFunction {
  69294. /** Defines the amplitude of the function */
  69295. amplitude: number;
  69296. /**
  69297. * Instantiates a back ease easing
  69298. * @see https://easings.net/#easeInBack
  69299. * @param amplitude Defines the amplitude of the function
  69300. */
  69301. constructor(
  69302. /** Defines the amplitude of the function */
  69303. amplitude?: number);
  69304. /** @hidden */
  69305. easeInCore(gradient: number): number;
  69306. }
  69307. /**
  69308. * Easing function with a bouncing shape (see link below).
  69309. * @see https://easings.net/#easeInBounce
  69310. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69311. */
  69312. export class BounceEase extends EasingFunction implements IEasingFunction {
  69313. /** Defines the number of bounces */
  69314. bounces: number;
  69315. /** Defines the amplitude of the bounce */
  69316. bounciness: number;
  69317. /**
  69318. * Instantiates a bounce easing
  69319. * @see https://easings.net/#easeInBounce
  69320. * @param bounces Defines the number of bounces
  69321. * @param bounciness Defines the amplitude of the bounce
  69322. */
  69323. constructor(
  69324. /** Defines the number of bounces */
  69325. bounces?: number,
  69326. /** Defines the amplitude of the bounce */
  69327. bounciness?: number);
  69328. /** @hidden */
  69329. easeInCore(gradient: number): number;
  69330. }
  69331. /**
  69332. * Easing function with a power of 3 shape (see link below).
  69333. * @see https://easings.net/#easeInCubic
  69334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69335. */
  69336. export class CubicEase extends EasingFunction implements IEasingFunction {
  69337. /** @hidden */
  69338. easeInCore(gradient: number): number;
  69339. }
  69340. /**
  69341. * Easing function with an elastic shape (see link below).
  69342. * @see https://easings.net/#easeInElastic
  69343. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69344. */
  69345. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69346. /** Defines the number of oscillations*/
  69347. oscillations: number;
  69348. /** Defines the amplitude of the oscillations*/
  69349. springiness: number;
  69350. /**
  69351. * Instantiates an elastic easing function
  69352. * @see https://easings.net/#easeInElastic
  69353. * @param oscillations Defines the number of oscillations
  69354. * @param springiness Defines the amplitude of the oscillations
  69355. */
  69356. constructor(
  69357. /** Defines the number of oscillations*/
  69358. oscillations?: number,
  69359. /** Defines the amplitude of the oscillations*/
  69360. springiness?: number);
  69361. /** @hidden */
  69362. easeInCore(gradient: number): number;
  69363. }
  69364. /**
  69365. * Easing function with an exponential shape (see link below).
  69366. * @see https://easings.net/#easeInExpo
  69367. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69368. */
  69369. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69370. /** Defines the exponent of the function */
  69371. exponent: number;
  69372. /**
  69373. * Instantiates an exponential easing function
  69374. * @see https://easings.net/#easeInExpo
  69375. * @param exponent Defines the exponent of the function
  69376. */
  69377. constructor(
  69378. /** Defines the exponent of the function */
  69379. exponent?: number);
  69380. /** @hidden */
  69381. easeInCore(gradient: number): number;
  69382. }
  69383. /**
  69384. * Easing function with a power shape (see link below).
  69385. * @see https://easings.net/#easeInQuad
  69386. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69387. */
  69388. export class PowerEase extends EasingFunction implements IEasingFunction {
  69389. /** Defines the power of the function */
  69390. power: number;
  69391. /**
  69392. * Instantiates an power base easing function
  69393. * @see https://easings.net/#easeInQuad
  69394. * @param power Defines the power of the function
  69395. */
  69396. constructor(
  69397. /** Defines the power of the function */
  69398. power?: number);
  69399. /** @hidden */
  69400. easeInCore(gradient: number): number;
  69401. }
  69402. /**
  69403. * Easing function with a power of 2 shape (see link below).
  69404. * @see https://easings.net/#easeInQuad
  69405. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69406. */
  69407. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69408. /** @hidden */
  69409. easeInCore(gradient: number): number;
  69410. }
  69411. /**
  69412. * Easing function with a power of 4 shape (see link below).
  69413. * @see https://easings.net/#easeInQuart
  69414. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69415. */
  69416. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69417. /** @hidden */
  69418. easeInCore(gradient: number): number;
  69419. }
  69420. /**
  69421. * Easing function with a power of 5 shape (see link below).
  69422. * @see https://easings.net/#easeInQuint
  69423. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69424. */
  69425. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69426. /** @hidden */
  69427. easeInCore(gradient: number): number;
  69428. }
  69429. /**
  69430. * Easing function with a sin shape (see link below).
  69431. * @see https://easings.net/#easeInSine
  69432. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69433. */
  69434. export class SineEase extends EasingFunction implements IEasingFunction {
  69435. /** @hidden */
  69436. easeInCore(gradient: number): number;
  69437. }
  69438. /**
  69439. * Easing function with a bezier shape (see link below).
  69440. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69441. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69442. */
  69443. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69444. /** Defines the x component of the start tangent in the bezier curve */
  69445. x1: number;
  69446. /** Defines the y component of the start tangent in the bezier curve */
  69447. y1: number;
  69448. /** Defines the x component of the end tangent in the bezier curve */
  69449. x2: number;
  69450. /** Defines the y component of the end tangent in the bezier curve */
  69451. y2: number;
  69452. /**
  69453. * Instantiates a bezier function
  69454. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69455. * @param x1 Defines the x component of the start tangent in the bezier curve
  69456. * @param y1 Defines the y component of the start tangent in the bezier curve
  69457. * @param x2 Defines the x component of the end tangent in the bezier curve
  69458. * @param y2 Defines the y component of the end tangent in the bezier curve
  69459. */
  69460. constructor(
  69461. /** Defines the x component of the start tangent in the bezier curve */
  69462. x1?: number,
  69463. /** Defines the y component of the start tangent in the bezier curve */
  69464. y1?: number,
  69465. /** Defines the x component of the end tangent in the bezier curve */
  69466. x2?: number,
  69467. /** Defines the y component of the end tangent in the bezier curve */
  69468. y2?: number);
  69469. /** @hidden */
  69470. easeInCore(gradient: number): number;
  69471. }
  69472. }
  69473. declare module BABYLON {
  69474. /**
  69475. * Defines an interface which represents an animation key frame
  69476. */
  69477. export interface IAnimationKey {
  69478. /**
  69479. * Frame of the key frame
  69480. */
  69481. frame: number;
  69482. /**
  69483. * Value at the specifies key frame
  69484. */
  69485. value: any;
  69486. /**
  69487. * The input tangent for the cubic hermite spline
  69488. */
  69489. inTangent?: any;
  69490. /**
  69491. * The output tangent for the cubic hermite spline
  69492. */
  69493. outTangent?: any;
  69494. /**
  69495. * The animation interpolation type
  69496. */
  69497. interpolation?: AnimationKeyInterpolation;
  69498. }
  69499. /**
  69500. * Enum for the animation key frame interpolation type
  69501. */
  69502. export enum AnimationKeyInterpolation {
  69503. /**
  69504. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69505. */
  69506. STEP = 1
  69507. }
  69508. }
  69509. declare module BABYLON {
  69510. /**
  69511. * Represents the range of an animation
  69512. */
  69513. export class AnimationRange {
  69514. /**The name of the animation range**/
  69515. name: string;
  69516. /**The starting frame of the animation */
  69517. from: number;
  69518. /**The ending frame of the animation*/
  69519. to: number;
  69520. /**
  69521. * Initializes the range of an animation
  69522. * @param name The name of the animation range
  69523. * @param from The starting frame of the animation
  69524. * @param to The ending frame of the animation
  69525. */
  69526. constructor(
  69527. /**The name of the animation range**/
  69528. name: string,
  69529. /**The starting frame of the animation */
  69530. from: number,
  69531. /**The ending frame of the animation*/
  69532. to: number);
  69533. /**
  69534. * Makes a copy of the animation range
  69535. * @returns A copy of the animation range
  69536. */
  69537. clone(): AnimationRange;
  69538. }
  69539. }
  69540. declare module BABYLON {
  69541. /**
  69542. * Composed of a frame, and an action function
  69543. */
  69544. export class AnimationEvent {
  69545. /** The frame for which the event is triggered **/
  69546. frame: number;
  69547. /** The event to perform when triggered **/
  69548. action: (currentFrame: number) => void;
  69549. /** Specifies if the event should be triggered only once**/
  69550. onlyOnce?: boolean | undefined;
  69551. /**
  69552. * Specifies if the animation event is done
  69553. */
  69554. isDone: boolean;
  69555. /**
  69556. * Initializes the animation event
  69557. * @param frame The frame for which the event is triggered
  69558. * @param action The event to perform when triggered
  69559. * @param onlyOnce Specifies if the event should be triggered only once
  69560. */
  69561. constructor(
  69562. /** The frame for which the event is triggered **/
  69563. frame: number,
  69564. /** The event to perform when triggered **/
  69565. action: (currentFrame: number) => void,
  69566. /** Specifies if the event should be triggered only once**/
  69567. onlyOnce?: boolean | undefined);
  69568. /** @hidden */
  69569. _clone(): AnimationEvent;
  69570. }
  69571. }
  69572. declare module BABYLON {
  69573. /**
  69574. * Interface used to define a behavior
  69575. */
  69576. export interface Behavior<T> {
  69577. /** gets or sets behavior's name */
  69578. name: string;
  69579. /**
  69580. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69581. */
  69582. init(): void;
  69583. /**
  69584. * Called when the behavior is attached to a target
  69585. * @param target defines the target where the behavior is attached to
  69586. */
  69587. attach(target: T): void;
  69588. /**
  69589. * Called when the behavior is detached from its target
  69590. */
  69591. detach(): void;
  69592. }
  69593. /**
  69594. * Interface implemented by classes supporting behaviors
  69595. */
  69596. export interface IBehaviorAware<T> {
  69597. /**
  69598. * Attach a behavior
  69599. * @param behavior defines the behavior to attach
  69600. * @returns the current host
  69601. */
  69602. addBehavior(behavior: Behavior<T>): T;
  69603. /**
  69604. * Remove a behavior from the current object
  69605. * @param behavior defines the behavior to detach
  69606. * @returns the current host
  69607. */
  69608. removeBehavior(behavior: Behavior<T>): T;
  69609. /**
  69610. * Gets a behavior using its name to search
  69611. * @param name defines the name to search
  69612. * @returns the behavior or null if not found
  69613. */
  69614. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69615. }
  69616. }
  69617. declare module BABYLON {
  69618. /**
  69619. * @hidden
  69620. */
  69621. export class IntersectionInfo {
  69622. bu: Nullable<number>;
  69623. bv: Nullable<number>;
  69624. distance: number;
  69625. faceId: number;
  69626. subMeshId: number;
  69627. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69628. }
  69629. }
  69630. declare module BABYLON {
  69631. /**
  69632. * Class used to store bounding sphere information
  69633. */
  69634. export class BoundingSphere {
  69635. /**
  69636. * Gets the center of the bounding sphere in local space
  69637. */
  69638. readonly center: Vector3;
  69639. /**
  69640. * Radius of the bounding sphere in local space
  69641. */
  69642. radius: number;
  69643. /**
  69644. * Gets the center of the bounding sphere in world space
  69645. */
  69646. readonly centerWorld: Vector3;
  69647. /**
  69648. * Radius of the bounding sphere in world space
  69649. */
  69650. radiusWorld: number;
  69651. /**
  69652. * Gets the minimum vector in local space
  69653. */
  69654. readonly minimum: Vector3;
  69655. /**
  69656. * Gets the maximum vector in local space
  69657. */
  69658. readonly maximum: Vector3;
  69659. private _worldMatrix;
  69660. private static readonly TmpVector3;
  69661. /**
  69662. * Creates a new bounding sphere
  69663. * @param min defines the minimum vector (in local space)
  69664. * @param max defines the maximum vector (in local space)
  69665. * @param worldMatrix defines the new world matrix
  69666. */
  69667. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69668. /**
  69669. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69670. * @param min defines the new minimum vector (in local space)
  69671. * @param max defines the new maximum vector (in local space)
  69672. * @param worldMatrix defines the new world matrix
  69673. */
  69674. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69675. /**
  69676. * Scale the current bounding sphere by applying a scale factor
  69677. * @param factor defines the scale factor to apply
  69678. * @returns the current bounding box
  69679. */
  69680. scale(factor: number): BoundingSphere;
  69681. /**
  69682. * Gets the world matrix of the bounding box
  69683. * @returns a matrix
  69684. */
  69685. getWorldMatrix(): DeepImmutable<Matrix>;
  69686. /** @hidden */
  69687. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69688. /**
  69689. * Tests if the bounding sphere is intersecting the frustum planes
  69690. * @param frustumPlanes defines the frustum planes to test
  69691. * @returns true if there is an intersection
  69692. */
  69693. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69694. /**
  69695. * Tests if the bounding sphere center is in between the frustum planes.
  69696. * Used for optimistic fast inclusion.
  69697. * @param frustumPlanes defines the frustum planes to test
  69698. * @returns true if the sphere center is in between the frustum planes
  69699. */
  69700. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69701. /**
  69702. * Tests if a point is inside the bounding sphere
  69703. * @param point defines the point to test
  69704. * @returns true if the point is inside the bounding sphere
  69705. */
  69706. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69707. /**
  69708. * Checks if two sphere intersct
  69709. * @param sphere0 sphere 0
  69710. * @param sphere1 sphere 1
  69711. * @returns true if the speres intersect
  69712. */
  69713. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69714. }
  69715. }
  69716. declare module BABYLON {
  69717. /**
  69718. * Class used to store bounding box information
  69719. */
  69720. export class BoundingBox implements ICullable {
  69721. /**
  69722. * Gets the 8 vectors representing the bounding box in local space
  69723. */
  69724. readonly vectors: Vector3[];
  69725. /**
  69726. * Gets the center of the bounding box in local space
  69727. */
  69728. readonly center: Vector3;
  69729. /**
  69730. * Gets the center of the bounding box in world space
  69731. */
  69732. readonly centerWorld: Vector3;
  69733. /**
  69734. * Gets the extend size in local space
  69735. */
  69736. readonly extendSize: Vector3;
  69737. /**
  69738. * Gets the extend size in world space
  69739. */
  69740. readonly extendSizeWorld: Vector3;
  69741. /**
  69742. * Gets the OBB (object bounding box) directions
  69743. */
  69744. readonly directions: Vector3[];
  69745. /**
  69746. * Gets the 8 vectors representing the bounding box in world space
  69747. */
  69748. readonly vectorsWorld: Vector3[];
  69749. /**
  69750. * Gets the minimum vector in world space
  69751. */
  69752. readonly minimumWorld: Vector3;
  69753. /**
  69754. * Gets the maximum vector in world space
  69755. */
  69756. readonly maximumWorld: Vector3;
  69757. /**
  69758. * Gets the minimum vector in local space
  69759. */
  69760. readonly minimum: Vector3;
  69761. /**
  69762. * Gets the maximum vector in local space
  69763. */
  69764. readonly maximum: Vector3;
  69765. private _worldMatrix;
  69766. private static readonly TmpVector3;
  69767. /**
  69768. * @hidden
  69769. */
  69770. _tag: number;
  69771. /**
  69772. * Creates a new bounding box
  69773. * @param min defines the minimum vector (in local space)
  69774. * @param max defines the maximum vector (in local space)
  69775. * @param worldMatrix defines the new world matrix
  69776. */
  69777. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69778. /**
  69779. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69780. * @param min defines the new minimum vector (in local space)
  69781. * @param max defines the new maximum vector (in local space)
  69782. * @param worldMatrix defines the new world matrix
  69783. */
  69784. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69785. /**
  69786. * Scale the current bounding box by applying a scale factor
  69787. * @param factor defines the scale factor to apply
  69788. * @returns the current bounding box
  69789. */
  69790. scale(factor: number): BoundingBox;
  69791. /**
  69792. * Gets the world matrix of the bounding box
  69793. * @returns a matrix
  69794. */
  69795. getWorldMatrix(): DeepImmutable<Matrix>;
  69796. /** @hidden */
  69797. _update(world: DeepImmutable<Matrix>): void;
  69798. /**
  69799. * Tests if the bounding box is intersecting the frustum planes
  69800. * @param frustumPlanes defines the frustum planes to test
  69801. * @returns true if there is an intersection
  69802. */
  69803. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69804. /**
  69805. * Tests if the bounding box is entirely inside the frustum planes
  69806. * @param frustumPlanes defines the frustum planes to test
  69807. * @returns true if there is an inclusion
  69808. */
  69809. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69810. /**
  69811. * Tests if a point is inside the bounding box
  69812. * @param point defines the point to test
  69813. * @returns true if the point is inside the bounding box
  69814. */
  69815. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69816. /**
  69817. * Tests if the bounding box intersects with a bounding sphere
  69818. * @param sphere defines the sphere to test
  69819. * @returns true if there is an intersection
  69820. */
  69821. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69822. /**
  69823. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69824. * @param min defines the min vector to use
  69825. * @param max defines the max vector to use
  69826. * @returns true if there is an intersection
  69827. */
  69828. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69829. /**
  69830. * Tests if two bounding boxes are intersections
  69831. * @param box0 defines the first box to test
  69832. * @param box1 defines the second box to test
  69833. * @returns true if there is an intersection
  69834. */
  69835. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69836. /**
  69837. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69838. * @param minPoint defines the minimum vector of the bounding box
  69839. * @param maxPoint defines the maximum vector of the bounding box
  69840. * @param sphereCenter defines the sphere center
  69841. * @param sphereRadius defines the sphere radius
  69842. * @returns true if there is an intersection
  69843. */
  69844. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69845. /**
  69846. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69847. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69848. * @param frustumPlanes defines the frustum planes to test
  69849. * @return true if there is an inclusion
  69850. */
  69851. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69852. /**
  69853. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69854. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69855. * @param frustumPlanes defines the frustum planes to test
  69856. * @return true if there is an intersection
  69857. */
  69858. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69859. }
  69860. }
  69861. declare module BABYLON {
  69862. /** @hidden */
  69863. export class Collider {
  69864. /** Define if a collision was found */
  69865. collisionFound: boolean;
  69866. /**
  69867. * Define last intersection point in local space
  69868. */
  69869. intersectionPoint: Vector3;
  69870. /**
  69871. * Define last collided mesh
  69872. */
  69873. collidedMesh: Nullable<AbstractMesh>;
  69874. private _collisionPoint;
  69875. private _planeIntersectionPoint;
  69876. private _tempVector;
  69877. private _tempVector2;
  69878. private _tempVector3;
  69879. private _tempVector4;
  69880. private _edge;
  69881. private _baseToVertex;
  69882. private _destinationPoint;
  69883. private _slidePlaneNormal;
  69884. private _displacementVector;
  69885. /** @hidden */
  69886. _radius: Vector3;
  69887. /** @hidden */
  69888. _retry: number;
  69889. private _velocity;
  69890. private _basePoint;
  69891. private _epsilon;
  69892. /** @hidden */
  69893. _velocityWorldLength: number;
  69894. /** @hidden */
  69895. _basePointWorld: Vector3;
  69896. private _velocityWorld;
  69897. private _normalizedVelocity;
  69898. /** @hidden */
  69899. _initialVelocity: Vector3;
  69900. /** @hidden */
  69901. _initialPosition: Vector3;
  69902. private _nearestDistance;
  69903. private _collisionMask;
  69904. collisionMask: number;
  69905. /**
  69906. * Gets the plane normal used to compute the sliding response (in local space)
  69907. */
  69908. readonly slidePlaneNormal: Vector3;
  69909. /** @hidden */
  69910. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69911. /** @hidden */
  69912. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69913. /** @hidden */
  69914. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69915. /** @hidden */
  69916. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69917. /** @hidden */
  69918. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69919. /** @hidden */
  69920. _getResponse(pos: Vector3, vel: Vector3): void;
  69921. }
  69922. }
  69923. declare module BABYLON {
  69924. /**
  69925. * Interface for cullable objects
  69926. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69927. */
  69928. export interface ICullable {
  69929. /**
  69930. * Checks if the object or part of the object is in the frustum
  69931. * @param frustumPlanes Camera near/planes
  69932. * @returns true if the object is in frustum otherwise false
  69933. */
  69934. isInFrustum(frustumPlanes: Plane[]): boolean;
  69935. /**
  69936. * Checks if a cullable object (mesh...) is in the camera frustum
  69937. * Unlike isInFrustum this cheks the full bounding box
  69938. * @param frustumPlanes Camera near/planes
  69939. * @returns true if the object is in frustum otherwise false
  69940. */
  69941. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69942. }
  69943. /**
  69944. * Info for a bounding data of a mesh
  69945. */
  69946. export class BoundingInfo implements ICullable {
  69947. /**
  69948. * Bounding box for the mesh
  69949. */
  69950. readonly boundingBox: BoundingBox;
  69951. /**
  69952. * Bounding sphere for the mesh
  69953. */
  69954. readonly boundingSphere: BoundingSphere;
  69955. private _isLocked;
  69956. private static readonly TmpVector3;
  69957. /**
  69958. * Constructs bounding info
  69959. * @param minimum min vector of the bounding box/sphere
  69960. * @param maximum max vector of the bounding box/sphere
  69961. * @param worldMatrix defines the new world matrix
  69962. */
  69963. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69964. /**
  69965. * Recreates the entire bounding info from scratch as if we call the constructor in place
  69966. * @param min defines the new minimum vector (in local space)
  69967. * @param max defines the new maximum vector (in local space)
  69968. * @param worldMatrix defines the new world matrix
  69969. */
  69970. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69971. /**
  69972. * min vector of the bounding box/sphere
  69973. */
  69974. readonly minimum: Vector3;
  69975. /**
  69976. * max vector of the bounding box/sphere
  69977. */
  69978. readonly maximum: Vector3;
  69979. /**
  69980. * If the info is locked and won't be updated to avoid perf overhead
  69981. */
  69982. isLocked: boolean;
  69983. /**
  69984. * Updates the bounding sphere and box
  69985. * @param world world matrix to be used to update
  69986. */
  69987. update(world: DeepImmutable<Matrix>): void;
  69988. /**
  69989. * Recreate the bounding info to be centered around a specific point given a specific extend.
  69990. * @param center New center of the bounding info
  69991. * @param extend New extend of the bounding info
  69992. * @returns the current bounding info
  69993. */
  69994. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  69995. /**
  69996. * Scale the current bounding info by applying a scale factor
  69997. * @param factor defines the scale factor to apply
  69998. * @returns the current bounding info
  69999. */
  70000. scale(factor: number): BoundingInfo;
  70001. /**
  70002. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70003. * @param frustumPlanes defines the frustum to test
  70004. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70005. * @returns true if the bounding info is in the frustum planes
  70006. */
  70007. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70008. /**
  70009. * Gets the world distance between the min and max points of the bounding box
  70010. */
  70011. readonly diagonalLength: number;
  70012. /**
  70013. * Checks if a cullable object (mesh...) is in the camera frustum
  70014. * Unlike isInFrustum this cheks the full bounding box
  70015. * @param frustumPlanes Camera near/planes
  70016. * @returns true if the object is in frustum otherwise false
  70017. */
  70018. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70019. /** @hidden */
  70020. _checkCollision(collider: Collider): boolean;
  70021. /**
  70022. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70023. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70024. * @param point the point to check intersection with
  70025. * @returns if the point intersects
  70026. */
  70027. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70028. /**
  70029. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70030. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70031. * @param boundingInfo the bounding info to check intersection with
  70032. * @param precise if the intersection should be done using OBB
  70033. * @returns if the bounding info intersects
  70034. */
  70035. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70036. }
  70037. }
  70038. declare module BABYLON {
  70039. /**
  70040. * Defines an array and its length.
  70041. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70042. */
  70043. export interface ISmartArrayLike<T> {
  70044. /**
  70045. * The data of the array.
  70046. */
  70047. data: Array<T>;
  70048. /**
  70049. * The active length of the array.
  70050. */
  70051. length: number;
  70052. }
  70053. /**
  70054. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70055. */
  70056. export class SmartArray<T> implements ISmartArrayLike<T> {
  70057. /**
  70058. * The full set of data from the array.
  70059. */
  70060. data: Array<T>;
  70061. /**
  70062. * The active length of the array.
  70063. */
  70064. length: number;
  70065. protected _id: number;
  70066. /**
  70067. * Instantiates a Smart Array.
  70068. * @param capacity defines the default capacity of the array.
  70069. */
  70070. constructor(capacity: number);
  70071. /**
  70072. * Pushes a value at the end of the active data.
  70073. * @param value defines the object to push in the array.
  70074. */
  70075. push(value: T): void;
  70076. /**
  70077. * Iterates over the active data and apply the lambda to them.
  70078. * @param func defines the action to apply on each value.
  70079. */
  70080. forEach(func: (content: T) => void): void;
  70081. /**
  70082. * Sorts the full sets of data.
  70083. * @param compareFn defines the comparison function to apply.
  70084. */
  70085. sort(compareFn: (a: T, b: T) => number): void;
  70086. /**
  70087. * Resets the active data to an empty array.
  70088. */
  70089. reset(): void;
  70090. /**
  70091. * Releases all the data from the array as well as the array.
  70092. */
  70093. dispose(): void;
  70094. /**
  70095. * Concats the active data with a given array.
  70096. * @param array defines the data to concatenate with.
  70097. */
  70098. concat(array: any): void;
  70099. /**
  70100. * Returns the position of a value in the active data.
  70101. * @param value defines the value to find the index for
  70102. * @returns the index if found in the active data otherwise -1
  70103. */
  70104. indexOf(value: T): number;
  70105. /**
  70106. * Returns whether an element is part of the active data.
  70107. * @param value defines the value to look for
  70108. * @returns true if found in the active data otherwise false
  70109. */
  70110. contains(value: T): boolean;
  70111. private static _GlobalId;
  70112. }
  70113. /**
  70114. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70115. * The data in this array can only be present once
  70116. */
  70117. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70118. private _duplicateId;
  70119. /**
  70120. * Pushes a value at the end of the active data.
  70121. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70122. * @param value defines the object to push in the array.
  70123. */
  70124. push(value: T): void;
  70125. /**
  70126. * Pushes a value at the end of the active data.
  70127. * If the data is already present, it won t be added again
  70128. * @param value defines the object to push in the array.
  70129. * @returns true if added false if it was already present
  70130. */
  70131. pushNoDuplicate(value: T): boolean;
  70132. /**
  70133. * Resets the active data to an empty array.
  70134. */
  70135. reset(): void;
  70136. /**
  70137. * Concats the active data with a given array.
  70138. * This ensures no dupplicate will be present in the result.
  70139. * @param array defines the data to concatenate with.
  70140. */
  70141. concatWithNoDuplicate(array: any): void;
  70142. }
  70143. }
  70144. declare module BABYLON {
  70145. /**
  70146. * Enum that determines the text-wrapping mode to use.
  70147. */
  70148. export enum InspectableType {
  70149. /**
  70150. * Checkbox for booleans
  70151. */
  70152. Checkbox = 0,
  70153. /**
  70154. * Sliders for numbers
  70155. */
  70156. Slider = 1,
  70157. /**
  70158. * Vector3
  70159. */
  70160. Vector3 = 2,
  70161. /**
  70162. * Quaternions
  70163. */
  70164. Quaternion = 3,
  70165. /**
  70166. * Color3
  70167. */
  70168. Color3 = 4
  70169. }
  70170. /**
  70171. * Interface used to define custom inspectable properties.
  70172. * This interface is used by the inspector to display custom property grids
  70173. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70174. */
  70175. export interface IInspectable {
  70176. /**
  70177. * Gets the label to display
  70178. */
  70179. label: string;
  70180. /**
  70181. * Gets the name of the property to edit
  70182. */
  70183. propertyName: string;
  70184. /**
  70185. * Gets the type of the editor to use
  70186. */
  70187. type: InspectableType;
  70188. /**
  70189. * Gets the minimum value of the property when using in "slider" mode
  70190. */
  70191. min?: number;
  70192. /**
  70193. * Gets the maximum value of the property when using in "slider" mode
  70194. */
  70195. max?: number;
  70196. /**
  70197. * Gets the setp to use when using in "slider" mode
  70198. */
  70199. step?: number;
  70200. }
  70201. }
  70202. declare module BABYLON {
  70203. /**
  70204. * This represents the required contract to create a new type of texture loader.
  70205. */
  70206. export interface IInternalTextureLoader {
  70207. /**
  70208. * Defines wether the loader supports cascade loading the different faces.
  70209. */
  70210. supportCascades: boolean;
  70211. /**
  70212. * This returns if the loader support the current file information.
  70213. * @param extension defines the file extension of the file being loaded
  70214. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70215. * @param fallback defines the fallback internal texture if any
  70216. * @param isBase64 defines whether the texture is encoded as a base64
  70217. * @param isBuffer defines whether the texture data are stored as a buffer
  70218. * @returns true if the loader can load the specified file
  70219. */
  70220. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70221. /**
  70222. * Transform the url before loading if required.
  70223. * @param rootUrl the url of the texture
  70224. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70225. * @returns the transformed texture
  70226. */
  70227. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70228. /**
  70229. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70230. * @param rootUrl the url of the texture
  70231. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70232. * @returns the fallback texture
  70233. */
  70234. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70235. /**
  70236. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70237. * @param data contains the texture data
  70238. * @param texture defines the BabylonJS internal texture
  70239. * @param createPolynomials will be true if polynomials have been requested
  70240. * @param onLoad defines the callback to trigger once the texture is ready
  70241. * @param onError defines the callback to trigger in case of error
  70242. */
  70243. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70244. /**
  70245. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70246. * @param data contains the texture data
  70247. * @param texture defines the BabylonJS internal texture
  70248. * @param callback defines the method to call once ready to upload
  70249. */
  70250. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70251. }
  70252. }
  70253. declare module BABYLON {
  70254. interface Engine {
  70255. /**
  70256. * Creates a depth stencil cube texture.
  70257. * This is only available in WebGL 2.
  70258. * @param size The size of face edge in the cube texture.
  70259. * @param options The options defining the cube texture.
  70260. * @returns The cube texture
  70261. */
  70262. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70263. /**
  70264. * Creates a cube texture
  70265. * @param rootUrl defines the url where the files to load is located
  70266. * @param scene defines the current scene
  70267. * @param files defines the list of files to load (1 per face)
  70268. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70269. * @param onLoad defines an optional callback raised when the texture is loaded
  70270. * @param onError defines an optional callback raised if there is an issue to load the texture
  70271. * @param format defines the format of the data
  70272. * @param forcedExtension defines the extension to use to pick the right loader
  70273. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70274. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70275. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70276. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70277. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70278. * @returns the cube texture as an InternalTexture
  70279. */
  70280. 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;
  70281. /**
  70282. * Creates a cube texture
  70283. * @param rootUrl defines the url where the files to load is located
  70284. * @param scene defines the current scene
  70285. * @param files defines the list of files to load (1 per face)
  70286. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70287. * @param onLoad defines an optional callback raised when the texture is loaded
  70288. * @param onError defines an optional callback raised if there is an issue to load the texture
  70289. * @param format defines the format of the data
  70290. * @param forcedExtension defines the extension to use to pick the right loader
  70291. * @returns the cube texture as an InternalTexture
  70292. */
  70293. 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;
  70294. /**
  70295. * Creates a cube texture
  70296. * @param rootUrl defines the url where the files to load is located
  70297. * @param scene defines the current scene
  70298. * @param files defines the list of files to load (1 per face)
  70299. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70300. * @param onLoad defines an optional callback raised when the texture is loaded
  70301. * @param onError defines an optional callback raised if there is an issue to load the texture
  70302. * @param format defines the format of the data
  70303. * @param forcedExtension defines the extension to use to pick the right loader
  70304. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70305. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70306. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70307. * @returns the cube texture as an InternalTexture
  70308. */
  70309. 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;
  70310. /** @hidden */
  70311. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70312. /** @hidden */
  70313. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70314. /** @hidden */
  70315. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70316. /** @hidden */
  70317. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70318. }
  70319. }
  70320. declare module BABYLON {
  70321. /**
  70322. * Class for creating a cube texture
  70323. */
  70324. export class CubeTexture extends BaseTexture {
  70325. private _delayedOnLoad;
  70326. /**
  70327. * The url of the texture
  70328. */
  70329. url: string;
  70330. /**
  70331. * Gets or sets the center of the bounding box associated with the cube texture.
  70332. * It must define where the camera used to render the texture was set
  70333. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70334. */
  70335. boundingBoxPosition: Vector3;
  70336. private _boundingBoxSize;
  70337. /**
  70338. * Gets or sets the size of the bounding box associated with the cube texture
  70339. * When defined, the cubemap will switch to local mode
  70340. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70341. * @example https://www.babylonjs-playground.com/#RNASML
  70342. */
  70343. /**
  70344. * Returns the bounding box size
  70345. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70346. */
  70347. boundingBoxSize: Vector3;
  70348. protected _rotationY: number;
  70349. /**
  70350. * Sets texture matrix rotation angle around Y axis in radians.
  70351. */
  70352. /**
  70353. * Gets texture matrix rotation angle around Y axis radians.
  70354. */
  70355. rotationY: number;
  70356. /**
  70357. * Are mip maps generated for this texture or not.
  70358. */
  70359. readonly noMipmap: boolean;
  70360. private _noMipmap;
  70361. private _files;
  70362. private _extensions;
  70363. private _textureMatrix;
  70364. private _format;
  70365. private _createPolynomials;
  70366. /** @hidden */
  70367. _prefiltered: boolean;
  70368. /**
  70369. * Creates a cube texture from an array of image urls
  70370. * @param files defines an array of image urls
  70371. * @param scene defines the hosting scene
  70372. * @param noMipmap specifies if mip maps are not used
  70373. * @returns a cube texture
  70374. */
  70375. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70376. /**
  70377. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70378. * @param url defines the url of the prefiltered texture
  70379. * @param scene defines the scene the texture is attached to
  70380. * @param forcedExtension defines the extension of the file if different from the url
  70381. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70382. * @return the prefiltered texture
  70383. */
  70384. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70385. /**
  70386. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70387. * as prefiltered data.
  70388. * @param rootUrl defines the url of the texture or the root name of the six images
  70389. * @param scene defines the scene the texture is attached to
  70390. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70391. * @param noMipmap defines if mipmaps should be created or not
  70392. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70393. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70394. * @param onError defines a callback triggered in case of error during load
  70395. * @param format defines the internal format to use for the texture once loaded
  70396. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70397. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70398. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70399. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70400. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70401. * @return the cube texture
  70402. */
  70403. 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);
  70404. /**
  70405. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70406. */
  70407. readonly isPrefiltered: boolean;
  70408. /**
  70409. * Get the current class name of the texture useful for serialization or dynamic coding.
  70410. * @returns "CubeTexture"
  70411. */
  70412. getClassName(): string;
  70413. /**
  70414. * Update the url (and optional buffer) of this texture if url was null during construction.
  70415. * @param url the url of the texture
  70416. * @param forcedExtension defines the extension to use
  70417. * @param onLoad callback called when the texture is loaded (defaults to null)
  70418. */
  70419. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70420. /**
  70421. * Delays loading of the cube texture
  70422. * @param forcedExtension defines the extension to use
  70423. */
  70424. delayLoad(forcedExtension?: string): void;
  70425. /**
  70426. * Returns the reflection texture matrix
  70427. * @returns the reflection texture matrix
  70428. */
  70429. getReflectionTextureMatrix(): Matrix;
  70430. /**
  70431. * Sets the reflection texture matrix
  70432. * @param value Reflection texture matrix
  70433. */
  70434. setReflectionTextureMatrix(value: Matrix): void;
  70435. /**
  70436. * Parses text to create a cube texture
  70437. * @param parsedTexture define the serialized text to read from
  70438. * @param scene defines the hosting scene
  70439. * @param rootUrl defines the root url of the cube texture
  70440. * @returns a cube texture
  70441. */
  70442. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70443. /**
  70444. * Makes a clone, or deep copy, of the cube texture
  70445. * @returns a new cube texture
  70446. */
  70447. clone(): CubeTexture;
  70448. }
  70449. }
  70450. declare module BABYLON {
  70451. /** @hidden */
  70452. export var postprocessVertexShader: {
  70453. name: string;
  70454. shader: string;
  70455. };
  70456. }
  70457. declare module BABYLON {
  70458. /**
  70459. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70460. * This is the base of the follow, arc rotate cameras and Free camera
  70461. * @see http://doc.babylonjs.com/features/cameras
  70462. */
  70463. export class TargetCamera extends Camera {
  70464. private static _RigCamTransformMatrix;
  70465. private static _TargetTransformMatrix;
  70466. private static _TargetFocalPoint;
  70467. /**
  70468. * Define the current direction the camera is moving to
  70469. */
  70470. cameraDirection: Vector3;
  70471. /**
  70472. * Define the current rotation the camera is rotating to
  70473. */
  70474. cameraRotation: Vector2;
  70475. /**
  70476. * When set, the up vector of the camera will be updated by the rotation of the camera
  70477. */
  70478. updateUpVectorFromRotation: boolean;
  70479. private _tmpQuaternion;
  70480. /**
  70481. * Define the current rotation of the camera
  70482. */
  70483. rotation: Vector3;
  70484. /**
  70485. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70486. */
  70487. rotationQuaternion: Quaternion;
  70488. /**
  70489. * Define the current speed of the camera
  70490. */
  70491. speed: number;
  70492. /**
  70493. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70494. * around all axis.
  70495. */
  70496. noRotationConstraint: boolean;
  70497. /**
  70498. * Define the current target of the camera as an object or a position.
  70499. */
  70500. lockedTarget: any;
  70501. /** @hidden */
  70502. _currentTarget: Vector3;
  70503. /** @hidden */
  70504. _initialFocalDistance: number;
  70505. /** @hidden */
  70506. _viewMatrix: Matrix;
  70507. /** @hidden */
  70508. _camMatrix: Matrix;
  70509. /** @hidden */
  70510. _cameraTransformMatrix: Matrix;
  70511. /** @hidden */
  70512. _cameraRotationMatrix: Matrix;
  70513. /** @hidden */
  70514. _referencePoint: Vector3;
  70515. /** @hidden */
  70516. _transformedReferencePoint: Vector3;
  70517. protected _globalCurrentTarget: Vector3;
  70518. protected _globalCurrentUpVector: Vector3;
  70519. /** @hidden */
  70520. _reset: () => void;
  70521. private _defaultUp;
  70522. /**
  70523. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70524. * This is the base of the follow, arc rotate cameras and Free camera
  70525. * @see http://doc.babylonjs.com/features/cameras
  70526. * @param name Defines the name of the camera in the scene
  70527. * @param position Defines the start position of the camera in the scene
  70528. * @param scene Defines the scene the camera belongs to
  70529. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70530. */
  70531. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70532. /**
  70533. * Gets the position in front of the camera at a given distance.
  70534. * @param distance The distance from the camera we want the position to be
  70535. * @returns the position
  70536. */
  70537. getFrontPosition(distance: number): Vector3;
  70538. /** @hidden */
  70539. _getLockedTargetPosition(): Nullable<Vector3>;
  70540. private _storedPosition;
  70541. private _storedRotation;
  70542. private _storedRotationQuaternion;
  70543. /**
  70544. * Store current camera state of the camera (fov, position, rotation, etc..)
  70545. * @returns the camera
  70546. */
  70547. storeState(): Camera;
  70548. /**
  70549. * Restored camera state. You must call storeState() first
  70550. * @returns whether it was successful or not
  70551. * @hidden
  70552. */
  70553. _restoreStateValues(): boolean;
  70554. /** @hidden */
  70555. _initCache(): void;
  70556. /** @hidden */
  70557. _updateCache(ignoreParentClass?: boolean): void;
  70558. /** @hidden */
  70559. _isSynchronizedViewMatrix(): boolean;
  70560. /** @hidden */
  70561. _computeLocalCameraSpeed(): number;
  70562. /**
  70563. * Defines the target the camera should look at.
  70564. * This will automatically adapt alpha beta and radius to fit within the new target.
  70565. * @param target Defines the new target as a Vector or a mesh
  70566. */
  70567. setTarget(target: Vector3): void;
  70568. /**
  70569. * Return the current target position of the camera. This value is expressed in local space.
  70570. * @returns the target position
  70571. */
  70572. getTarget(): Vector3;
  70573. /** @hidden */
  70574. _decideIfNeedsToMove(): boolean;
  70575. /** @hidden */
  70576. _updatePosition(): void;
  70577. /** @hidden */
  70578. _checkInputs(): void;
  70579. protected _updateCameraRotationMatrix(): void;
  70580. /**
  70581. * 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)
  70582. * @returns the current camera
  70583. */
  70584. private _rotateUpVectorWithCameraRotationMatrix;
  70585. private _cachedRotationZ;
  70586. private _cachedQuaternionRotationZ;
  70587. /** @hidden */
  70588. _getViewMatrix(): Matrix;
  70589. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70590. /**
  70591. * @hidden
  70592. */
  70593. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70594. /**
  70595. * @hidden
  70596. */
  70597. _updateRigCameras(): void;
  70598. private _getRigCamPositionAndTarget;
  70599. /**
  70600. * Gets the current object class name.
  70601. * @return the class name
  70602. */
  70603. getClassName(): string;
  70604. }
  70605. }
  70606. declare module BABYLON {
  70607. /**
  70608. * @ignore
  70609. * This is a list of all the different input types that are available in the application.
  70610. * Fo instance: ArcRotateCameraGamepadInput...
  70611. */
  70612. export var CameraInputTypes: {};
  70613. /**
  70614. * This is the contract to implement in order to create a new input class.
  70615. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70616. */
  70617. export interface ICameraInput<TCamera extends Camera> {
  70618. /**
  70619. * Defines the camera the input is attached to.
  70620. */
  70621. camera: Nullable<TCamera>;
  70622. /**
  70623. * Gets the class name of the current intput.
  70624. * @returns the class name
  70625. */
  70626. getClassName(): string;
  70627. /**
  70628. * Get the friendly name associated with the input class.
  70629. * @returns the input friendly name
  70630. */
  70631. getSimpleName(): string;
  70632. /**
  70633. * Attach the input controls to a specific dom element to get the input from.
  70634. * @param element Defines the element the controls should be listened from
  70635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70636. */
  70637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70638. /**
  70639. * Detach the current controls from the specified dom element.
  70640. * @param element Defines the element to stop listening the inputs from
  70641. */
  70642. detachControl(element: Nullable<HTMLElement>): void;
  70643. /**
  70644. * Update the current camera state depending on the inputs that have been used this frame.
  70645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70646. */
  70647. checkInputs?: () => void;
  70648. }
  70649. /**
  70650. * Represents a map of input types to input instance or input index to input instance.
  70651. */
  70652. export interface CameraInputsMap<TCamera extends Camera> {
  70653. /**
  70654. * Accessor to the input by input type.
  70655. */
  70656. [name: string]: ICameraInput<TCamera>;
  70657. /**
  70658. * Accessor to the input by input index.
  70659. */
  70660. [idx: number]: ICameraInput<TCamera>;
  70661. }
  70662. /**
  70663. * This represents the input manager used within a camera.
  70664. * It helps dealing with all the different kind of input attached to a camera.
  70665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70666. */
  70667. export class CameraInputsManager<TCamera extends Camera> {
  70668. /**
  70669. * Defines the list of inputs attahed to the camera.
  70670. */
  70671. attached: CameraInputsMap<TCamera>;
  70672. /**
  70673. * Defines the dom element the camera is collecting inputs from.
  70674. * This is null if the controls have not been attached.
  70675. */
  70676. attachedElement: Nullable<HTMLElement>;
  70677. /**
  70678. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70679. */
  70680. noPreventDefault: boolean;
  70681. /**
  70682. * Defined the camera the input manager belongs to.
  70683. */
  70684. camera: TCamera;
  70685. /**
  70686. * Update the current camera state depending on the inputs that have been used this frame.
  70687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70688. */
  70689. checkInputs: () => void;
  70690. /**
  70691. * Instantiate a new Camera Input Manager.
  70692. * @param camera Defines the camera the input manager blongs to
  70693. */
  70694. constructor(camera: TCamera);
  70695. /**
  70696. * Add an input method to a camera
  70697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70698. * @param input camera input method
  70699. */
  70700. add(input: ICameraInput<TCamera>): void;
  70701. /**
  70702. * Remove a specific input method from a camera
  70703. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70704. * @param inputToRemove camera input method
  70705. */
  70706. remove(inputToRemove: ICameraInput<TCamera>): void;
  70707. /**
  70708. * Remove a specific input type from a camera
  70709. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70710. * @param inputType the type of the input to remove
  70711. */
  70712. removeByType(inputType: string): void;
  70713. private _addCheckInputs;
  70714. /**
  70715. * Attach the input controls to the currently attached dom element to listen the events from.
  70716. * @param input Defines the input to attach
  70717. */
  70718. attachInput(input: ICameraInput<TCamera>): void;
  70719. /**
  70720. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70721. * @param element Defines the dom element to collect the events from
  70722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70723. */
  70724. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70725. /**
  70726. * Detach the current manager inputs controls from a specific dom element.
  70727. * @param element Defines the dom element to collect the events from
  70728. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70729. */
  70730. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70731. /**
  70732. * Rebuild the dynamic inputCheck function from the current list of
  70733. * defined inputs in the manager.
  70734. */
  70735. rebuildInputCheck(): void;
  70736. /**
  70737. * Remove all attached input methods from a camera
  70738. */
  70739. clear(): void;
  70740. /**
  70741. * Serialize the current input manager attached to a camera.
  70742. * This ensures than once parsed,
  70743. * the input associated to the camera will be identical to the current ones
  70744. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70745. */
  70746. serialize(serializedCamera: any): void;
  70747. /**
  70748. * Parses an input manager serialized JSON to restore the previous list of inputs
  70749. * and states associated to a camera.
  70750. * @param parsedCamera Defines the JSON to parse
  70751. */
  70752. parse(parsedCamera: any): void;
  70753. }
  70754. }
  70755. declare module BABYLON {
  70756. /**
  70757. * Gather the list of keyboard event types as constants.
  70758. */
  70759. export class KeyboardEventTypes {
  70760. /**
  70761. * The keydown event is fired when a key becomes active (pressed).
  70762. */
  70763. static readonly KEYDOWN: number;
  70764. /**
  70765. * The keyup event is fired when a key has been released.
  70766. */
  70767. static readonly KEYUP: number;
  70768. }
  70769. /**
  70770. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70771. */
  70772. export class KeyboardInfo {
  70773. /**
  70774. * Defines the type of event (KeyboardEventTypes)
  70775. */
  70776. type: number;
  70777. /**
  70778. * Defines the related dom event
  70779. */
  70780. event: KeyboardEvent;
  70781. /**
  70782. * Instantiates a new keyboard info.
  70783. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70784. * @param type Defines the type of event (KeyboardEventTypes)
  70785. * @param event Defines the related dom event
  70786. */
  70787. constructor(
  70788. /**
  70789. * Defines the type of event (KeyboardEventTypes)
  70790. */
  70791. type: number,
  70792. /**
  70793. * Defines the related dom event
  70794. */
  70795. event: KeyboardEvent);
  70796. }
  70797. /**
  70798. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70799. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  70800. */
  70801. export class KeyboardInfoPre extends KeyboardInfo {
  70802. /**
  70803. * Defines the type of event (KeyboardEventTypes)
  70804. */
  70805. type: number;
  70806. /**
  70807. * Defines the related dom event
  70808. */
  70809. event: KeyboardEvent;
  70810. /**
  70811. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  70812. */
  70813. skipOnPointerObservable: boolean;
  70814. /**
  70815. * Instantiates a new keyboard pre info.
  70816. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70817. * @param type Defines the type of event (KeyboardEventTypes)
  70818. * @param event Defines the related dom event
  70819. */
  70820. constructor(
  70821. /**
  70822. * Defines the type of event (KeyboardEventTypes)
  70823. */
  70824. type: number,
  70825. /**
  70826. * Defines the related dom event
  70827. */
  70828. event: KeyboardEvent);
  70829. }
  70830. }
  70831. declare module BABYLON {
  70832. /**
  70833. * Manage the keyboard inputs to control the movement of a free camera.
  70834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70835. */
  70836. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  70837. /**
  70838. * Defines the camera the input is attached to.
  70839. */
  70840. camera: FreeCamera;
  70841. /**
  70842. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70843. */
  70844. keysUp: number[];
  70845. /**
  70846. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70847. */
  70848. keysDown: number[];
  70849. /**
  70850. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70851. */
  70852. keysLeft: number[];
  70853. /**
  70854. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70855. */
  70856. keysRight: number[];
  70857. private _keys;
  70858. private _onCanvasBlurObserver;
  70859. private _onKeyboardObserver;
  70860. private _engine;
  70861. private _scene;
  70862. /**
  70863. * Attach the input controls to a specific dom element to get the input from.
  70864. * @param element Defines the element the controls should be listened from
  70865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70866. */
  70867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70868. /**
  70869. * Detach the current controls from the specified dom element.
  70870. * @param element Defines the element to stop listening the inputs from
  70871. */
  70872. detachControl(element: Nullable<HTMLElement>): void;
  70873. /**
  70874. * Update the current camera state depending on the inputs that have been used this frame.
  70875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70876. */
  70877. checkInputs(): void;
  70878. /**
  70879. * Gets the class name of the current intput.
  70880. * @returns the class name
  70881. */
  70882. getClassName(): string;
  70883. /** @hidden */
  70884. _onLostFocus(): void;
  70885. /**
  70886. * Get the friendly name associated with the input class.
  70887. * @returns the input friendly name
  70888. */
  70889. getSimpleName(): string;
  70890. }
  70891. }
  70892. declare module BABYLON {
  70893. /**
  70894. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70895. * separate meshes. This can be use to improve performances.
  70896. * @see http://doc.babylonjs.com/how_to/multi_materials
  70897. */
  70898. export class MultiMaterial extends Material {
  70899. private _subMaterials;
  70900. /**
  70901. * Gets or Sets the list of Materials used within the multi material.
  70902. * They need to be ordered according to the submeshes order in the associated mesh
  70903. */
  70904. subMaterials: Nullable<Material>[];
  70905. /**
  70906. * Function used to align with Node.getChildren()
  70907. * @returns the list of Materials used within the multi material
  70908. */
  70909. getChildren(): Nullable<Material>[];
  70910. /**
  70911. * Instantiates a new Multi Material
  70912. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70913. * separate meshes. This can be use to improve performances.
  70914. * @see http://doc.babylonjs.com/how_to/multi_materials
  70915. * @param name Define the name in the scene
  70916. * @param scene Define the scene the material belongs to
  70917. */
  70918. constructor(name: string, scene: Scene);
  70919. private _hookArray;
  70920. /**
  70921. * Get one of the submaterial by its index in the submaterials array
  70922. * @param index The index to look the sub material at
  70923. * @returns The Material if the index has been defined
  70924. */
  70925. getSubMaterial(index: number): Nullable<Material>;
  70926. /**
  70927. * Get the list of active textures for the whole sub materials list.
  70928. * @returns All the textures that will be used during the rendering
  70929. */
  70930. getActiveTextures(): BaseTexture[];
  70931. /**
  70932. * Gets the current class name of the material e.g. "MultiMaterial"
  70933. * Mainly use in serialization.
  70934. * @returns the class name
  70935. */
  70936. getClassName(): string;
  70937. /**
  70938. * Checks if the material is ready to render the requested sub mesh
  70939. * @param mesh Define the mesh the submesh belongs to
  70940. * @param subMesh Define the sub mesh to look readyness for
  70941. * @param useInstances Define whether or not the material is used with instances
  70942. * @returns true if ready, otherwise false
  70943. */
  70944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  70945. /**
  70946. * Clones the current material and its related sub materials
  70947. * @param name Define the name of the newly cloned material
  70948. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  70949. * @returns the cloned material
  70950. */
  70951. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  70952. /**
  70953. * Serializes the materials into a JSON representation.
  70954. * @returns the JSON representation
  70955. */
  70956. serialize(): any;
  70957. /**
  70958. * Dispose the material and release its associated resources
  70959. * @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)
  70960. * @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)
  70961. * @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)
  70962. */
  70963. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  70964. /**
  70965. * Creates a MultiMaterial from parsed MultiMaterial data.
  70966. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  70967. * @param scene defines the hosting scene
  70968. * @returns a new MultiMaterial
  70969. */
  70970. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  70971. }
  70972. }
  70973. declare module BABYLON {
  70974. /**
  70975. * Class used to represent data loading progression
  70976. */
  70977. export class SceneLoaderFlags {
  70978. private static _ForceFullSceneLoadingForIncremental;
  70979. private static _ShowLoadingScreen;
  70980. private static _CleanBoneMatrixWeights;
  70981. private static _loggingLevel;
  70982. /**
  70983. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  70984. */
  70985. static ForceFullSceneLoadingForIncremental: boolean;
  70986. /**
  70987. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  70988. */
  70989. static ShowLoadingScreen: boolean;
  70990. /**
  70991. * Defines the current logging level (while loading the scene)
  70992. * @ignorenaming
  70993. */
  70994. static loggingLevel: number;
  70995. /**
  70996. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  70997. */
  70998. static CleanBoneMatrixWeights: boolean;
  70999. }
  71000. }
  71001. declare module BABYLON {
  71002. /**
  71003. * 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.
  71004. * @see https://doc.babylonjs.com/how_to/transformnode
  71005. */
  71006. export class TransformNode extends Node {
  71007. /**
  71008. * Object will not rotate to face the camera
  71009. */
  71010. static BILLBOARDMODE_NONE: number;
  71011. /**
  71012. * Object will rotate to face the camera but only on the x axis
  71013. */
  71014. static BILLBOARDMODE_X: number;
  71015. /**
  71016. * Object will rotate to face the camera but only on the y axis
  71017. */
  71018. static BILLBOARDMODE_Y: number;
  71019. /**
  71020. * Object will rotate to face the camera but only on the z axis
  71021. */
  71022. static BILLBOARDMODE_Z: number;
  71023. /**
  71024. * Object will rotate to face the camera
  71025. */
  71026. static BILLBOARDMODE_ALL: number;
  71027. private _forward;
  71028. private _forwardInverted;
  71029. private _up;
  71030. private _right;
  71031. private _rightInverted;
  71032. private _position;
  71033. private _rotation;
  71034. private _rotationQuaternion;
  71035. protected _scaling: Vector3;
  71036. protected _isDirty: boolean;
  71037. private _transformToBoneReferal;
  71038. private _billboardMode;
  71039. /**
  71040. * Gets or sets the billboard mode. Default is 0.
  71041. *
  71042. * | Value | Type | Description |
  71043. * | --- | --- | --- |
  71044. * | 0 | BILLBOARDMODE_NONE | |
  71045. * | 1 | BILLBOARDMODE_X | |
  71046. * | 2 | BILLBOARDMODE_Y | |
  71047. * | 4 | BILLBOARDMODE_Z | |
  71048. * | 7 | BILLBOARDMODE_ALL | |
  71049. *
  71050. */
  71051. billboardMode: number;
  71052. private _preserveParentRotationForBillboard;
  71053. /**
  71054. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71055. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71056. */
  71057. preserveParentRotationForBillboard: boolean;
  71058. /**
  71059. * 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
  71060. */
  71061. scalingDeterminant: number;
  71062. private _infiniteDistance;
  71063. /**
  71064. * Gets or sets the distance of the object to max, often used by skybox
  71065. */
  71066. infiniteDistance: boolean;
  71067. /**
  71068. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71069. * By default the system will update normals to compensate
  71070. */
  71071. ignoreNonUniformScaling: boolean;
  71072. /**
  71073. * 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
  71074. */
  71075. reIntegrateRotationIntoRotationQuaternion: boolean;
  71076. /** @hidden */
  71077. _poseMatrix: Nullable<Matrix>;
  71078. /** @hidden */
  71079. _localMatrix: Matrix;
  71080. private _usePivotMatrix;
  71081. private _absolutePosition;
  71082. private _pivotMatrix;
  71083. private _pivotMatrixInverse;
  71084. protected _postMultiplyPivotMatrix: boolean;
  71085. protected _isWorldMatrixFrozen: boolean;
  71086. /** @hidden */
  71087. _indexInSceneTransformNodesArray: number;
  71088. /**
  71089. * An event triggered after the world matrix is updated
  71090. */
  71091. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71092. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71093. /**
  71094. * Gets a string identifying the name of the class
  71095. * @returns "TransformNode" string
  71096. */
  71097. getClassName(): string;
  71098. /**
  71099. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71100. */
  71101. position: Vector3;
  71102. /**
  71103. * 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)).
  71104. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71105. */
  71106. rotation: Vector3;
  71107. /**
  71108. * 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)).
  71109. */
  71110. scaling: Vector3;
  71111. /**
  71112. * 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).
  71113. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71114. */
  71115. rotationQuaternion: Nullable<Quaternion>;
  71116. /**
  71117. * The forward direction of that transform in world space.
  71118. */
  71119. readonly forward: Vector3;
  71120. /**
  71121. * The up direction of that transform in world space.
  71122. */
  71123. readonly up: Vector3;
  71124. /**
  71125. * The right direction of that transform in world space.
  71126. */
  71127. readonly right: Vector3;
  71128. /**
  71129. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71130. * @param matrix the matrix to copy the pose from
  71131. * @returns this TransformNode.
  71132. */
  71133. updatePoseMatrix(matrix: Matrix): TransformNode;
  71134. /**
  71135. * Returns the mesh Pose matrix.
  71136. * @returns the pose matrix
  71137. */
  71138. getPoseMatrix(): Matrix;
  71139. /** @hidden */
  71140. _isSynchronized(): boolean;
  71141. /** @hidden */
  71142. _initCache(): void;
  71143. /**
  71144. * Flag the transform node as dirty (Forcing it to update everything)
  71145. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71146. * @returns this transform node
  71147. */
  71148. markAsDirty(property: string): TransformNode;
  71149. /**
  71150. * Returns the current mesh absolute position.
  71151. * Returns a Vector3.
  71152. */
  71153. readonly absolutePosition: Vector3;
  71154. /**
  71155. * Sets a new matrix to apply before all other transformation
  71156. * @param matrix defines the transform matrix
  71157. * @returns the current TransformNode
  71158. */
  71159. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71160. /**
  71161. * Sets a new pivot matrix to the current node
  71162. * @param matrix defines the new pivot matrix to use
  71163. * @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
  71164. * @returns the current TransformNode
  71165. */
  71166. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71167. /**
  71168. * Returns the mesh pivot matrix.
  71169. * Default : Identity.
  71170. * @returns the matrix
  71171. */
  71172. getPivotMatrix(): Matrix;
  71173. /**
  71174. * Prevents the World matrix to be computed any longer.
  71175. * @returns the TransformNode.
  71176. */
  71177. freezeWorldMatrix(): TransformNode;
  71178. /**
  71179. * Allows back the World matrix computation.
  71180. * @returns the TransformNode.
  71181. */
  71182. unfreezeWorldMatrix(): this;
  71183. /**
  71184. * True if the World matrix has been frozen.
  71185. */
  71186. readonly isWorldMatrixFrozen: boolean;
  71187. /**
  71188. * Retuns the mesh absolute position in the World.
  71189. * @returns a Vector3.
  71190. */
  71191. getAbsolutePosition(): Vector3;
  71192. /**
  71193. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71194. * @param absolutePosition the absolute position to set
  71195. * @returns the TransformNode.
  71196. */
  71197. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71198. /**
  71199. * Sets the mesh position in its local space.
  71200. * @param vector3 the position to set in localspace
  71201. * @returns the TransformNode.
  71202. */
  71203. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71204. /**
  71205. * Returns the mesh position in the local space from the current World matrix values.
  71206. * @returns a new Vector3.
  71207. */
  71208. getPositionExpressedInLocalSpace(): Vector3;
  71209. /**
  71210. * Translates the mesh along the passed Vector3 in its local space.
  71211. * @param vector3 the distance to translate in localspace
  71212. * @returns the TransformNode.
  71213. */
  71214. locallyTranslate(vector3: Vector3): TransformNode;
  71215. private static _lookAtVectorCache;
  71216. /**
  71217. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71218. * @param targetPoint the position (must be in same space as current mesh) to look at
  71219. * @param yawCor optional yaw (y-axis) correction in radians
  71220. * @param pitchCor optional pitch (x-axis) correction in radians
  71221. * @param rollCor optional roll (z-axis) correction in radians
  71222. * @param space the choosen space of the target
  71223. * @returns the TransformNode.
  71224. */
  71225. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71226. /**
  71227. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71228. * This Vector3 is expressed in the World space.
  71229. * @param localAxis axis to rotate
  71230. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71231. */
  71232. getDirection(localAxis: Vector3): Vector3;
  71233. /**
  71234. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71235. * localAxis is expressed in the mesh local space.
  71236. * result is computed in the Wordl space from the mesh World matrix.
  71237. * @param localAxis axis to rotate
  71238. * @param result the resulting transformnode
  71239. * @returns this TransformNode.
  71240. */
  71241. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71242. /**
  71243. * Sets this transform node rotation to the given local axis.
  71244. * @param localAxis the axis in local space
  71245. * @param yawCor optional yaw (y-axis) correction in radians
  71246. * @param pitchCor optional pitch (x-axis) correction in radians
  71247. * @param rollCor optional roll (z-axis) correction in radians
  71248. * @returns this TransformNode
  71249. */
  71250. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71251. /**
  71252. * Sets a new pivot point to the current node
  71253. * @param point defines the new pivot point to use
  71254. * @param space defines if the point is in world or local space (local by default)
  71255. * @returns the current TransformNode
  71256. */
  71257. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71258. /**
  71259. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71260. * @returns the pivot point
  71261. */
  71262. getPivotPoint(): Vector3;
  71263. /**
  71264. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71265. * @param result the vector3 to store the result
  71266. * @returns this TransformNode.
  71267. */
  71268. getPivotPointToRef(result: Vector3): TransformNode;
  71269. /**
  71270. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71271. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71272. */
  71273. getAbsolutePivotPoint(): Vector3;
  71274. /**
  71275. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71276. * @param result vector3 to store the result
  71277. * @returns this TransformNode.
  71278. */
  71279. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71280. /**
  71281. * Defines the passed node as the parent of the current node.
  71282. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71283. * @see https://doc.babylonjs.com/how_to/parenting
  71284. * @param node the node ot set as the parent
  71285. * @returns this TransformNode.
  71286. */
  71287. setParent(node: Nullable<Node>): TransformNode;
  71288. private _nonUniformScaling;
  71289. /**
  71290. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71291. */
  71292. readonly nonUniformScaling: boolean;
  71293. /** @hidden */
  71294. _updateNonUniformScalingState(value: boolean): boolean;
  71295. /**
  71296. * Attach the current TransformNode to another TransformNode associated with a bone
  71297. * @param bone Bone affecting the TransformNode
  71298. * @param affectedTransformNode TransformNode associated with the bone
  71299. * @returns this object
  71300. */
  71301. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71302. /**
  71303. * Detach the transform node if its associated with a bone
  71304. * @returns this object
  71305. */
  71306. detachFromBone(): TransformNode;
  71307. private static _rotationAxisCache;
  71308. /**
  71309. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71310. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71311. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71312. * The passed axis is also normalized.
  71313. * @param axis the axis to rotate around
  71314. * @param amount the amount to rotate in radians
  71315. * @param space Space to rotate in (Default: local)
  71316. * @returns the TransformNode.
  71317. */
  71318. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71319. /**
  71320. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71321. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71322. * The passed axis is also normalized. .
  71323. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71324. * @param point the point to rotate around
  71325. * @param axis the axis to rotate around
  71326. * @param amount the amount to rotate in radians
  71327. * @returns the TransformNode
  71328. */
  71329. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71330. /**
  71331. * Translates the mesh along the axis vector for the passed distance in the given space.
  71332. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71333. * @param axis the axis to translate in
  71334. * @param distance the distance to translate
  71335. * @param space Space to rotate in (Default: local)
  71336. * @returns the TransformNode.
  71337. */
  71338. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71339. /**
  71340. * Adds a rotation step to the mesh current rotation.
  71341. * x, y, z are Euler angles expressed in radians.
  71342. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71343. * This means this rotation is made in the mesh local space only.
  71344. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71345. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71346. * ```javascript
  71347. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71348. * ```
  71349. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71350. * 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.
  71351. * @param x Rotation to add
  71352. * @param y Rotation to add
  71353. * @param z Rotation to add
  71354. * @returns the TransformNode.
  71355. */
  71356. addRotation(x: number, y: number, z: number): TransformNode;
  71357. /**
  71358. * @hidden
  71359. */
  71360. protected _getEffectiveParent(): Nullable<Node>;
  71361. /**
  71362. * Computes the world matrix of the node
  71363. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71364. * @returns the world matrix
  71365. */
  71366. computeWorldMatrix(force?: boolean): Matrix;
  71367. protected _afterComputeWorldMatrix(): void;
  71368. /**
  71369. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71370. * @param func callback function to add
  71371. *
  71372. * @returns the TransformNode.
  71373. */
  71374. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71375. /**
  71376. * Removes a registered callback function.
  71377. * @param func callback function to remove
  71378. * @returns the TransformNode.
  71379. */
  71380. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71381. /**
  71382. * Gets the position of the current mesh in camera space
  71383. * @param camera defines the camera to use
  71384. * @returns a position
  71385. */
  71386. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71387. /**
  71388. * Returns the distance from the mesh to the active camera
  71389. * @param camera defines the camera to use
  71390. * @returns the distance
  71391. */
  71392. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71393. /**
  71394. * Clone the current transform node
  71395. * @param name Name of the new clone
  71396. * @param newParent New parent for the clone
  71397. * @param doNotCloneChildren Do not clone children hierarchy
  71398. * @returns the new transform node
  71399. */
  71400. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71401. /**
  71402. * Serializes the objects information.
  71403. * @param currentSerializationObject defines the object to serialize in
  71404. * @returns the serialized object
  71405. */
  71406. serialize(currentSerializationObject?: any): any;
  71407. /**
  71408. * Returns a new TransformNode object parsed from the source provided.
  71409. * @param parsedTransformNode is the source.
  71410. * @param scene the scne the object belongs to
  71411. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71412. * @returns a new TransformNode object parsed from the source provided.
  71413. */
  71414. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71415. /**
  71416. * Get all child-transformNodes of this node
  71417. * @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
  71418. * @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
  71419. * @returns an array of TransformNode
  71420. */
  71421. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71422. /**
  71423. * Releases resources associated with this transform node.
  71424. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71425. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71426. */
  71427. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71428. /**
  71429. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71430. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71431. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71432. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71433. * @returns the current mesh
  71434. */
  71435. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71436. }
  71437. }
  71438. declare module BABYLON {
  71439. /**
  71440. * Class used to override all child animations of a given target
  71441. */
  71442. export class AnimationPropertiesOverride {
  71443. /**
  71444. * Gets or sets a value indicating if animation blending must be used
  71445. */
  71446. enableBlending: boolean;
  71447. /**
  71448. * Gets or sets the blending speed to use when enableBlending is true
  71449. */
  71450. blendingSpeed: number;
  71451. /**
  71452. * Gets or sets the default loop mode to use
  71453. */
  71454. loopMode: number;
  71455. }
  71456. }
  71457. declare module BABYLON {
  71458. /**
  71459. * Class used to store bone information
  71460. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71461. */
  71462. export class Bone extends Node {
  71463. /**
  71464. * defines the bone name
  71465. */
  71466. name: string;
  71467. private static _tmpVecs;
  71468. private static _tmpQuat;
  71469. private static _tmpMats;
  71470. /**
  71471. * Gets the list of child bones
  71472. */
  71473. children: Bone[];
  71474. /** Gets the animations associated with this bone */
  71475. animations: Animation[];
  71476. /**
  71477. * Gets or sets bone length
  71478. */
  71479. length: number;
  71480. /**
  71481. * @hidden Internal only
  71482. * Set this value to map this bone to a different index in the transform matrices
  71483. * Set this value to -1 to exclude the bone from the transform matrices
  71484. */
  71485. _index: Nullable<number>;
  71486. private _skeleton;
  71487. private _localMatrix;
  71488. private _restPose;
  71489. private _baseMatrix;
  71490. private _absoluteTransform;
  71491. private _invertedAbsoluteTransform;
  71492. private _parent;
  71493. private _scalingDeterminant;
  71494. private _worldTransform;
  71495. private _localScaling;
  71496. private _localRotation;
  71497. private _localPosition;
  71498. private _needToDecompose;
  71499. private _needToCompose;
  71500. /** @hidden */
  71501. _linkedTransformNode: Nullable<TransformNode>;
  71502. /** @hidden */
  71503. _waitingTransformNodeId: Nullable<string>;
  71504. /** @hidden */
  71505. /** @hidden */
  71506. _matrix: Matrix;
  71507. /**
  71508. * Create a new bone
  71509. * @param name defines the bone name
  71510. * @param skeleton defines the parent skeleton
  71511. * @param parentBone defines the parent (can be null if the bone is the root)
  71512. * @param localMatrix defines the local matrix
  71513. * @param restPose defines the rest pose matrix
  71514. * @param baseMatrix defines the base matrix
  71515. * @param index defines index of the bone in the hiearchy
  71516. */
  71517. constructor(
  71518. /**
  71519. * defines the bone name
  71520. */
  71521. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71522. /**
  71523. * Gets the current object class name.
  71524. * @return the class name
  71525. */
  71526. getClassName(): string;
  71527. /**
  71528. * Gets the parent skeleton
  71529. * @returns a skeleton
  71530. */
  71531. getSkeleton(): Skeleton;
  71532. /**
  71533. * Gets parent bone
  71534. * @returns a bone or null if the bone is the root of the bone hierarchy
  71535. */
  71536. getParent(): Nullable<Bone>;
  71537. /**
  71538. * Returns an array containing the root bones
  71539. * @returns an array containing the root bones
  71540. */
  71541. getChildren(): Array<Bone>;
  71542. /**
  71543. * Sets the parent bone
  71544. * @param parent defines the parent (can be null if the bone is the root)
  71545. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71546. */
  71547. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71548. /**
  71549. * Gets the local matrix
  71550. * @returns a matrix
  71551. */
  71552. getLocalMatrix(): Matrix;
  71553. /**
  71554. * Gets the base matrix (initial matrix which remains unchanged)
  71555. * @returns a matrix
  71556. */
  71557. getBaseMatrix(): Matrix;
  71558. /**
  71559. * Gets the rest pose matrix
  71560. * @returns a matrix
  71561. */
  71562. getRestPose(): Matrix;
  71563. /**
  71564. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71565. */
  71566. getWorldMatrix(): Matrix;
  71567. /**
  71568. * Sets the local matrix to rest pose matrix
  71569. */
  71570. returnToRest(): void;
  71571. /**
  71572. * Gets the inverse of the absolute transform matrix.
  71573. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71574. * @returns a matrix
  71575. */
  71576. getInvertedAbsoluteTransform(): Matrix;
  71577. /**
  71578. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71579. * @returns a matrix
  71580. */
  71581. getAbsoluteTransform(): Matrix;
  71582. /**
  71583. * Links with the given transform node.
  71584. * The local matrix of this bone is copied from the transform node every frame.
  71585. * @param transformNode defines the transform node to link to
  71586. */
  71587. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71588. /** Gets or sets current position (in local space) */
  71589. position: Vector3;
  71590. /** Gets or sets current rotation (in local space) */
  71591. rotation: Vector3;
  71592. /** Gets or sets current rotation quaternion (in local space) */
  71593. rotationQuaternion: Quaternion;
  71594. /** Gets or sets current scaling (in local space) */
  71595. scaling: Vector3;
  71596. /**
  71597. * Gets the animation properties override
  71598. */
  71599. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71600. private _decompose;
  71601. private _compose;
  71602. /**
  71603. * Update the base and local matrices
  71604. * @param matrix defines the new base or local matrix
  71605. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71606. * @param updateLocalMatrix defines if the local matrix should be updated
  71607. */
  71608. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71609. /** @hidden */
  71610. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71611. /**
  71612. * Flag the bone as dirty (Forcing it to update everything)
  71613. */
  71614. markAsDirty(): void;
  71615. /** @hidden */
  71616. _markAsDirtyAndCompose(): void;
  71617. private _markAsDirtyAndDecompose;
  71618. /**
  71619. * Translate the bone in local or world space
  71620. * @param vec The amount to translate the bone
  71621. * @param space The space that the translation is in
  71622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71623. */
  71624. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71625. /**
  71626. * Set the postion of the bone in local or world space
  71627. * @param position The position to set the bone
  71628. * @param space The space that the position is in
  71629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71630. */
  71631. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71632. /**
  71633. * Set the absolute position of the bone (world space)
  71634. * @param position The position to set the bone
  71635. * @param mesh The mesh that this bone is attached to
  71636. */
  71637. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71638. /**
  71639. * Scale the bone on the x, y and z axes (in local space)
  71640. * @param x The amount to scale the bone on the x axis
  71641. * @param y The amount to scale the bone on the y axis
  71642. * @param z The amount to scale the bone on the z axis
  71643. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71644. */
  71645. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71646. /**
  71647. * Set the bone scaling in local space
  71648. * @param scale defines the scaling vector
  71649. */
  71650. setScale(scale: Vector3): void;
  71651. /**
  71652. * Gets the current scaling in local space
  71653. * @returns the current scaling vector
  71654. */
  71655. getScale(): Vector3;
  71656. /**
  71657. * Gets the current scaling in local space and stores it in a target vector
  71658. * @param result defines the target vector
  71659. */
  71660. getScaleToRef(result: Vector3): void;
  71661. /**
  71662. * Set the yaw, pitch, and roll of the bone in local or world space
  71663. * @param yaw The rotation of the bone on the y axis
  71664. * @param pitch The rotation of the bone on the x axis
  71665. * @param roll The rotation of the bone on the z axis
  71666. * @param space The space that the axes of rotation are in
  71667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71668. */
  71669. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  71670. /**
  71671. * Add a rotation to the bone on an axis in local or world space
  71672. * @param axis The axis to rotate the bone on
  71673. * @param amount The amount to rotate the bone
  71674. * @param space The space that the axis is in
  71675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71676. */
  71677. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  71678. /**
  71679. * Set the rotation of the bone to a particular axis angle in local or world space
  71680. * @param axis The axis to rotate the bone on
  71681. * @param angle The angle that the bone should be rotated to
  71682. * @param space The space that the axis is in
  71683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71684. */
  71685. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  71686. /**
  71687. * Set the euler rotation of the bone in local of world space
  71688. * @param rotation The euler rotation that the bone should be set to
  71689. * @param space The space that the rotation is in
  71690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71691. */
  71692. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71693. /**
  71694. * Set the quaternion rotation of the bone in local of world space
  71695. * @param quat The quaternion rotation that the bone should be set to
  71696. * @param space The space that the rotation is in
  71697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71698. */
  71699. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  71700. /**
  71701. * Set the rotation matrix of the bone in local of world space
  71702. * @param rotMat The rotation matrix that the bone should be set to
  71703. * @param space The space that the rotation is in
  71704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71705. */
  71706. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  71707. private _rotateWithMatrix;
  71708. private _getNegativeRotationToRef;
  71709. /**
  71710. * Get the position of the bone in local or world space
  71711. * @param space The space that the returned position is in
  71712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71713. * @returns The position of the bone
  71714. */
  71715. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71716. /**
  71717. * Copy the position of the bone to a vector3 in local or world space
  71718. * @param space The space that the returned position is in
  71719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71720. * @param result The vector3 to copy the position to
  71721. */
  71722. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  71723. /**
  71724. * Get the absolute position of the bone (world space)
  71725. * @param mesh The mesh that this bone is attached to
  71726. * @returns The absolute position of the bone
  71727. */
  71728. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  71729. /**
  71730. * Copy the absolute position of the bone (world space) to the result param
  71731. * @param mesh The mesh that this bone is attached to
  71732. * @param result The vector3 to copy the absolute position to
  71733. */
  71734. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  71735. /**
  71736. * Compute the absolute transforms of this bone and its children
  71737. */
  71738. computeAbsoluteTransforms(): void;
  71739. /**
  71740. * Get the world direction from an axis that is in the local space of the bone
  71741. * @param localAxis The local direction that is used to compute the world direction
  71742. * @param mesh The mesh that this bone is attached to
  71743. * @returns The world direction
  71744. */
  71745. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71746. /**
  71747. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  71748. * @param localAxis The local direction that is used to compute the world direction
  71749. * @param mesh The mesh that this bone is attached to
  71750. * @param result The vector3 that the world direction will be copied to
  71751. */
  71752. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71753. /**
  71754. * Get the euler rotation of the bone in local or world space
  71755. * @param space The space that the rotation should be in
  71756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71757. * @returns The euler rotation
  71758. */
  71759. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71760. /**
  71761. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  71762. * @param space The space that the rotation should be in
  71763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71764. * @param result The vector3 that the rotation should be copied to
  71765. */
  71766. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71767. /**
  71768. * Get the quaternion rotation of the bone in either local or world space
  71769. * @param space The space that the rotation should be in
  71770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71771. * @returns The quaternion rotation
  71772. */
  71773. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  71774. /**
  71775. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  71776. * @param space The space that the rotation should be in
  71777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71778. * @param result The quaternion that the rotation should be copied to
  71779. */
  71780. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  71781. /**
  71782. * Get the rotation matrix of the bone in local or world space
  71783. * @param space The space that the rotation should be in
  71784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71785. * @returns The rotation matrix
  71786. */
  71787. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  71788. /**
  71789. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  71790. * @param space The space that the rotation should be in
  71791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71792. * @param result The quaternion that the rotation should be copied to
  71793. */
  71794. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  71795. /**
  71796. * Get the world position of a point that is in the local space of the bone
  71797. * @param position The local position
  71798. * @param mesh The mesh that this bone is attached to
  71799. * @returns The world position
  71800. */
  71801. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71802. /**
  71803. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  71804. * @param position The local position
  71805. * @param mesh The mesh that this bone is attached to
  71806. * @param result The vector3 that the world position should be copied to
  71807. */
  71808. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71809. /**
  71810. * Get the local position of a point that is in world space
  71811. * @param position The world position
  71812. * @param mesh The mesh that this bone is attached to
  71813. * @returns The local position
  71814. */
  71815. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71816. /**
  71817. * Get the local position of a point that is in world space and copy it to the result param
  71818. * @param position The world position
  71819. * @param mesh The mesh that this bone is attached to
  71820. * @param result The vector3 that the local position should be copied to
  71821. */
  71822. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71823. }
  71824. }
  71825. declare module BABYLON {
  71826. interface Engine {
  71827. /**
  71828. * Creates a raw texture
  71829. * @param data defines the data to store in the texture
  71830. * @param width defines the width of the texture
  71831. * @param height defines the height of the texture
  71832. * @param format defines the format of the data
  71833. * @param generateMipMaps defines if the engine should generate the mip levels
  71834. * @param invertY defines if data must be stored with Y axis inverted
  71835. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71836. * @param compression defines the compression used (null by default)
  71837. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71838. * @returns the raw texture inside an InternalTexture
  71839. */
  71840. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  71841. /**
  71842. * Update a raw texture
  71843. * @param texture defines the texture to update
  71844. * @param data defines the data to store in the texture
  71845. * @param format defines the format of the data
  71846. * @param invertY defines if data must be stored with Y axis inverted
  71847. */
  71848. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71849. /**
  71850. * Update a raw texture
  71851. * @param texture defines the texture to update
  71852. * @param data defines the data to store in the texture
  71853. * @param format defines the format of the data
  71854. * @param invertY defines if data must be stored with Y axis inverted
  71855. * @param compression defines the compression used (null by default)
  71856. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71857. */
  71858. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  71859. /**
  71860. * Creates a new raw cube texture
  71861. * @param data defines the array of data to use to create each face
  71862. * @param size defines the size of the textures
  71863. * @param format defines the format of the data
  71864. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71865. * @param generateMipMaps defines if the engine should generate the mip levels
  71866. * @param invertY defines if data must be stored with Y axis inverted
  71867. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71868. * @param compression defines the compression used (null by default)
  71869. * @returns the cube texture as an InternalTexture
  71870. */
  71871. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  71872. /**
  71873. * Update a raw cube texture
  71874. * @param texture defines the texture to udpdate
  71875. * @param data defines the data to store
  71876. * @param format defines the data format
  71877. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71878. * @param invertY defines if data must be stored with Y axis inverted
  71879. */
  71880. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  71881. /**
  71882. * Update a raw cube texture
  71883. * @param texture defines the texture to udpdate
  71884. * @param data defines the data to store
  71885. * @param format defines the data format
  71886. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71887. * @param invertY defines if data must be stored with Y axis inverted
  71888. * @param compression defines the compression used (null by default)
  71889. */
  71890. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  71891. /**
  71892. * Update a raw cube texture
  71893. * @param texture defines the texture to udpdate
  71894. * @param data defines the data to store
  71895. * @param format defines the data format
  71896. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71897. * @param invertY defines if data must be stored with Y axis inverted
  71898. * @param compression defines the compression used (null by default)
  71899. * @param level defines which level of the texture to update
  71900. */
  71901. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  71902. /**
  71903. * Creates a new raw cube texture from a specified url
  71904. * @param url defines the url where the data is located
  71905. * @param scene defines the current scene
  71906. * @param size defines the size of the textures
  71907. * @param format defines the format of the data
  71908. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71909. * @param noMipmap defines if the engine should avoid generating the mip levels
  71910. * @param callback defines a callback used to extract texture data from loaded data
  71911. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71912. * @param onLoad defines a callback called when texture is loaded
  71913. * @param onError defines a callback called if there is an error
  71914. * @returns the cube texture as an InternalTexture
  71915. */
  71916. 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;
  71917. /**
  71918. * Creates a new raw cube texture from a specified url
  71919. * @param url defines the url where the data is located
  71920. * @param scene defines the current scene
  71921. * @param size defines the size of the textures
  71922. * @param format defines the format of the data
  71923. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71924. * @param noMipmap defines if the engine should avoid generating the mip levels
  71925. * @param callback defines a callback used to extract texture data from loaded data
  71926. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71927. * @param onLoad defines a callback called when texture is loaded
  71928. * @param onError defines a callback called if there is an error
  71929. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71930. * @param invertY defines if data must be stored with Y axis inverted
  71931. * @returns the cube texture as an InternalTexture
  71932. */
  71933. 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;
  71934. /**
  71935. * Creates a new raw 3D texture
  71936. * @param data defines the data used to create the texture
  71937. * @param width defines the width of the texture
  71938. * @param height defines the height of the texture
  71939. * @param depth defines the depth of the texture
  71940. * @param format defines the format of the texture
  71941. * @param generateMipMaps defines if the engine must generate mip levels
  71942. * @param invertY defines if data must be stored with Y axis inverted
  71943. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71944. * @param compression defines the compressed used (can be null)
  71945. * @param textureType defines the compressed used (can be null)
  71946. * @returns a new raw 3D texture (stored in an InternalTexture)
  71947. */
  71948. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  71949. /**
  71950. * Update a raw 3D texture
  71951. * @param texture defines the texture to update
  71952. * @param data defines the data to store
  71953. * @param format defines the data format
  71954. * @param invertY defines if data must be stored with Y axis inverted
  71955. */
  71956. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71957. /**
  71958. * Update a raw 3D texture
  71959. * @param texture defines the texture to update
  71960. * @param data defines the data to store
  71961. * @param format defines the data format
  71962. * @param invertY defines if data must be stored with Y axis inverted
  71963. * @param compression defines the used compression (can be null)
  71964. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  71965. */
  71966. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  71967. }
  71968. }
  71969. declare module BABYLON {
  71970. /**
  71971. * Raw texture can help creating a texture directly from an array of data.
  71972. * This can be super useful if you either get the data from an uncompressed source or
  71973. * if you wish to create your texture pixel by pixel.
  71974. */
  71975. export class RawTexture extends Texture {
  71976. /**
  71977. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71978. */
  71979. format: number;
  71980. private _engine;
  71981. /**
  71982. * Instantiates a new RawTexture.
  71983. * Raw texture can help creating a texture directly from an array of data.
  71984. * This can be super useful if you either get the data from an uncompressed source or
  71985. * if you wish to create your texture pixel by pixel.
  71986. * @param data define the array of data to use to create the texture
  71987. * @param width define the width of the texture
  71988. * @param height define the height of the texture
  71989. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71990. * @param scene define the scene the texture belongs to
  71991. * @param generateMipMaps define whether mip maps should be generated or not
  71992. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  71993. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  71994. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  71995. */
  71996. constructor(data: ArrayBufferView, width: number, height: number,
  71997. /**
  71998. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71999. */
  72000. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72001. /**
  72002. * Updates the texture underlying data.
  72003. * @param data Define the new data of the texture
  72004. */
  72005. update(data: ArrayBufferView): void;
  72006. /**
  72007. * Creates a luminance texture from some data.
  72008. * @param data Define the texture data
  72009. * @param width Define the width of the texture
  72010. * @param height Define the height of the texture
  72011. * @param scene Define the scene the texture belongs to
  72012. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72013. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72014. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72015. * @returns the luminance texture
  72016. */
  72017. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72018. /**
  72019. * Creates a luminance alpha texture from some data.
  72020. * @param data Define the texture data
  72021. * @param width Define the width of the texture
  72022. * @param height Define the height of the texture
  72023. * @param scene Define the scene the texture belongs to
  72024. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72025. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72026. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72027. * @returns the luminance alpha texture
  72028. */
  72029. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72030. /**
  72031. * Creates an alpha texture from some data.
  72032. * @param data Define the texture data
  72033. * @param width Define the width of the texture
  72034. * @param height Define the height of the texture
  72035. * @param scene Define the scene the texture belongs to
  72036. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72037. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72038. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72039. * @returns the alpha texture
  72040. */
  72041. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72042. /**
  72043. * Creates a RGB texture from some data.
  72044. * @param data Define the texture data
  72045. * @param width Define the width of the texture
  72046. * @param height Define the height of the texture
  72047. * @param scene Define the scene the texture belongs to
  72048. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72049. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72050. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72051. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72052. * @returns the RGB alpha texture
  72053. */
  72054. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72055. /**
  72056. * Creates a RGBA texture from some data.
  72057. * @param data Define the texture data
  72058. * @param width Define the width of the texture
  72059. * @param height Define the height of the texture
  72060. * @param scene Define the scene the texture belongs to
  72061. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72062. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72063. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72064. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72065. * @returns the RGBA texture
  72066. */
  72067. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72068. /**
  72069. * Creates a R texture from some data.
  72070. * @param data Define the texture data
  72071. * @param width Define the width of the texture
  72072. * @param height Define the height of the texture
  72073. * @param scene Define the scene the texture belongs to
  72074. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72075. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72076. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72077. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72078. * @returns the R texture
  72079. */
  72080. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72081. }
  72082. }
  72083. declare module BABYLON {
  72084. /**
  72085. * Defines a runtime animation
  72086. */
  72087. export class RuntimeAnimation {
  72088. private _events;
  72089. /**
  72090. * The current frame of the runtime animation
  72091. */
  72092. private _currentFrame;
  72093. /**
  72094. * The animation used by the runtime animation
  72095. */
  72096. private _animation;
  72097. /**
  72098. * The target of the runtime animation
  72099. */
  72100. private _target;
  72101. /**
  72102. * The initiating animatable
  72103. */
  72104. private _host;
  72105. /**
  72106. * The original value of the runtime animation
  72107. */
  72108. private _originalValue;
  72109. /**
  72110. * The original blend value of the runtime animation
  72111. */
  72112. private _originalBlendValue;
  72113. /**
  72114. * The offsets cache of the runtime animation
  72115. */
  72116. private _offsetsCache;
  72117. /**
  72118. * The high limits cache of the runtime animation
  72119. */
  72120. private _highLimitsCache;
  72121. /**
  72122. * Specifies if the runtime animation has been stopped
  72123. */
  72124. private _stopped;
  72125. /**
  72126. * The blending factor of the runtime animation
  72127. */
  72128. private _blendingFactor;
  72129. /**
  72130. * The BabylonJS scene
  72131. */
  72132. private _scene;
  72133. /**
  72134. * The current value of the runtime animation
  72135. */
  72136. private _currentValue;
  72137. /** @hidden */
  72138. _animationState: _IAnimationState;
  72139. /**
  72140. * The active target of the runtime animation
  72141. */
  72142. private _activeTargets;
  72143. private _currentActiveTarget;
  72144. private _directTarget;
  72145. /**
  72146. * The target path of the runtime animation
  72147. */
  72148. private _targetPath;
  72149. /**
  72150. * The weight of the runtime animation
  72151. */
  72152. private _weight;
  72153. /**
  72154. * The ratio offset of the runtime animation
  72155. */
  72156. private _ratioOffset;
  72157. /**
  72158. * The previous delay of the runtime animation
  72159. */
  72160. private _previousDelay;
  72161. /**
  72162. * The previous ratio of the runtime animation
  72163. */
  72164. private _previousRatio;
  72165. private _enableBlending;
  72166. private _keys;
  72167. private _minFrame;
  72168. private _maxFrame;
  72169. private _minValue;
  72170. private _maxValue;
  72171. private _targetIsArray;
  72172. /**
  72173. * Gets the current frame of the runtime animation
  72174. */
  72175. readonly currentFrame: number;
  72176. /**
  72177. * Gets the weight of the runtime animation
  72178. */
  72179. readonly weight: number;
  72180. /**
  72181. * Gets the current value of the runtime animation
  72182. */
  72183. readonly currentValue: any;
  72184. /**
  72185. * Gets the target path of the runtime animation
  72186. */
  72187. readonly targetPath: string;
  72188. /**
  72189. * Gets the actual target of the runtime animation
  72190. */
  72191. readonly target: any;
  72192. /** @hidden */
  72193. _onLoop: () => void;
  72194. /**
  72195. * Create a new RuntimeAnimation object
  72196. * @param target defines the target of the animation
  72197. * @param animation defines the source animation object
  72198. * @param scene defines the hosting scene
  72199. * @param host defines the initiating Animatable
  72200. */
  72201. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72202. private _preparePath;
  72203. /**
  72204. * Gets the animation from the runtime animation
  72205. */
  72206. readonly animation: Animation;
  72207. /**
  72208. * Resets the runtime animation to the beginning
  72209. * @param restoreOriginal defines whether to restore the target property to the original value
  72210. */
  72211. reset(restoreOriginal?: boolean): void;
  72212. /**
  72213. * Specifies if the runtime animation is stopped
  72214. * @returns Boolean specifying if the runtime animation is stopped
  72215. */
  72216. isStopped(): boolean;
  72217. /**
  72218. * Disposes of the runtime animation
  72219. */
  72220. dispose(): void;
  72221. /**
  72222. * Apply the interpolated value to the target
  72223. * @param currentValue defines the value computed by the animation
  72224. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72225. */
  72226. setValue(currentValue: any, weight: number): void;
  72227. private _getOriginalValues;
  72228. private _setValue;
  72229. /**
  72230. * Gets the loop pmode of the runtime animation
  72231. * @returns Loop Mode
  72232. */
  72233. private _getCorrectLoopMode;
  72234. /**
  72235. * Move the current animation to a given frame
  72236. * @param frame defines the frame to move to
  72237. */
  72238. goToFrame(frame: number): void;
  72239. /**
  72240. * @hidden Internal use only
  72241. */
  72242. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72243. /**
  72244. * Execute the current animation
  72245. * @param delay defines the delay to add to the current frame
  72246. * @param from defines the lower bound of the animation range
  72247. * @param to defines the upper bound of the animation range
  72248. * @param loop defines if the current animation must loop
  72249. * @param speedRatio defines the current speed ratio
  72250. * @param weight defines the weight of the animation (default is -1 so no weight)
  72251. * @param onLoop optional callback called when animation loops
  72252. * @returns a boolean indicating if the animation is running
  72253. */
  72254. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72255. }
  72256. }
  72257. declare module BABYLON {
  72258. /**
  72259. * Class used to store an actual running animation
  72260. */
  72261. export class Animatable {
  72262. /** defines the target object */
  72263. target: any;
  72264. /** defines the starting frame number (default is 0) */
  72265. fromFrame: number;
  72266. /** defines the ending frame number (default is 100) */
  72267. toFrame: number;
  72268. /** defines if the animation must loop (default is false) */
  72269. loopAnimation: boolean;
  72270. /** defines a callback to call when animation ends if it is not looping */
  72271. onAnimationEnd?: (() => void) | null | undefined;
  72272. /** defines a callback to call when animation loops */
  72273. onAnimationLoop?: (() => void) | null | undefined;
  72274. private _localDelayOffset;
  72275. private _pausedDelay;
  72276. private _runtimeAnimations;
  72277. private _paused;
  72278. private _scene;
  72279. private _speedRatio;
  72280. private _weight;
  72281. private _syncRoot;
  72282. /**
  72283. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72284. * This will only apply for non looping animation (default is true)
  72285. */
  72286. disposeOnEnd: boolean;
  72287. /**
  72288. * Gets a boolean indicating if the animation has started
  72289. */
  72290. animationStarted: boolean;
  72291. /**
  72292. * Observer raised when the animation ends
  72293. */
  72294. onAnimationEndObservable: Observable<Animatable>;
  72295. /**
  72296. * Observer raised when the animation loops
  72297. */
  72298. onAnimationLoopObservable: Observable<Animatable>;
  72299. /**
  72300. * Gets the root Animatable used to synchronize and normalize animations
  72301. */
  72302. readonly syncRoot: Nullable<Animatable>;
  72303. /**
  72304. * Gets the current frame of the first RuntimeAnimation
  72305. * Used to synchronize Animatables
  72306. */
  72307. readonly masterFrame: number;
  72308. /**
  72309. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72310. */
  72311. weight: number;
  72312. /**
  72313. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72314. */
  72315. speedRatio: number;
  72316. /**
  72317. * Creates a new Animatable
  72318. * @param scene defines the hosting scene
  72319. * @param target defines the target object
  72320. * @param fromFrame defines the starting frame number (default is 0)
  72321. * @param toFrame defines the ending frame number (default is 100)
  72322. * @param loopAnimation defines if the animation must loop (default is false)
  72323. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72324. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72325. * @param animations defines a group of animation to add to the new Animatable
  72326. * @param onAnimationLoop defines a callback to call when animation loops
  72327. */
  72328. constructor(scene: Scene,
  72329. /** defines the target object */
  72330. target: any,
  72331. /** defines the starting frame number (default is 0) */
  72332. fromFrame?: number,
  72333. /** defines the ending frame number (default is 100) */
  72334. toFrame?: number,
  72335. /** defines if the animation must loop (default is false) */
  72336. loopAnimation?: boolean, speedRatio?: number,
  72337. /** defines a callback to call when animation ends if it is not looping */
  72338. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72339. /** defines a callback to call when animation loops */
  72340. onAnimationLoop?: (() => void) | null | undefined);
  72341. /**
  72342. * Synchronize and normalize current Animatable with a source Animatable
  72343. * This is useful when using animation weights and when animations are not of the same length
  72344. * @param root defines the root Animatable to synchronize with
  72345. * @returns the current Animatable
  72346. */
  72347. syncWith(root: Animatable): Animatable;
  72348. /**
  72349. * Gets the list of runtime animations
  72350. * @returns an array of RuntimeAnimation
  72351. */
  72352. getAnimations(): RuntimeAnimation[];
  72353. /**
  72354. * Adds more animations to the current animatable
  72355. * @param target defines the target of the animations
  72356. * @param animations defines the new animations to add
  72357. */
  72358. appendAnimations(target: any, animations: Animation[]): void;
  72359. /**
  72360. * Gets the source animation for a specific property
  72361. * @param property defines the propertyu to look for
  72362. * @returns null or the source animation for the given property
  72363. */
  72364. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72365. /**
  72366. * Gets the runtime animation for a specific property
  72367. * @param property defines the propertyu to look for
  72368. * @returns null or the runtime animation for the given property
  72369. */
  72370. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72371. /**
  72372. * Resets the animatable to its original state
  72373. */
  72374. reset(): void;
  72375. /**
  72376. * Allows the animatable to blend with current running animations
  72377. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72378. * @param blendingSpeed defines the blending speed to use
  72379. */
  72380. enableBlending(blendingSpeed: number): void;
  72381. /**
  72382. * Disable animation blending
  72383. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72384. */
  72385. disableBlending(): void;
  72386. /**
  72387. * Jump directly to a given frame
  72388. * @param frame defines the frame to jump to
  72389. */
  72390. goToFrame(frame: number): void;
  72391. /**
  72392. * Pause the animation
  72393. */
  72394. pause(): void;
  72395. /**
  72396. * Restart the animation
  72397. */
  72398. restart(): void;
  72399. private _raiseOnAnimationEnd;
  72400. /**
  72401. * Stop and delete the current animation
  72402. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72403. * @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)
  72404. */
  72405. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72406. /**
  72407. * Wait asynchronously for the animation to end
  72408. * @returns a promise which will be fullfilled when the animation ends
  72409. */
  72410. waitAsync(): Promise<Animatable>;
  72411. /** @hidden */
  72412. _animate(delay: number): boolean;
  72413. }
  72414. interface Scene {
  72415. /** @hidden */
  72416. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72417. /** @hidden */
  72418. _processLateAnimationBindingsForMatrices(holder: {
  72419. totalWeight: number;
  72420. animations: RuntimeAnimation[];
  72421. originalValue: Matrix;
  72422. }): any;
  72423. /** @hidden */
  72424. _processLateAnimationBindingsForQuaternions(holder: {
  72425. totalWeight: number;
  72426. animations: RuntimeAnimation[];
  72427. originalValue: Quaternion;
  72428. }, refQuaternion: Quaternion): Quaternion;
  72429. /** @hidden */
  72430. _processLateAnimationBindings(): void;
  72431. /**
  72432. * Will start the animation sequence of a given target
  72433. * @param target defines the target
  72434. * @param from defines from which frame should animation start
  72435. * @param to defines until which frame should animation run.
  72436. * @param weight defines the weight to apply to the animation (1.0 by default)
  72437. * @param loop defines if the animation loops
  72438. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72439. * @param onAnimationEnd defines the function to be executed when the animation ends
  72440. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72441. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72442. * @param onAnimationLoop defines the callback to call when an animation loops
  72443. * @returns the animatable object created for this animation
  72444. */
  72445. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72446. /**
  72447. * Will start the animation sequence of a given target
  72448. * @param target defines the target
  72449. * @param from defines from which frame should animation start
  72450. * @param to defines until which frame should animation run.
  72451. * @param loop defines if the animation loops
  72452. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72453. * @param onAnimationEnd defines the function to be executed when the animation ends
  72454. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72455. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72456. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72457. * @param onAnimationLoop defines the callback to call when an animation loops
  72458. * @returns the animatable object created for this animation
  72459. */
  72460. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72461. /**
  72462. * Will start the animation sequence of a given target and its hierarchy
  72463. * @param target defines the target
  72464. * @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.
  72465. * @param from defines from which frame should animation start
  72466. * @param to defines until which frame should animation run.
  72467. * @param loop defines if the animation loops
  72468. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72469. * @param onAnimationEnd defines the function to be executed when the animation ends
  72470. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72471. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72472. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72473. * @param onAnimationLoop defines the callback to call when an animation loops
  72474. * @returns the list of created animatables
  72475. */
  72476. 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[];
  72477. /**
  72478. * Begin a new animation on a given node
  72479. * @param target defines the target where the animation will take place
  72480. * @param animations defines the list of animations to start
  72481. * @param from defines the initial value
  72482. * @param to defines the final value
  72483. * @param loop defines if you want animation to loop (off by default)
  72484. * @param speedRatio defines the speed ratio to apply to all animations
  72485. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72486. * @param onAnimationLoop defines the callback to call when an animation loops
  72487. * @returns the list of created animatables
  72488. */
  72489. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72490. /**
  72491. * Begin a new animation on a given node and its hierarchy
  72492. * @param target defines the root node where the animation will take place
  72493. * @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.
  72494. * @param animations defines the list of animations to start
  72495. * @param from defines the initial value
  72496. * @param to defines the final value
  72497. * @param loop defines if you want animation to loop (off by default)
  72498. * @param speedRatio defines the speed ratio to apply to all animations
  72499. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72500. * @param onAnimationLoop defines the callback to call when an animation loops
  72501. * @returns the list of animatables created for all nodes
  72502. */
  72503. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72504. /**
  72505. * Gets the animatable associated with a specific target
  72506. * @param target defines the target of the animatable
  72507. * @returns the required animatable if found
  72508. */
  72509. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72510. /**
  72511. * Gets all animatables associated with a given target
  72512. * @param target defines the target to look animatables for
  72513. * @returns an array of Animatables
  72514. */
  72515. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72516. /**
  72517. * Stops and removes all animations that have been applied to the scene
  72518. */
  72519. stopAllAnimations(): void;
  72520. }
  72521. interface Bone {
  72522. /**
  72523. * Copy an animation range from another bone
  72524. * @param source defines the source bone
  72525. * @param rangeName defines the range name to copy
  72526. * @param frameOffset defines the frame offset
  72527. * @param rescaleAsRequired defines if rescaling must be applied if required
  72528. * @param skelDimensionsRatio defines the scaling ratio
  72529. * @returns true if operation was successful
  72530. */
  72531. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72532. }
  72533. }
  72534. declare module BABYLON {
  72535. /**
  72536. * Class used to handle skinning animations
  72537. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72538. */
  72539. export class Skeleton implements IAnimatable {
  72540. /** defines the skeleton name */
  72541. name: string;
  72542. /** defines the skeleton Id */
  72543. id: string;
  72544. /**
  72545. * Defines the list of child bones
  72546. */
  72547. bones: Bone[];
  72548. /**
  72549. * Defines an estimate of the dimension of the skeleton at rest
  72550. */
  72551. dimensionsAtRest: Vector3;
  72552. /**
  72553. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72554. */
  72555. needInitialSkinMatrix: boolean;
  72556. /**
  72557. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72558. */
  72559. overrideMesh: Nullable<AbstractMesh>;
  72560. /**
  72561. * Gets the list of animations attached to this skeleton
  72562. */
  72563. animations: Array<Animation>;
  72564. private _scene;
  72565. private _isDirty;
  72566. private _transformMatrices;
  72567. private _transformMatrixTexture;
  72568. private _meshesWithPoseMatrix;
  72569. private _animatables;
  72570. private _identity;
  72571. private _synchronizedWithMesh;
  72572. private _ranges;
  72573. private _lastAbsoluteTransformsUpdateId;
  72574. private _canUseTextureForBones;
  72575. private _uniqueId;
  72576. /** @hidden */
  72577. _numBonesWithLinkedTransformNode: number;
  72578. /** @hidden */
  72579. _hasWaitingData: Nullable<boolean>;
  72580. /**
  72581. * Specifies if the skeleton should be serialized
  72582. */
  72583. doNotSerialize: boolean;
  72584. private _useTextureToStoreBoneMatrices;
  72585. /**
  72586. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72587. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  72588. */
  72589. useTextureToStoreBoneMatrices: boolean;
  72590. private _animationPropertiesOverride;
  72591. /**
  72592. * Gets or sets the animation properties override
  72593. */
  72594. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72595. /**
  72596. * List of inspectable custom properties (used by the Inspector)
  72597. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72598. */
  72599. inspectableCustomProperties: IInspectable[];
  72600. /**
  72601. * An observable triggered before computing the skeleton's matrices
  72602. */
  72603. onBeforeComputeObservable: Observable<Skeleton>;
  72604. /**
  72605. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72606. */
  72607. readonly isUsingTextureForMatrices: boolean;
  72608. /**
  72609. * Gets the unique ID of this skeleton
  72610. */
  72611. readonly uniqueId: number;
  72612. /**
  72613. * Creates a new skeleton
  72614. * @param name defines the skeleton name
  72615. * @param id defines the skeleton Id
  72616. * @param scene defines the hosting scene
  72617. */
  72618. constructor(
  72619. /** defines the skeleton name */
  72620. name: string,
  72621. /** defines the skeleton Id */
  72622. id: string, scene: Scene);
  72623. /**
  72624. * Gets the current object class name.
  72625. * @return the class name
  72626. */
  72627. getClassName(): string;
  72628. /**
  72629. * Returns an array containing the root bones
  72630. * @returns an array containing the root bones
  72631. */
  72632. getChildren(): Array<Bone>;
  72633. /**
  72634. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72635. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72636. * @returns a Float32Array containing matrices data
  72637. */
  72638. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72639. /**
  72640. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72641. * @returns a raw texture containing the data
  72642. */
  72643. getTransformMatrixTexture(): Nullable<RawTexture>;
  72644. /**
  72645. * Gets the current hosting scene
  72646. * @returns a scene object
  72647. */
  72648. getScene(): Scene;
  72649. /**
  72650. * Gets a string representing the current skeleton data
  72651. * @param fullDetails defines a boolean indicating if we want a verbose version
  72652. * @returns a string representing the current skeleton data
  72653. */
  72654. toString(fullDetails?: boolean): string;
  72655. /**
  72656. * Get bone's index searching by name
  72657. * @param name defines bone's name to search for
  72658. * @return the indice of the bone. Returns -1 if not found
  72659. */
  72660. getBoneIndexByName(name: string): number;
  72661. /**
  72662. * Creater a new animation range
  72663. * @param name defines the name of the range
  72664. * @param from defines the start key
  72665. * @param to defines the end key
  72666. */
  72667. createAnimationRange(name: string, from: number, to: number): void;
  72668. /**
  72669. * Delete a specific animation range
  72670. * @param name defines the name of the range
  72671. * @param deleteFrames defines if frames must be removed as well
  72672. */
  72673. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  72674. /**
  72675. * Gets a specific animation range
  72676. * @param name defines the name of the range to look for
  72677. * @returns the requested animation range or null if not found
  72678. */
  72679. getAnimationRange(name: string): Nullable<AnimationRange>;
  72680. /**
  72681. * Gets the list of all animation ranges defined on this skeleton
  72682. * @returns an array
  72683. */
  72684. getAnimationRanges(): Nullable<AnimationRange>[];
  72685. /**
  72686. * Copy animation range from a source skeleton.
  72687. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  72688. * @param source defines the source skeleton
  72689. * @param name defines the name of the range to copy
  72690. * @param rescaleAsRequired defines if rescaling must be applied if required
  72691. * @returns true if operation was successful
  72692. */
  72693. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  72694. /**
  72695. * Forces the skeleton to go to rest pose
  72696. */
  72697. returnToRest(): void;
  72698. private _getHighestAnimationFrame;
  72699. /**
  72700. * Begin a specific animation range
  72701. * @param name defines the name of the range to start
  72702. * @param loop defines if looping must be turned on (false by default)
  72703. * @param speedRatio defines the speed ratio to apply (1 by default)
  72704. * @param onAnimationEnd defines a callback which will be called when animation will end
  72705. * @returns a new animatable
  72706. */
  72707. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  72708. /** @hidden */
  72709. _markAsDirty(): void;
  72710. /** @hidden */
  72711. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72712. /** @hidden */
  72713. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72714. private _computeTransformMatrices;
  72715. /**
  72716. * Build all resources required to render a skeleton
  72717. */
  72718. prepare(): void;
  72719. /**
  72720. * Gets the list of animatables currently running for this skeleton
  72721. * @returns an array of animatables
  72722. */
  72723. getAnimatables(): IAnimatable[];
  72724. /**
  72725. * Clone the current skeleton
  72726. * @param name defines the name of the new skeleton
  72727. * @param id defines the id of the new skeleton
  72728. * @returns the new skeleton
  72729. */
  72730. clone(name: string, id: string): Skeleton;
  72731. /**
  72732. * Enable animation blending for this skeleton
  72733. * @param blendingSpeed defines the blending speed to apply
  72734. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72735. */
  72736. enableBlending(blendingSpeed?: number): void;
  72737. /**
  72738. * Releases all resources associated with the current skeleton
  72739. */
  72740. dispose(): void;
  72741. /**
  72742. * Serialize the skeleton in a JSON object
  72743. * @returns a JSON object
  72744. */
  72745. serialize(): any;
  72746. /**
  72747. * Creates a new skeleton from serialized data
  72748. * @param parsedSkeleton defines the serialized data
  72749. * @param scene defines the hosting scene
  72750. * @returns a new skeleton
  72751. */
  72752. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  72753. /**
  72754. * Compute all node absolute transforms
  72755. * @param forceUpdate defines if computation must be done even if cache is up to date
  72756. */
  72757. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  72758. /**
  72759. * Gets the root pose matrix
  72760. * @returns a matrix
  72761. */
  72762. getPoseMatrix(): Nullable<Matrix>;
  72763. /**
  72764. * Sorts bones per internal index
  72765. */
  72766. sortBones(): void;
  72767. private _sortBones;
  72768. }
  72769. }
  72770. declare module BABYLON {
  72771. /**
  72772. * Defines a target to use with MorphTargetManager
  72773. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72774. */
  72775. export class MorphTarget implements IAnimatable {
  72776. /** defines the name of the target */
  72777. name: string;
  72778. /**
  72779. * Gets or sets the list of animations
  72780. */
  72781. animations: Animation[];
  72782. private _scene;
  72783. private _positions;
  72784. private _normals;
  72785. private _tangents;
  72786. private _influence;
  72787. /**
  72788. * Observable raised when the influence changes
  72789. */
  72790. onInfluenceChanged: Observable<boolean>;
  72791. /** @hidden */
  72792. _onDataLayoutChanged: Observable<void>;
  72793. /**
  72794. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  72795. */
  72796. influence: number;
  72797. /**
  72798. * Gets or sets the id of the morph Target
  72799. */
  72800. id: string;
  72801. private _animationPropertiesOverride;
  72802. /**
  72803. * Gets or sets the animation properties override
  72804. */
  72805. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72806. /**
  72807. * Creates a new MorphTarget
  72808. * @param name defines the name of the target
  72809. * @param influence defines the influence to use
  72810. * @param scene defines the scene the morphtarget belongs to
  72811. */
  72812. constructor(
  72813. /** defines the name of the target */
  72814. name: string, influence?: number, scene?: Nullable<Scene>);
  72815. /**
  72816. * Gets a boolean defining if the target contains position data
  72817. */
  72818. readonly hasPositions: boolean;
  72819. /**
  72820. * Gets a boolean defining if the target contains normal data
  72821. */
  72822. readonly hasNormals: boolean;
  72823. /**
  72824. * Gets a boolean defining if the target contains tangent data
  72825. */
  72826. readonly hasTangents: boolean;
  72827. /**
  72828. * Affects position data to this target
  72829. * @param data defines the position data to use
  72830. */
  72831. setPositions(data: Nullable<FloatArray>): void;
  72832. /**
  72833. * Gets the position data stored in this target
  72834. * @returns a FloatArray containing the position data (or null if not present)
  72835. */
  72836. getPositions(): Nullable<FloatArray>;
  72837. /**
  72838. * Affects normal data to this target
  72839. * @param data defines the normal data to use
  72840. */
  72841. setNormals(data: Nullable<FloatArray>): void;
  72842. /**
  72843. * Gets the normal data stored in this target
  72844. * @returns a FloatArray containing the normal data (or null if not present)
  72845. */
  72846. getNormals(): Nullable<FloatArray>;
  72847. /**
  72848. * Affects tangent data to this target
  72849. * @param data defines the tangent data to use
  72850. */
  72851. setTangents(data: Nullable<FloatArray>): void;
  72852. /**
  72853. * Gets the tangent data stored in this target
  72854. * @returns a FloatArray containing the tangent data (or null if not present)
  72855. */
  72856. getTangents(): Nullable<FloatArray>;
  72857. /**
  72858. * Serializes the current target into a Serialization object
  72859. * @returns the serialized object
  72860. */
  72861. serialize(): any;
  72862. /**
  72863. * Returns the string "MorphTarget"
  72864. * @returns "MorphTarget"
  72865. */
  72866. getClassName(): string;
  72867. /**
  72868. * Creates a new target from serialized data
  72869. * @param serializationObject defines the serialized data to use
  72870. * @returns a new MorphTarget
  72871. */
  72872. static Parse(serializationObject: any): MorphTarget;
  72873. /**
  72874. * Creates a MorphTarget from mesh data
  72875. * @param mesh defines the source mesh
  72876. * @param name defines the name to use for the new target
  72877. * @param influence defines the influence to attach to the target
  72878. * @returns a new MorphTarget
  72879. */
  72880. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  72881. }
  72882. }
  72883. declare module BABYLON {
  72884. /**
  72885. * This class is used to deform meshes using morphing between different targets
  72886. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72887. */
  72888. export class MorphTargetManager {
  72889. private _targets;
  72890. private _targetInfluenceChangedObservers;
  72891. private _targetDataLayoutChangedObservers;
  72892. private _activeTargets;
  72893. private _scene;
  72894. private _influences;
  72895. private _supportsNormals;
  72896. private _supportsTangents;
  72897. private _vertexCount;
  72898. private _uniqueId;
  72899. private _tempInfluences;
  72900. /**
  72901. * Creates a new MorphTargetManager
  72902. * @param scene defines the current scene
  72903. */
  72904. constructor(scene?: Nullable<Scene>);
  72905. /**
  72906. * Gets the unique ID of this manager
  72907. */
  72908. readonly uniqueId: number;
  72909. /**
  72910. * Gets the number of vertices handled by this manager
  72911. */
  72912. readonly vertexCount: number;
  72913. /**
  72914. * Gets a boolean indicating if this manager supports morphing of normals
  72915. */
  72916. readonly supportsNormals: boolean;
  72917. /**
  72918. * Gets a boolean indicating if this manager supports morphing of tangents
  72919. */
  72920. readonly supportsTangents: boolean;
  72921. /**
  72922. * Gets the number of targets stored in this manager
  72923. */
  72924. readonly numTargets: number;
  72925. /**
  72926. * Gets the number of influencers (ie. the number of targets with influences > 0)
  72927. */
  72928. readonly numInfluencers: number;
  72929. /**
  72930. * Gets the list of influences (one per target)
  72931. */
  72932. readonly influences: Float32Array;
  72933. /**
  72934. * Gets the active target at specified index. An active target is a target with an influence > 0
  72935. * @param index defines the index to check
  72936. * @returns the requested target
  72937. */
  72938. getActiveTarget(index: number): MorphTarget;
  72939. /**
  72940. * Gets the target at specified index
  72941. * @param index defines the index to check
  72942. * @returns the requested target
  72943. */
  72944. getTarget(index: number): MorphTarget;
  72945. /**
  72946. * Add a new target to this manager
  72947. * @param target defines the target to add
  72948. */
  72949. addTarget(target: MorphTarget): void;
  72950. /**
  72951. * Removes a target from the manager
  72952. * @param target defines the target to remove
  72953. */
  72954. removeTarget(target: MorphTarget): void;
  72955. /**
  72956. * Serializes the current manager into a Serialization object
  72957. * @returns the serialized object
  72958. */
  72959. serialize(): any;
  72960. private _syncActiveTargets;
  72961. /**
  72962. * Syncrhonize the targets with all the meshes using this morph target manager
  72963. */
  72964. synchronize(): void;
  72965. /**
  72966. * Creates a new MorphTargetManager from serialized data
  72967. * @param serializationObject defines the serialized data
  72968. * @param scene defines the hosting scene
  72969. * @returns the new MorphTargetManager
  72970. */
  72971. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  72972. }
  72973. }
  72974. declare module BABYLON {
  72975. /**
  72976. * Groups all the scene component constants in one place to ease maintenance.
  72977. * @hidden
  72978. */
  72979. export class SceneComponentConstants {
  72980. static readonly NAME_EFFECTLAYER: string;
  72981. static readonly NAME_LAYER: string;
  72982. static readonly NAME_LENSFLARESYSTEM: string;
  72983. static readonly NAME_BOUNDINGBOXRENDERER: string;
  72984. static readonly NAME_PARTICLESYSTEM: string;
  72985. static readonly NAME_GAMEPAD: string;
  72986. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  72987. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  72988. static readonly NAME_DEPTHRENDERER: string;
  72989. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  72990. static readonly NAME_SPRITE: string;
  72991. static readonly NAME_OUTLINERENDERER: string;
  72992. static readonly NAME_PROCEDURALTEXTURE: string;
  72993. static readonly NAME_SHADOWGENERATOR: string;
  72994. static readonly NAME_OCTREE: string;
  72995. static readonly NAME_PHYSICSENGINE: string;
  72996. static readonly NAME_AUDIO: string;
  72997. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  72998. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  72999. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73000. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73001. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73002. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73003. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73004. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73005. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73006. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73007. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73008. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73009. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73010. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73011. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73012. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73013. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73014. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73015. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73016. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73017. static readonly STEP_AFTERRENDER_AUDIO: number;
  73018. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73019. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73020. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73021. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73022. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73023. static readonly STEP_POINTERMOVE_SPRITE: number;
  73024. static readonly STEP_POINTERDOWN_SPRITE: number;
  73025. static readonly STEP_POINTERUP_SPRITE: number;
  73026. }
  73027. /**
  73028. * This represents a scene component.
  73029. *
  73030. * This is used to decouple the dependency the scene is having on the different workloads like
  73031. * layers, post processes...
  73032. */
  73033. export interface ISceneComponent {
  73034. /**
  73035. * The name of the component. Each component must have a unique name.
  73036. */
  73037. name: string;
  73038. /**
  73039. * The scene the component belongs to.
  73040. */
  73041. scene: Scene;
  73042. /**
  73043. * Register the component to one instance of a scene.
  73044. */
  73045. register(): void;
  73046. /**
  73047. * Rebuilds the elements related to this component in case of
  73048. * context lost for instance.
  73049. */
  73050. rebuild(): void;
  73051. /**
  73052. * Disposes the component and the associated ressources.
  73053. */
  73054. dispose(): void;
  73055. }
  73056. /**
  73057. * This represents a SERIALIZABLE scene component.
  73058. *
  73059. * This extends Scene Component to add Serialization methods on top.
  73060. */
  73061. export interface ISceneSerializableComponent extends ISceneComponent {
  73062. /**
  73063. * Adds all the elements from the container to the scene
  73064. * @param container the container holding the elements
  73065. */
  73066. addFromContainer(container: AbstractScene): void;
  73067. /**
  73068. * Removes all the elements in the container from the scene
  73069. * @param container contains the elements to remove
  73070. * @param dispose if the removed element should be disposed (default: false)
  73071. */
  73072. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73073. /**
  73074. * Serializes the component data to the specified json object
  73075. * @param serializationObject The object to serialize to
  73076. */
  73077. serialize(serializationObject: any): void;
  73078. }
  73079. /**
  73080. * Strong typing of a Mesh related stage step action
  73081. */
  73082. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73083. /**
  73084. * Strong typing of a Evaluate Sub Mesh related stage step action
  73085. */
  73086. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73087. /**
  73088. * Strong typing of a Active Mesh related stage step action
  73089. */
  73090. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73091. /**
  73092. * Strong typing of a Camera related stage step action
  73093. */
  73094. export type CameraStageAction = (camera: Camera) => void;
  73095. /**
  73096. * Strong typing of a Camera Frame buffer related stage step action
  73097. */
  73098. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73099. /**
  73100. * Strong typing of a Render Target related stage step action
  73101. */
  73102. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73103. /**
  73104. * Strong typing of a RenderingGroup related stage step action
  73105. */
  73106. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73107. /**
  73108. * Strong typing of a Mesh Render related stage step action
  73109. */
  73110. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73111. /**
  73112. * Strong typing of a simple stage step action
  73113. */
  73114. export type SimpleStageAction = () => void;
  73115. /**
  73116. * Strong typing of a render target action.
  73117. */
  73118. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73119. /**
  73120. * Strong typing of a pointer move action.
  73121. */
  73122. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73123. /**
  73124. * Strong typing of a pointer up/down action.
  73125. */
  73126. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73127. /**
  73128. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73129. * @hidden
  73130. */
  73131. export class Stage<T extends Function> extends Array<{
  73132. index: number;
  73133. component: ISceneComponent;
  73134. action: T;
  73135. }> {
  73136. /**
  73137. * Hide ctor from the rest of the world.
  73138. * @param items The items to add.
  73139. */
  73140. private constructor();
  73141. /**
  73142. * Creates a new Stage.
  73143. * @returns A new instance of a Stage
  73144. */
  73145. static Create<T extends Function>(): Stage<T>;
  73146. /**
  73147. * Registers a step in an ordered way in the targeted stage.
  73148. * @param index Defines the position to register the step in
  73149. * @param component Defines the component attached to the step
  73150. * @param action Defines the action to launch during the step
  73151. */
  73152. registerStep(index: number, component: ISceneComponent, action: T): void;
  73153. /**
  73154. * Clears all the steps from the stage.
  73155. */
  73156. clear(): void;
  73157. }
  73158. }
  73159. declare module BABYLON {
  73160. /**
  73161. * Class used to represent a specific level of detail of a mesh
  73162. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73163. */
  73164. export class MeshLODLevel {
  73165. /** Defines the distance where this level should star being displayed */
  73166. distance: number;
  73167. /** Defines the mesh to use to render this level */
  73168. mesh: Nullable<Mesh>;
  73169. /**
  73170. * Creates a new LOD level
  73171. * @param distance defines the distance where this level should star being displayed
  73172. * @param mesh defines the mesh to use to render this level
  73173. */
  73174. constructor(
  73175. /** Defines the distance where this level should star being displayed */
  73176. distance: number,
  73177. /** Defines the mesh to use to render this level */
  73178. mesh: Nullable<Mesh>);
  73179. }
  73180. }
  73181. declare module BABYLON {
  73182. /**
  73183. * Interface describing all the common properties and methods a shadow light needs to implement.
  73184. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73185. * as well as binding the different shadow properties to the effects.
  73186. */
  73187. export interface IShadowLight extends Light {
  73188. /**
  73189. * The light id in the scene (used in scene.findLighById for instance)
  73190. */
  73191. id: string;
  73192. /**
  73193. * The position the shdow will be casted from.
  73194. */
  73195. position: Vector3;
  73196. /**
  73197. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73198. */
  73199. direction: Vector3;
  73200. /**
  73201. * The transformed position. Position of the light in world space taking parenting in account.
  73202. */
  73203. transformedPosition: Vector3;
  73204. /**
  73205. * The transformed direction. Direction of the light in world space taking parenting in account.
  73206. */
  73207. transformedDirection: Vector3;
  73208. /**
  73209. * The friendly name of the light in the scene.
  73210. */
  73211. name: string;
  73212. /**
  73213. * Defines the shadow projection clipping minimum z value.
  73214. */
  73215. shadowMinZ: number;
  73216. /**
  73217. * Defines the shadow projection clipping maximum z value.
  73218. */
  73219. shadowMaxZ: number;
  73220. /**
  73221. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73222. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73223. */
  73224. computeTransformedInformation(): boolean;
  73225. /**
  73226. * Gets the scene the light belongs to.
  73227. * @returns The scene
  73228. */
  73229. getScene(): Scene;
  73230. /**
  73231. * Callback defining a custom Projection Matrix Builder.
  73232. * This can be used to override the default projection matrix computation.
  73233. */
  73234. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73235. /**
  73236. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73237. * @param matrix The materix to updated with the projection information
  73238. * @param viewMatrix The transform matrix of the light
  73239. * @param renderList The list of mesh to render in the map
  73240. * @returns The current light
  73241. */
  73242. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73243. /**
  73244. * Gets the current depth scale used in ESM.
  73245. * @returns The scale
  73246. */
  73247. getDepthScale(): number;
  73248. /**
  73249. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73250. * @returns true if a cube texture needs to be use
  73251. */
  73252. needCube(): boolean;
  73253. /**
  73254. * Detects if the projection matrix requires to be recomputed this frame.
  73255. * @returns true if it requires to be recomputed otherwise, false.
  73256. */
  73257. needProjectionMatrixCompute(): boolean;
  73258. /**
  73259. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73260. */
  73261. forceProjectionMatrixCompute(): void;
  73262. /**
  73263. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73264. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73265. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73266. */
  73267. getShadowDirection(faceIndex?: number): Vector3;
  73268. /**
  73269. * Gets the minZ used for shadow according to both the scene and the light.
  73270. * @param activeCamera The camera we are returning the min for
  73271. * @returns the depth min z
  73272. */
  73273. getDepthMinZ(activeCamera: Camera): number;
  73274. /**
  73275. * Gets the maxZ used for shadow according to both the scene and the light.
  73276. * @param activeCamera The camera we are returning the max for
  73277. * @returns the depth max z
  73278. */
  73279. getDepthMaxZ(activeCamera: Camera): number;
  73280. }
  73281. /**
  73282. * Base implementation IShadowLight
  73283. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73284. */
  73285. export abstract class ShadowLight extends Light implements IShadowLight {
  73286. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73287. protected _position: Vector3;
  73288. protected _setPosition(value: Vector3): void;
  73289. /**
  73290. * Sets the position the shadow will be casted from. Also use as the light position for both
  73291. * point and spot lights.
  73292. */
  73293. /**
  73294. * Sets the position the shadow will be casted from. Also use as the light position for both
  73295. * point and spot lights.
  73296. */
  73297. position: Vector3;
  73298. protected _direction: Vector3;
  73299. protected _setDirection(value: Vector3): void;
  73300. /**
  73301. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73302. * Also use as the light direction on spot and directional lights.
  73303. */
  73304. /**
  73305. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73306. * Also use as the light direction on spot and directional lights.
  73307. */
  73308. direction: Vector3;
  73309. private _shadowMinZ;
  73310. /**
  73311. * Gets the shadow projection clipping minimum z value.
  73312. */
  73313. /**
  73314. * Sets the shadow projection clipping minimum z value.
  73315. */
  73316. shadowMinZ: number;
  73317. private _shadowMaxZ;
  73318. /**
  73319. * Sets the shadow projection clipping maximum z value.
  73320. */
  73321. /**
  73322. * Gets the shadow projection clipping maximum z value.
  73323. */
  73324. shadowMaxZ: number;
  73325. /**
  73326. * Callback defining a custom Projection Matrix Builder.
  73327. * This can be used to override the default projection matrix computation.
  73328. */
  73329. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73330. /**
  73331. * The transformed position. Position of the light in world space taking parenting in account.
  73332. */
  73333. transformedPosition: Vector3;
  73334. /**
  73335. * The transformed direction. Direction of the light in world space taking parenting in account.
  73336. */
  73337. transformedDirection: Vector3;
  73338. private _needProjectionMatrixCompute;
  73339. /**
  73340. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73341. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73342. */
  73343. computeTransformedInformation(): boolean;
  73344. /**
  73345. * Return the depth scale used for the shadow map.
  73346. * @returns the depth scale.
  73347. */
  73348. getDepthScale(): number;
  73349. /**
  73350. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73351. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73352. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73353. */
  73354. getShadowDirection(faceIndex?: number): Vector3;
  73355. /**
  73356. * Returns the ShadowLight absolute position in the World.
  73357. * @returns the position vector in world space
  73358. */
  73359. getAbsolutePosition(): Vector3;
  73360. /**
  73361. * Sets the ShadowLight direction toward the passed target.
  73362. * @param target The point to target in local space
  73363. * @returns the updated ShadowLight direction
  73364. */
  73365. setDirectionToTarget(target: Vector3): Vector3;
  73366. /**
  73367. * Returns the light rotation in euler definition.
  73368. * @returns the x y z rotation in local space.
  73369. */
  73370. getRotation(): Vector3;
  73371. /**
  73372. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73373. * @returns true if a cube texture needs to be use
  73374. */
  73375. needCube(): boolean;
  73376. /**
  73377. * Detects if the projection matrix requires to be recomputed this frame.
  73378. * @returns true if it requires to be recomputed otherwise, false.
  73379. */
  73380. needProjectionMatrixCompute(): boolean;
  73381. /**
  73382. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73383. */
  73384. forceProjectionMatrixCompute(): void;
  73385. /** @hidden */
  73386. _initCache(): void;
  73387. /** @hidden */
  73388. _isSynchronized(): boolean;
  73389. /**
  73390. * Computes the world matrix of the node
  73391. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73392. * @returns the world matrix
  73393. */
  73394. computeWorldMatrix(force?: boolean): Matrix;
  73395. /**
  73396. * Gets the minZ used for shadow according to both the scene and the light.
  73397. * @param activeCamera The camera we are returning the min for
  73398. * @returns the depth min z
  73399. */
  73400. getDepthMinZ(activeCamera: Camera): number;
  73401. /**
  73402. * Gets the maxZ used for shadow according to both the scene and the light.
  73403. * @param activeCamera The camera we are returning the max for
  73404. * @returns the depth max z
  73405. */
  73406. getDepthMaxZ(activeCamera: Camera): number;
  73407. /**
  73408. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73409. * @param matrix The materix to updated with the projection information
  73410. * @param viewMatrix The transform matrix of the light
  73411. * @param renderList The list of mesh to render in the map
  73412. * @returns The current light
  73413. */
  73414. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73415. }
  73416. }
  73417. declare module BABYLON {
  73418. /**
  73419. * "Static Class" containing the most commonly used helper while dealing with material for
  73420. * rendering purpose.
  73421. *
  73422. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73423. *
  73424. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73425. */
  73426. export class MaterialHelper {
  73427. /**
  73428. * Bind the current view position to an effect.
  73429. * @param effect The effect to be bound
  73430. * @param scene The scene the eyes position is used from
  73431. */
  73432. static BindEyePosition(effect: Effect, scene: Scene): void;
  73433. /**
  73434. * Helps preparing the defines values about the UVs in used in the effect.
  73435. * UVs are shared as much as we can accross channels in the shaders.
  73436. * @param texture The texture we are preparing the UVs for
  73437. * @param defines The defines to update
  73438. * @param key The channel key "diffuse", "specular"... used in the shader
  73439. */
  73440. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73441. /**
  73442. * Binds a texture matrix value to its corrsponding uniform
  73443. * @param texture The texture to bind the matrix for
  73444. * @param uniformBuffer The uniform buffer receivin the data
  73445. * @param key The channel key "diffuse", "specular"... used in the shader
  73446. */
  73447. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73448. /**
  73449. * Gets the current status of the fog (should it be enabled?)
  73450. * @param mesh defines the mesh to evaluate for fog support
  73451. * @param scene defines the hosting scene
  73452. * @returns true if fog must be enabled
  73453. */
  73454. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73455. /**
  73456. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73457. * @param mesh defines the current mesh
  73458. * @param scene defines the current scene
  73459. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73460. * @param pointsCloud defines if point cloud rendering has to be turned on
  73461. * @param fogEnabled defines if fog has to be turned on
  73462. * @param alphaTest defines if alpha testing has to be turned on
  73463. * @param defines defines the current list of defines
  73464. */
  73465. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73466. /**
  73467. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73468. * @param scene defines the current scene
  73469. * @param engine defines the current engine
  73470. * @param defines specifies the list of active defines
  73471. * @param useInstances defines if instances have to be turned on
  73472. * @param useClipPlane defines if clip plane have to be turned on
  73473. */
  73474. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73475. /**
  73476. * Prepares the defines for bones
  73477. * @param mesh The mesh containing the geometry data we will draw
  73478. * @param defines The defines to update
  73479. */
  73480. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73481. /**
  73482. * Prepares the defines for morph targets
  73483. * @param mesh The mesh containing the geometry data we will draw
  73484. * @param defines The defines to update
  73485. */
  73486. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73487. /**
  73488. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73489. * @param mesh The mesh containing the geometry data we will draw
  73490. * @param defines The defines to update
  73491. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73492. * @param useBones Precise whether bones should be used or not (override mesh info)
  73493. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73494. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73495. * @returns false if defines are considered not dirty and have not been checked
  73496. */
  73497. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73498. /**
  73499. * Prepares the defines related to multiview
  73500. * @param scene The scene we are intending to draw
  73501. * @param defines The defines to update
  73502. */
  73503. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73504. /**
  73505. * Prepares the defines related to the light information passed in parameter
  73506. * @param scene The scene we are intending to draw
  73507. * @param mesh The mesh the effect is compiling for
  73508. * @param defines The defines to update
  73509. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73510. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73511. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73512. * @returns true if normals will be required for the rest of the effect
  73513. */
  73514. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73515. /**
  73516. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  73517. * that won t be acctive due to defines being turned off.
  73518. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73519. * @param samplersList The samplers list
  73520. * @param defines The defines helping in the list generation
  73521. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73522. */
  73523. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73524. /**
  73525. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73526. * @param defines The defines to update while falling back
  73527. * @param fallbacks The authorized effect fallbacks
  73528. * @param maxSimultaneousLights The maximum number of lights allowed
  73529. * @param rank the current rank of the Effect
  73530. * @returns The newly affected rank
  73531. */
  73532. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73533. /**
  73534. * Prepares the list of attributes required for morph targets according to the effect defines.
  73535. * @param attribs The current list of supported attribs
  73536. * @param mesh The mesh to prepare the morph targets attributes for
  73537. * @param defines The current Defines of the effect
  73538. */
  73539. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73540. /**
  73541. * Prepares the list of attributes required for bones according to the effect defines.
  73542. * @param attribs The current list of supported attribs
  73543. * @param mesh The mesh to prepare the bones attributes for
  73544. * @param defines The current Defines of the effect
  73545. * @param fallbacks The current efffect fallback strategy
  73546. */
  73547. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73548. /**
  73549. * Check and prepare the list of attributes required for instances according to the effect defines.
  73550. * @param attribs The current list of supported attribs
  73551. * @param defines The current MaterialDefines of the effect
  73552. */
  73553. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73554. /**
  73555. * Add the list of attributes required for instances to the attribs array.
  73556. * @param attribs The current list of supported attribs
  73557. */
  73558. static PushAttributesForInstances(attribs: string[]): void;
  73559. /**
  73560. * Binds the light shadow information to the effect for the given mesh.
  73561. * @param light The light containing the generator
  73562. * @param scene The scene the lights belongs to
  73563. * @param mesh The mesh we are binding the information to render
  73564. * @param lightIndex The light index in the effect used to render the mesh
  73565. * @param effect The effect we are binding the data to
  73566. */
  73567. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73568. /**
  73569. * Binds the light information to the effect.
  73570. * @param light The light containing the generator
  73571. * @param effect The effect we are binding the data to
  73572. * @param lightIndex The light index in the effect used to render
  73573. */
  73574. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73575. /**
  73576. * Binds the lights information from the scene to the effect for the given mesh.
  73577. * @param scene The scene the lights belongs to
  73578. * @param mesh The mesh we are binding the information to render
  73579. * @param effect The effect we are binding the data to
  73580. * @param defines The generated defines for the effect
  73581. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73582. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73583. */
  73584. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73585. private static _tempFogColor;
  73586. /**
  73587. * Binds the fog information from the scene to the effect for the given mesh.
  73588. * @param scene The scene the lights belongs to
  73589. * @param mesh The mesh we are binding the information to render
  73590. * @param effect The effect we are binding the data to
  73591. * @param linearSpace Defines if the fog effect is applied in linear space
  73592. */
  73593. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73594. /**
  73595. * Binds the bones information from the mesh to the effect.
  73596. * @param mesh The mesh we are binding the information to render
  73597. * @param effect The effect we are binding the data to
  73598. */
  73599. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73600. /**
  73601. * Binds the morph targets information from the mesh to the effect.
  73602. * @param abstractMesh The mesh we are binding the information to render
  73603. * @param effect The effect we are binding the data to
  73604. */
  73605. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73606. /**
  73607. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73608. * @param defines The generated defines used in the effect
  73609. * @param effect The effect we are binding the data to
  73610. * @param scene The scene we are willing to render with logarithmic scale for
  73611. */
  73612. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73613. /**
  73614. * Binds the clip plane information from the scene to the effect.
  73615. * @param scene The scene the clip plane information are extracted from
  73616. * @param effect The effect we are binding the data to
  73617. */
  73618. static BindClipPlane(effect: Effect, scene: Scene): void;
  73619. }
  73620. }
  73621. declare module BABYLON {
  73622. /** @hidden */
  73623. export var shadowMapPixelShader: {
  73624. name: string;
  73625. shader: string;
  73626. };
  73627. }
  73628. declare module BABYLON {
  73629. /** @hidden */
  73630. export var bonesDeclaration: {
  73631. name: string;
  73632. shader: string;
  73633. };
  73634. }
  73635. declare module BABYLON {
  73636. /** @hidden */
  73637. export var morphTargetsVertexGlobalDeclaration: {
  73638. name: string;
  73639. shader: string;
  73640. };
  73641. }
  73642. declare module BABYLON {
  73643. /** @hidden */
  73644. export var morphTargetsVertexDeclaration: {
  73645. name: string;
  73646. shader: string;
  73647. };
  73648. }
  73649. declare module BABYLON {
  73650. /** @hidden */
  73651. export var instancesDeclaration: {
  73652. name: string;
  73653. shader: string;
  73654. };
  73655. }
  73656. declare module BABYLON {
  73657. /** @hidden */
  73658. export var helperFunctions: {
  73659. name: string;
  73660. shader: string;
  73661. };
  73662. }
  73663. declare module BABYLON {
  73664. /** @hidden */
  73665. export var morphTargetsVertex: {
  73666. name: string;
  73667. shader: string;
  73668. };
  73669. }
  73670. declare module BABYLON {
  73671. /** @hidden */
  73672. export var instancesVertex: {
  73673. name: string;
  73674. shader: string;
  73675. };
  73676. }
  73677. declare module BABYLON {
  73678. /** @hidden */
  73679. export var bonesVertex: {
  73680. name: string;
  73681. shader: string;
  73682. };
  73683. }
  73684. declare module BABYLON {
  73685. /** @hidden */
  73686. export var shadowMapVertexShader: {
  73687. name: string;
  73688. shader: string;
  73689. };
  73690. }
  73691. declare module BABYLON {
  73692. /** @hidden */
  73693. export var depthBoxBlurPixelShader: {
  73694. name: string;
  73695. shader: string;
  73696. };
  73697. }
  73698. declare module BABYLON {
  73699. /**
  73700. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73701. */
  73702. export interface ICustomShaderOptions {
  73703. /**
  73704. * Gets or sets the custom shader name to use
  73705. */
  73706. shaderName: string;
  73707. /**
  73708. * The list of attribute names used in the shader
  73709. */
  73710. attributes?: string[];
  73711. /**
  73712. * The list of unifrom names used in the shader
  73713. */
  73714. uniforms?: string[];
  73715. /**
  73716. * The list of sampler names used in the shader
  73717. */
  73718. samplers?: string[];
  73719. /**
  73720. * The list of defines used in the shader
  73721. */
  73722. defines?: string[];
  73723. }
  73724. /**
  73725. * Interface to implement to create a shadow generator compatible with BJS.
  73726. */
  73727. export interface IShadowGenerator {
  73728. /**
  73729. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73730. * @returns The render target texture if present otherwise, null
  73731. */
  73732. getShadowMap(): Nullable<RenderTargetTexture>;
  73733. /**
  73734. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73735. * @returns The render target texture if the shadow map is present otherwise, null
  73736. */
  73737. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73738. /**
  73739. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73740. * @param subMesh The submesh we want to render in the shadow map
  73741. * @param useInstances Defines wether will draw in the map using instances
  73742. * @returns true if ready otherwise, false
  73743. */
  73744. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73745. /**
  73746. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73747. * @param defines Defines of the material we want to update
  73748. * @param lightIndex Index of the light in the enabled light list of the material
  73749. */
  73750. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73751. /**
  73752. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73753. * defined in the generator but impacting the effect).
  73754. * It implies the unifroms available on the materials are the standard BJS ones.
  73755. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73756. * @param effect The effect we are binfing the information for
  73757. */
  73758. bindShadowLight(lightIndex: string, effect: Effect): void;
  73759. /**
  73760. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73761. * (eq to shadow prjection matrix * light transform matrix)
  73762. * @returns The transform matrix used to create the shadow map
  73763. */
  73764. getTransformMatrix(): Matrix;
  73765. /**
  73766. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73767. * Cube and 2D textures for instance.
  73768. */
  73769. recreateShadowMap(): void;
  73770. /**
  73771. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73772. * @param onCompiled Callback triggered at the and of the effects compilation
  73773. * @param options Sets of optional options forcing the compilation with different modes
  73774. */
  73775. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73776. useInstances: boolean;
  73777. }>): void;
  73778. /**
  73779. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73780. * @param options Sets of optional options forcing the compilation with different modes
  73781. * @returns A promise that resolves when the compilation completes
  73782. */
  73783. forceCompilationAsync(options?: Partial<{
  73784. useInstances: boolean;
  73785. }>): Promise<void>;
  73786. /**
  73787. * Serializes the shadow generator setup to a json object.
  73788. * @returns The serialized JSON object
  73789. */
  73790. serialize(): any;
  73791. /**
  73792. * Disposes the Shadow map and related Textures and effects.
  73793. */
  73794. dispose(): void;
  73795. }
  73796. /**
  73797. * Default implementation IShadowGenerator.
  73798. * This is the main object responsible of generating shadows in the framework.
  73799. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73800. */
  73801. export class ShadowGenerator implements IShadowGenerator {
  73802. /**
  73803. * Shadow generator mode None: no filtering applied.
  73804. */
  73805. static readonly FILTER_NONE: number;
  73806. /**
  73807. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73808. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73809. */
  73810. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73811. /**
  73812. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73813. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73814. */
  73815. static readonly FILTER_POISSONSAMPLING: number;
  73816. /**
  73817. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73818. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73819. */
  73820. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73821. /**
  73822. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73823. * edge artifacts on steep falloff.
  73824. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73825. */
  73826. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73827. /**
  73828. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73829. * edge artifacts on steep falloff.
  73830. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73831. */
  73832. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73833. /**
  73834. * Shadow generator mode PCF: Percentage Closer Filtering
  73835. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73836. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73837. */
  73838. static readonly FILTER_PCF: number;
  73839. /**
  73840. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73841. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73842. * Contact Hardening
  73843. */
  73844. static readonly FILTER_PCSS: number;
  73845. /**
  73846. * Reserved for PCF and PCSS
  73847. * Highest Quality.
  73848. *
  73849. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73850. *
  73851. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73852. */
  73853. static readonly QUALITY_HIGH: number;
  73854. /**
  73855. * Reserved for PCF and PCSS
  73856. * Good tradeoff for quality/perf cross devices
  73857. *
  73858. * Execute PCF on a 3*3 kernel.
  73859. *
  73860. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73861. */
  73862. static readonly QUALITY_MEDIUM: number;
  73863. /**
  73864. * Reserved for PCF and PCSS
  73865. * The lowest quality but the fastest.
  73866. *
  73867. * Execute PCF on a 1*1 kernel.
  73868. *
  73869. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73870. */
  73871. static readonly QUALITY_LOW: number;
  73872. /** Gets or sets the custom shader name to use */
  73873. customShaderOptions: ICustomShaderOptions;
  73874. /**
  73875. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73876. */
  73877. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73878. /**
  73879. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73880. */
  73881. onAfterShadowMapRenderObservable: Observable<Effect>;
  73882. /**
  73883. * Observable triggered before a mesh is rendered in the shadow map.
  73884. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73885. */
  73886. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73887. /**
  73888. * Observable triggered after a mesh is rendered in the shadow map.
  73889. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73890. */
  73891. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73892. private _bias;
  73893. /**
  73894. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73895. */
  73896. /**
  73897. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73898. */
  73899. bias: number;
  73900. private _normalBias;
  73901. /**
  73902. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73903. */
  73904. /**
  73905. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73906. */
  73907. normalBias: number;
  73908. private _blurBoxOffset;
  73909. /**
  73910. * Gets the blur box offset: offset applied during the blur pass.
  73911. * Only useful if useKernelBlur = false
  73912. */
  73913. /**
  73914. * Sets the blur box offset: offset applied during the blur pass.
  73915. * Only useful if useKernelBlur = false
  73916. */
  73917. blurBoxOffset: number;
  73918. private _blurScale;
  73919. /**
  73920. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73921. * 2 means half of the size.
  73922. */
  73923. /**
  73924. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73925. * 2 means half of the size.
  73926. */
  73927. blurScale: number;
  73928. private _blurKernel;
  73929. /**
  73930. * Gets the blur kernel: kernel size of the blur pass.
  73931. * Only useful if useKernelBlur = true
  73932. */
  73933. /**
  73934. * Sets the blur kernel: kernel size of the blur pass.
  73935. * Only useful if useKernelBlur = true
  73936. */
  73937. blurKernel: number;
  73938. private _useKernelBlur;
  73939. /**
  73940. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73941. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73942. */
  73943. /**
  73944. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73945. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73946. */
  73947. useKernelBlur: boolean;
  73948. private _depthScale;
  73949. /**
  73950. * Gets the depth scale used in ESM mode.
  73951. */
  73952. /**
  73953. * Sets the depth scale used in ESM mode.
  73954. * This can override the scale stored on the light.
  73955. */
  73956. depthScale: number;
  73957. private _filter;
  73958. /**
  73959. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73960. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73961. */
  73962. /**
  73963. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73964. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73965. */
  73966. filter: number;
  73967. /**
  73968. * Gets if the current filter is set to Poisson Sampling.
  73969. */
  73970. /**
  73971. * Sets the current filter to Poisson Sampling.
  73972. */
  73973. usePoissonSampling: boolean;
  73974. /**
  73975. * Gets if the current filter is set to ESM.
  73976. */
  73977. /**
  73978. * Sets the current filter is to ESM.
  73979. */
  73980. useExponentialShadowMap: boolean;
  73981. /**
  73982. * Gets if the current filter is set to filtered ESM.
  73983. */
  73984. /**
  73985. * Gets if the current filter is set to filtered ESM.
  73986. */
  73987. useBlurExponentialShadowMap: boolean;
  73988. /**
  73989. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73990. * exponential to prevent steep falloff artifacts).
  73991. */
  73992. /**
  73993. * Sets the current filter to "close ESM" (using the inverse of the
  73994. * exponential to prevent steep falloff artifacts).
  73995. */
  73996. useCloseExponentialShadowMap: boolean;
  73997. /**
  73998. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73999. * exponential to prevent steep falloff artifacts).
  74000. */
  74001. /**
  74002. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74003. * exponential to prevent steep falloff artifacts).
  74004. */
  74005. useBlurCloseExponentialShadowMap: boolean;
  74006. /**
  74007. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74008. */
  74009. /**
  74010. * Sets the current filter to "PCF" (percentage closer filtering).
  74011. */
  74012. usePercentageCloserFiltering: boolean;
  74013. private _filteringQuality;
  74014. /**
  74015. * Gets the PCF or PCSS Quality.
  74016. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74017. */
  74018. /**
  74019. * Sets the PCF or PCSS Quality.
  74020. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74021. */
  74022. filteringQuality: number;
  74023. /**
  74024. * Gets if the current filter is set to "PCSS" (contact hardening).
  74025. */
  74026. /**
  74027. * Sets the current filter to "PCSS" (contact hardening).
  74028. */
  74029. useContactHardeningShadow: boolean;
  74030. private _contactHardeningLightSizeUVRatio;
  74031. /**
  74032. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74033. * Using a ratio helps keeping shape stability independently of the map size.
  74034. *
  74035. * It does not account for the light projection as it was having too much
  74036. * instability during the light setup or during light position changes.
  74037. *
  74038. * Only valid if useContactHardeningShadow is true.
  74039. */
  74040. /**
  74041. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74042. * Using a ratio helps keeping shape stability independently of the map size.
  74043. *
  74044. * It does not account for the light projection as it was having too much
  74045. * instability during the light setup or during light position changes.
  74046. *
  74047. * Only valid if useContactHardeningShadow is true.
  74048. */
  74049. contactHardeningLightSizeUVRatio: number;
  74050. private _darkness;
  74051. /** Gets or sets the actual darkness of a shadow */
  74052. darkness: number;
  74053. /**
  74054. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74055. * 0 means strongest and 1 would means no shadow.
  74056. * @returns the darkness.
  74057. */
  74058. getDarkness(): number;
  74059. /**
  74060. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74061. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74062. * @returns the shadow generator allowing fluent coding.
  74063. */
  74064. setDarkness(darkness: number): ShadowGenerator;
  74065. private _transparencyShadow;
  74066. /** Gets or sets the ability to have transparent shadow */
  74067. transparencyShadow: boolean;
  74068. /**
  74069. * Sets the ability to have transparent shadow (boolean).
  74070. * @param transparent True if transparent else False
  74071. * @returns the shadow generator allowing fluent coding
  74072. */
  74073. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74074. private _shadowMap;
  74075. private _shadowMap2;
  74076. /**
  74077. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74078. * @returns The render target texture if present otherwise, null
  74079. */
  74080. getShadowMap(): Nullable<RenderTargetTexture>;
  74081. /**
  74082. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74083. * @returns The render target texture if the shadow map is present otherwise, null
  74084. */
  74085. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74086. /**
  74087. * Gets the class name of that object
  74088. * @returns "ShadowGenerator"
  74089. */
  74090. getClassName(): string;
  74091. /**
  74092. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74093. * @param mesh Mesh to add
  74094. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74095. * @returns the Shadow Generator itself
  74096. */
  74097. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74098. /**
  74099. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74100. * @param mesh Mesh to remove
  74101. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74102. * @returns the Shadow Generator itself
  74103. */
  74104. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74105. /**
  74106. * Controls the extent to which the shadows fade out at the edge of the frustum
  74107. * Used only by directionals and spots
  74108. */
  74109. frustumEdgeFalloff: number;
  74110. private _light;
  74111. /**
  74112. * Returns the associated light object.
  74113. * @returns the light generating the shadow
  74114. */
  74115. getLight(): IShadowLight;
  74116. /**
  74117. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74118. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74119. * It might on the other hand introduce peter panning.
  74120. */
  74121. forceBackFacesOnly: boolean;
  74122. private _scene;
  74123. private _lightDirection;
  74124. private _effect;
  74125. private _viewMatrix;
  74126. private _projectionMatrix;
  74127. private _transformMatrix;
  74128. private _cachedPosition;
  74129. private _cachedDirection;
  74130. private _cachedDefines;
  74131. private _currentRenderID;
  74132. private _boxBlurPostprocess;
  74133. private _kernelBlurXPostprocess;
  74134. private _kernelBlurYPostprocess;
  74135. private _blurPostProcesses;
  74136. private _mapSize;
  74137. private _currentFaceIndex;
  74138. private _currentFaceIndexCache;
  74139. private _textureType;
  74140. private _defaultTextureMatrix;
  74141. /** @hidden */
  74142. static _SceneComponentInitialization: (scene: Scene) => void;
  74143. /**
  74144. * Creates a ShadowGenerator object.
  74145. * A ShadowGenerator is the required tool to use the shadows.
  74146. * Each light casting shadows needs to use its own ShadowGenerator.
  74147. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74148. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74149. * @param light The light object generating the shadows.
  74150. * @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.
  74151. */
  74152. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74153. private _initializeGenerator;
  74154. private _initializeShadowMap;
  74155. private _initializeBlurRTTAndPostProcesses;
  74156. private _renderForShadowMap;
  74157. private _renderSubMeshForShadowMap;
  74158. private _applyFilterValues;
  74159. /**
  74160. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74161. * @param onCompiled Callback triggered at the and of the effects compilation
  74162. * @param options Sets of optional options forcing the compilation with different modes
  74163. */
  74164. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74165. useInstances: boolean;
  74166. }>): void;
  74167. /**
  74168. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74169. * @param options Sets of optional options forcing the compilation with different modes
  74170. * @returns A promise that resolves when the compilation completes
  74171. */
  74172. forceCompilationAsync(options?: Partial<{
  74173. useInstances: boolean;
  74174. }>): Promise<void>;
  74175. /**
  74176. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74177. * @param subMesh The submesh we want to render in the shadow map
  74178. * @param useInstances Defines wether will draw in the map using instances
  74179. * @returns true if ready otherwise, false
  74180. */
  74181. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74182. /**
  74183. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74184. * @param defines Defines of the material we want to update
  74185. * @param lightIndex Index of the light in the enabled light list of the material
  74186. */
  74187. prepareDefines(defines: any, lightIndex: number): void;
  74188. /**
  74189. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74190. * defined in the generator but impacting the effect).
  74191. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74192. * @param effect The effect we are binfing the information for
  74193. */
  74194. bindShadowLight(lightIndex: string, effect: Effect): void;
  74195. /**
  74196. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74197. * (eq to shadow prjection matrix * light transform matrix)
  74198. * @returns The transform matrix used to create the shadow map
  74199. */
  74200. getTransformMatrix(): Matrix;
  74201. /**
  74202. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74203. * Cube and 2D textures for instance.
  74204. */
  74205. recreateShadowMap(): void;
  74206. private _disposeBlurPostProcesses;
  74207. private _disposeRTTandPostProcesses;
  74208. /**
  74209. * Disposes the ShadowGenerator.
  74210. * Returns nothing.
  74211. */
  74212. dispose(): void;
  74213. /**
  74214. * Serializes the shadow generator setup to a json object.
  74215. * @returns The serialized JSON object
  74216. */
  74217. serialize(): any;
  74218. /**
  74219. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74220. * @param parsedShadowGenerator The JSON object to parse
  74221. * @param scene The scene to create the shadow map for
  74222. * @returns The parsed shadow generator
  74223. */
  74224. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74225. }
  74226. }
  74227. declare module BABYLON {
  74228. /**
  74229. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74230. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74231. * 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.
  74232. */
  74233. export abstract class Light extends Node {
  74234. /**
  74235. * Falloff Default: light is falling off following the material specification:
  74236. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74237. */
  74238. static readonly FALLOFF_DEFAULT: number;
  74239. /**
  74240. * Falloff Physical: light is falling off following the inverse squared distance law.
  74241. */
  74242. static readonly FALLOFF_PHYSICAL: number;
  74243. /**
  74244. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74245. * to enhance interoperability with other engines.
  74246. */
  74247. static readonly FALLOFF_GLTF: number;
  74248. /**
  74249. * Falloff Standard: light is falling off like in the standard material
  74250. * to enhance interoperability with other materials.
  74251. */
  74252. static readonly FALLOFF_STANDARD: number;
  74253. /**
  74254. * If every light affecting the material is in this lightmapMode,
  74255. * material.lightmapTexture adds or multiplies
  74256. * (depends on material.useLightmapAsShadowmap)
  74257. * after every other light calculations.
  74258. */
  74259. static readonly LIGHTMAP_DEFAULT: number;
  74260. /**
  74261. * material.lightmapTexture as only diffuse lighting from this light
  74262. * adds only specular lighting from this light
  74263. * adds dynamic shadows
  74264. */
  74265. static readonly LIGHTMAP_SPECULAR: number;
  74266. /**
  74267. * material.lightmapTexture as only lighting
  74268. * no light calculation from this light
  74269. * only adds dynamic shadows from this light
  74270. */
  74271. static readonly LIGHTMAP_SHADOWSONLY: number;
  74272. /**
  74273. * Each light type uses the default quantity according to its type:
  74274. * point/spot lights use luminous intensity
  74275. * directional lights use illuminance
  74276. */
  74277. static readonly INTENSITYMODE_AUTOMATIC: number;
  74278. /**
  74279. * lumen (lm)
  74280. */
  74281. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74282. /**
  74283. * candela (lm/sr)
  74284. */
  74285. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74286. /**
  74287. * lux (lm/m^2)
  74288. */
  74289. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74290. /**
  74291. * nit (cd/m^2)
  74292. */
  74293. static readonly INTENSITYMODE_LUMINANCE: number;
  74294. /**
  74295. * Light type const id of the point light.
  74296. */
  74297. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74298. /**
  74299. * Light type const id of the directional light.
  74300. */
  74301. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74302. /**
  74303. * Light type const id of the spot light.
  74304. */
  74305. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74306. /**
  74307. * Light type const id of the hemispheric light.
  74308. */
  74309. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74310. /**
  74311. * Diffuse gives the basic color to an object.
  74312. */
  74313. diffuse: Color3;
  74314. /**
  74315. * Specular produces a highlight color on an object.
  74316. * Note: This is note affecting PBR materials.
  74317. */
  74318. specular: Color3;
  74319. /**
  74320. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74321. * falling off base on range or angle.
  74322. * This can be set to any values in Light.FALLOFF_x.
  74323. *
  74324. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74325. * other types of materials.
  74326. */
  74327. falloffType: number;
  74328. /**
  74329. * Strength of the light.
  74330. * Note: By default it is define in the framework own unit.
  74331. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74332. */
  74333. intensity: number;
  74334. private _range;
  74335. protected _inverseSquaredRange: number;
  74336. /**
  74337. * Defines how far from the source the light is impacting in scene units.
  74338. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74339. */
  74340. /**
  74341. * Defines how far from the source the light is impacting in scene units.
  74342. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74343. */
  74344. range: number;
  74345. /**
  74346. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74347. * of light.
  74348. */
  74349. private _photometricScale;
  74350. private _intensityMode;
  74351. /**
  74352. * Gets the photometric scale used to interpret the intensity.
  74353. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74354. */
  74355. /**
  74356. * Sets the photometric scale used to interpret the intensity.
  74357. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74358. */
  74359. intensityMode: number;
  74360. private _radius;
  74361. /**
  74362. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74363. */
  74364. /**
  74365. * sets the light radius used by PBR Materials to simulate soft area lights.
  74366. */
  74367. radius: number;
  74368. private _renderPriority;
  74369. /**
  74370. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74371. * exceeding the number allowed of the materials.
  74372. */
  74373. renderPriority: number;
  74374. private _shadowEnabled;
  74375. /**
  74376. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74377. * the current shadow generator.
  74378. */
  74379. /**
  74380. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74381. * the current shadow generator.
  74382. */
  74383. shadowEnabled: boolean;
  74384. private _includedOnlyMeshes;
  74385. /**
  74386. * Gets the only meshes impacted by this light.
  74387. */
  74388. /**
  74389. * Sets the only meshes impacted by this light.
  74390. */
  74391. includedOnlyMeshes: AbstractMesh[];
  74392. private _excludedMeshes;
  74393. /**
  74394. * Gets the meshes not impacted by this light.
  74395. */
  74396. /**
  74397. * Sets the meshes not impacted by this light.
  74398. */
  74399. excludedMeshes: AbstractMesh[];
  74400. private _excludeWithLayerMask;
  74401. /**
  74402. * Gets the layer id use to find what meshes are not impacted by the light.
  74403. * Inactive if 0
  74404. */
  74405. /**
  74406. * Sets the layer id use to find what meshes are not impacted by the light.
  74407. * Inactive if 0
  74408. */
  74409. excludeWithLayerMask: number;
  74410. private _includeOnlyWithLayerMask;
  74411. /**
  74412. * Gets the layer id use to find what meshes are impacted by the light.
  74413. * Inactive if 0
  74414. */
  74415. /**
  74416. * Sets the layer id use to find what meshes are impacted by the light.
  74417. * Inactive if 0
  74418. */
  74419. includeOnlyWithLayerMask: number;
  74420. private _lightmapMode;
  74421. /**
  74422. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74423. */
  74424. /**
  74425. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74426. */
  74427. lightmapMode: number;
  74428. /**
  74429. * Shadow generator associted to the light.
  74430. * @hidden Internal use only.
  74431. */
  74432. _shadowGenerator: Nullable<IShadowGenerator>;
  74433. /**
  74434. * @hidden Internal use only.
  74435. */
  74436. _excludedMeshesIds: string[];
  74437. /**
  74438. * @hidden Internal use only.
  74439. */
  74440. _includedOnlyMeshesIds: string[];
  74441. /**
  74442. * The current light unifom buffer.
  74443. * @hidden Internal use only.
  74444. */
  74445. _uniformBuffer: UniformBuffer;
  74446. /**
  74447. * Creates a Light object in the scene.
  74448. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74449. * @param name The firendly name of the light
  74450. * @param scene The scene the light belongs too
  74451. */
  74452. constructor(name: string, scene: Scene);
  74453. protected abstract _buildUniformLayout(): void;
  74454. /**
  74455. * Sets the passed Effect "effect" with the Light information.
  74456. * @param effect The effect to update
  74457. * @param lightIndex The index of the light in the effect to update
  74458. * @returns The light
  74459. */
  74460. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74461. /**
  74462. * Returns the string "Light".
  74463. * @returns the class name
  74464. */
  74465. getClassName(): string;
  74466. /** @hidden */
  74467. readonly _isLight: boolean;
  74468. /**
  74469. * Converts the light information to a readable string for debug purpose.
  74470. * @param fullDetails Supports for multiple levels of logging within scene loading
  74471. * @returns the human readable light info
  74472. */
  74473. toString(fullDetails?: boolean): string;
  74474. /** @hidden */
  74475. protected _syncParentEnabledState(): void;
  74476. /**
  74477. * Set the enabled state of this node.
  74478. * @param value - the new enabled state
  74479. */
  74480. setEnabled(value: boolean): void;
  74481. /**
  74482. * Returns the Light associated shadow generator if any.
  74483. * @return the associated shadow generator.
  74484. */
  74485. getShadowGenerator(): Nullable<IShadowGenerator>;
  74486. /**
  74487. * Returns a Vector3, the absolute light position in the World.
  74488. * @returns the world space position of the light
  74489. */
  74490. getAbsolutePosition(): Vector3;
  74491. /**
  74492. * Specifies if the light will affect the passed mesh.
  74493. * @param mesh The mesh to test against the light
  74494. * @return true the mesh is affected otherwise, false.
  74495. */
  74496. canAffectMesh(mesh: AbstractMesh): boolean;
  74497. /**
  74498. * Sort function to order lights for rendering.
  74499. * @param a First Light object to compare to second.
  74500. * @param b Second Light object to compare first.
  74501. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74502. */
  74503. static CompareLightsPriority(a: Light, b: Light): number;
  74504. /**
  74505. * Releases resources associated with this node.
  74506. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74507. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74508. */
  74509. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74510. /**
  74511. * Returns the light type ID (integer).
  74512. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74513. */
  74514. getTypeID(): number;
  74515. /**
  74516. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74517. * @returns the scaled intensity in intensity mode unit
  74518. */
  74519. getScaledIntensity(): number;
  74520. /**
  74521. * Returns a new Light object, named "name", from the current one.
  74522. * @param name The name of the cloned light
  74523. * @returns the new created light
  74524. */
  74525. clone(name: string): Nullable<Light>;
  74526. /**
  74527. * Serializes the current light into a Serialization object.
  74528. * @returns the serialized object.
  74529. */
  74530. serialize(): any;
  74531. /**
  74532. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74533. * This new light is named "name" and added to the passed scene.
  74534. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74535. * @param name The friendly name of the light
  74536. * @param scene The scene the new light will belong to
  74537. * @returns the constructor function
  74538. */
  74539. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74540. /**
  74541. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74542. * @param parsedLight The JSON representation of the light
  74543. * @param scene The scene to create the parsed light in
  74544. * @returns the created light after parsing
  74545. */
  74546. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74547. private _hookArrayForExcluded;
  74548. private _hookArrayForIncludedOnly;
  74549. private _resyncMeshes;
  74550. /**
  74551. * Forces the meshes to update their light related information in their rendering used effects
  74552. * @hidden Internal Use Only
  74553. */
  74554. _markMeshesAsLightDirty(): void;
  74555. /**
  74556. * Recomputes the cached photometric scale if needed.
  74557. */
  74558. private _computePhotometricScale;
  74559. /**
  74560. * Returns the Photometric Scale according to the light type and intensity mode.
  74561. */
  74562. private _getPhotometricScale;
  74563. /**
  74564. * Reorder the light in the scene according to their defined priority.
  74565. * @hidden Internal Use Only
  74566. */
  74567. _reorderLightsInScene(): void;
  74568. /**
  74569. * Prepares the list of defines specific to the light type.
  74570. * @param defines the list of defines
  74571. * @param lightIndex defines the index of the light for the effect
  74572. */
  74573. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74574. }
  74575. }
  74576. declare module BABYLON {
  74577. /**
  74578. * Creates an instance based on a source mesh.
  74579. */
  74580. export class InstancedMesh extends AbstractMesh {
  74581. private _sourceMesh;
  74582. private _currentLOD;
  74583. /** @hidden */
  74584. _indexInSourceMeshInstanceArray: number;
  74585. constructor(name: string, source: Mesh);
  74586. /**
  74587. * Returns the string "InstancedMesh".
  74588. */
  74589. getClassName(): string;
  74590. /** Gets the list of lights affecting that mesh */
  74591. readonly lightSources: Light[];
  74592. _resyncLightSources(): void;
  74593. _resyncLighSource(light: Light): void;
  74594. _removeLightSource(light: Light): void;
  74595. /**
  74596. * If the source mesh receives shadows
  74597. */
  74598. readonly receiveShadows: boolean;
  74599. /**
  74600. * The material of the source mesh
  74601. */
  74602. readonly material: Nullable<Material>;
  74603. /**
  74604. * Visibility of the source mesh
  74605. */
  74606. readonly visibility: number;
  74607. /**
  74608. * Skeleton of the source mesh
  74609. */
  74610. readonly skeleton: Nullable<Skeleton>;
  74611. /**
  74612. * Rendering ground id of the source mesh
  74613. */
  74614. renderingGroupId: number;
  74615. /**
  74616. * Returns the total number of vertices (integer).
  74617. */
  74618. getTotalVertices(): number;
  74619. /**
  74620. * Returns a positive integer : the total number of indices in this mesh geometry.
  74621. * @returns the numner of indices or zero if the mesh has no geometry.
  74622. */
  74623. getTotalIndices(): number;
  74624. /**
  74625. * The source mesh of the instance
  74626. */
  74627. readonly sourceMesh: Mesh;
  74628. /**
  74629. * Is this node ready to be used/rendered
  74630. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74631. * @return {boolean} is it ready
  74632. */
  74633. isReady(completeCheck?: boolean): boolean;
  74634. /**
  74635. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74636. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74637. * @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.
  74638. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74639. */
  74640. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74641. /**
  74642. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74643. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74644. * The `data` are either a numeric array either a Float32Array.
  74645. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74646. * 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).
  74647. * Note that a new underlying VertexBuffer object is created each call.
  74648. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74649. *
  74650. * Possible `kind` values :
  74651. * - VertexBuffer.PositionKind
  74652. * - VertexBuffer.UVKind
  74653. * - VertexBuffer.UV2Kind
  74654. * - VertexBuffer.UV3Kind
  74655. * - VertexBuffer.UV4Kind
  74656. * - VertexBuffer.UV5Kind
  74657. * - VertexBuffer.UV6Kind
  74658. * - VertexBuffer.ColorKind
  74659. * - VertexBuffer.MatricesIndicesKind
  74660. * - VertexBuffer.MatricesIndicesExtraKind
  74661. * - VertexBuffer.MatricesWeightsKind
  74662. * - VertexBuffer.MatricesWeightsExtraKind
  74663. *
  74664. * Returns the Mesh.
  74665. */
  74666. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74667. /**
  74668. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74669. * If the mesh has no geometry, it is simply returned as it is.
  74670. * The `data` are either a numeric array either a Float32Array.
  74671. * No new underlying VertexBuffer object is created.
  74672. * 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.
  74673. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74674. *
  74675. * Possible `kind` values :
  74676. * - VertexBuffer.PositionKind
  74677. * - VertexBuffer.UVKind
  74678. * - VertexBuffer.UV2Kind
  74679. * - VertexBuffer.UV3Kind
  74680. * - VertexBuffer.UV4Kind
  74681. * - VertexBuffer.UV5Kind
  74682. * - VertexBuffer.UV6Kind
  74683. * - VertexBuffer.ColorKind
  74684. * - VertexBuffer.MatricesIndicesKind
  74685. * - VertexBuffer.MatricesIndicesExtraKind
  74686. * - VertexBuffer.MatricesWeightsKind
  74687. * - VertexBuffer.MatricesWeightsExtraKind
  74688. *
  74689. * Returns the Mesh.
  74690. */
  74691. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74692. /**
  74693. * Sets the mesh indices.
  74694. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74695. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74696. * This method creates a new index buffer each call.
  74697. * Returns the Mesh.
  74698. */
  74699. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74700. /**
  74701. * Boolean : True if the mesh owns the requested kind of data.
  74702. */
  74703. isVerticesDataPresent(kind: string): boolean;
  74704. /**
  74705. * Returns an array of indices (IndicesArray).
  74706. */
  74707. getIndices(): Nullable<IndicesArray>;
  74708. readonly _positions: Nullable<Vector3[]>;
  74709. /**
  74710. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74711. * This means the mesh underlying bounding box and sphere are recomputed.
  74712. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74713. * @returns the current mesh
  74714. */
  74715. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74716. /** @hidden */
  74717. _preActivate(): InstancedMesh;
  74718. /** @hidden */
  74719. _activate(renderId: number, intermediateRendering: boolean): boolean;
  74720. /** @hidden */
  74721. _postActivate(): void;
  74722. getWorldMatrix(): Matrix;
  74723. readonly isAnInstance: boolean;
  74724. /**
  74725. * Returns the current associated LOD AbstractMesh.
  74726. */
  74727. getLOD(camera: Camera): AbstractMesh;
  74728. /** @hidden */
  74729. _syncSubMeshes(): InstancedMesh;
  74730. /** @hidden */
  74731. _generatePointsArray(): boolean;
  74732. /**
  74733. * Creates a new InstancedMesh from the current mesh.
  74734. * - name (string) : the cloned mesh name
  74735. * - newParent (optional Node) : the optional Node to parent the clone to.
  74736. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74737. *
  74738. * Returns the clone.
  74739. */
  74740. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74741. /**
  74742. * Disposes the InstancedMesh.
  74743. * Returns nothing.
  74744. */
  74745. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74746. }
  74747. }
  74748. declare module BABYLON {
  74749. /**
  74750. * Defines the options associated with the creation of a shader material.
  74751. */
  74752. export interface IShaderMaterialOptions {
  74753. /**
  74754. * Does the material work in alpha blend mode
  74755. */
  74756. needAlphaBlending: boolean;
  74757. /**
  74758. * Does the material work in alpha test mode
  74759. */
  74760. needAlphaTesting: boolean;
  74761. /**
  74762. * The list of attribute names used in the shader
  74763. */
  74764. attributes: string[];
  74765. /**
  74766. * The list of unifrom names used in the shader
  74767. */
  74768. uniforms: string[];
  74769. /**
  74770. * The list of UBO names used in the shader
  74771. */
  74772. uniformBuffers: string[];
  74773. /**
  74774. * The list of sampler names used in the shader
  74775. */
  74776. samplers: string[];
  74777. /**
  74778. * The list of defines used in the shader
  74779. */
  74780. defines: string[];
  74781. }
  74782. /**
  74783. * 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.
  74784. *
  74785. * This returned material effects how the mesh will look based on the code in the shaders.
  74786. *
  74787. * @see http://doc.babylonjs.com/how_to/shader_material
  74788. */
  74789. export class ShaderMaterial extends Material {
  74790. private _shaderPath;
  74791. private _options;
  74792. private _textures;
  74793. private _textureArrays;
  74794. private _floats;
  74795. private _ints;
  74796. private _floatsArrays;
  74797. private _colors3;
  74798. private _colors3Arrays;
  74799. private _colors4;
  74800. private _vectors2;
  74801. private _vectors3;
  74802. private _vectors4;
  74803. private _matrices;
  74804. private _matrices3x3;
  74805. private _matrices2x2;
  74806. private _vectors2Arrays;
  74807. private _vectors3Arrays;
  74808. private _cachedWorldViewMatrix;
  74809. private _cachedWorldViewProjectionMatrix;
  74810. private _renderId;
  74811. /**
  74812. * Instantiate a new shader material.
  74813. * 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.
  74814. * This returned material effects how the mesh will look based on the code in the shaders.
  74815. * @see http://doc.babylonjs.com/how_to/shader_material
  74816. * @param name Define the name of the material in the scene
  74817. * @param scene Define the scene the material belongs to
  74818. * @param shaderPath Defines the route to the shader code in one of three ways:
  74819. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74820. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74821. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74822. * @param options Define the options used to create the shader
  74823. */
  74824. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74825. /**
  74826. * Gets the options used to compile the shader.
  74827. * They can be modified to trigger a new compilation
  74828. */
  74829. readonly options: IShaderMaterialOptions;
  74830. /**
  74831. * Gets the current class name of the material e.g. "ShaderMaterial"
  74832. * Mainly use in serialization.
  74833. * @returns the class name
  74834. */
  74835. getClassName(): string;
  74836. /**
  74837. * Specifies if the material will require alpha blending
  74838. * @returns a boolean specifying if alpha blending is needed
  74839. */
  74840. needAlphaBlending(): boolean;
  74841. /**
  74842. * Specifies if this material should be rendered in alpha test mode
  74843. * @returns a boolean specifying if an alpha test is needed.
  74844. */
  74845. needAlphaTesting(): boolean;
  74846. private _checkUniform;
  74847. /**
  74848. * Set a texture in the shader.
  74849. * @param name Define the name of the uniform samplers as defined in the shader
  74850. * @param texture Define the texture to bind to this sampler
  74851. * @return the material itself allowing "fluent" like uniform updates
  74852. */
  74853. setTexture(name: string, texture: Texture): ShaderMaterial;
  74854. /**
  74855. * Set a texture array in the shader.
  74856. * @param name Define the name of the uniform sampler array as defined in the shader
  74857. * @param textures Define the list of textures to bind to this sampler
  74858. * @return the material itself allowing "fluent" like uniform updates
  74859. */
  74860. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74861. /**
  74862. * Set a float in the shader.
  74863. * @param name Define the name of the uniform as defined in the shader
  74864. * @param value Define the value to give to the uniform
  74865. * @return the material itself allowing "fluent" like uniform updates
  74866. */
  74867. setFloat(name: string, value: number): ShaderMaterial;
  74868. /**
  74869. * Set a int in the shader.
  74870. * @param name Define the name of the uniform as defined in the shader
  74871. * @param value Define the value to give to the uniform
  74872. * @return the material itself allowing "fluent" like uniform updates
  74873. */
  74874. setInt(name: string, value: number): ShaderMaterial;
  74875. /**
  74876. * Set an array of floats in the shader.
  74877. * @param name Define the name of the uniform as defined in the shader
  74878. * @param value Define the value to give to the uniform
  74879. * @return the material itself allowing "fluent" like uniform updates
  74880. */
  74881. setFloats(name: string, value: number[]): ShaderMaterial;
  74882. /**
  74883. * Set a vec3 in the shader from a Color3.
  74884. * @param name Define the name of the uniform as defined in the shader
  74885. * @param value Define the value to give to the uniform
  74886. * @return the material itself allowing "fluent" like uniform updates
  74887. */
  74888. setColor3(name: string, value: Color3): ShaderMaterial;
  74889. /**
  74890. * Set a vec3 array in the shader from a Color3 array.
  74891. * @param name Define the name of the uniform as defined in the shader
  74892. * @param value Define the value to give to the uniform
  74893. * @return the material itself allowing "fluent" like uniform updates
  74894. */
  74895. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74896. /**
  74897. * Set a vec4 in the shader from a Color4.
  74898. * @param name Define the name of the uniform as defined in the shader
  74899. * @param value Define the value to give to the uniform
  74900. * @return the material itself allowing "fluent" like uniform updates
  74901. */
  74902. setColor4(name: string, value: Color4): ShaderMaterial;
  74903. /**
  74904. * Set a vec2 in the shader from a Vector2.
  74905. * @param name Define the name of the uniform as defined in the shader
  74906. * @param value Define the value to give to the uniform
  74907. * @return the material itself allowing "fluent" like uniform updates
  74908. */
  74909. setVector2(name: string, value: Vector2): ShaderMaterial;
  74910. /**
  74911. * Set a vec3 in the shader from a Vector3.
  74912. * @param name Define the name of the uniform as defined in the shader
  74913. * @param value Define the value to give to the uniform
  74914. * @return the material itself allowing "fluent" like uniform updates
  74915. */
  74916. setVector3(name: string, value: Vector3): ShaderMaterial;
  74917. /**
  74918. * Set a vec4 in the shader from a Vector4.
  74919. * @param name Define the name of the uniform as defined in the shader
  74920. * @param value Define the value to give to the uniform
  74921. * @return the material itself allowing "fluent" like uniform updates
  74922. */
  74923. setVector4(name: string, value: Vector4): ShaderMaterial;
  74924. /**
  74925. * Set a mat4 in the shader from a Matrix.
  74926. * @param name Define the name of the uniform as defined in the shader
  74927. * @param value Define the value to give to the uniform
  74928. * @return the material itself allowing "fluent" like uniform updates
  74929. */
  74930. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74931. /**
  74932. * Set a mat3 in the shader from a Float32Array.
  74933. * @param name Define the name of the uniform as defined in the shader
  74934. * @param value Define the value to give to the uniform
  74935. * @return the material itself allowing "fluent" like uniform updates
  74936. */
  74937. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74938. /**
  74939. * Set a mat2 in the shader from a Float32Array.
  74940. * @param name Define the name of the uniform as defined in the shader
  74941. * @param value Define the value to give to the uniform
  74942. * @return the material itself allowing "fluent" like uniform updates
  74943. */
  74944. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74945. /**
  74946. * Set a vec2 array in the shader from a number array.
  74947. * @param name Define the name of the uniform as defined in the shader
  74948. * @param value Define the value to give to the uniform
  74949. * @return the material itself allowing "fluent" like uniform updates
  74950. */
  74951. setArray2(name: string, value: number[]): ShaderMaterial;
  74952. /**
  74953. * Set a vec3 array in the shader from a number array.
  74954. * @param name Define the name of the uniform as defined in the shader
  74955. * @param value Define the value to give to the uniform
  74956. * @return the material itself allowing "fluent" like uniform updates
  74957. */
  74958. setArray3(name: string, value: number[]): ShaderMaterial;
  74959. private _checkCache;
  74960. /**
  74961. * Specifies that the submesh is ready to be used
  74962. * @param mesh defines the mesh to check
  74963. * @param subMesh defines which submesh to check
  74964. * @param useInstances specifies that instances should be used
  74965. * @returns a boolean indicating that the submesh is ready or not
  74966. */
  74967. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  74968. /**
  74969. * Checks if the material is ready to render the requested mesh
  74970. * @param mesh Define the mesh to render
  74971. * @param useInstances Define whether or not the material is used with instances
  74972. * @returns true if ready, otherwise false
  74973. */
  74974. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74975. /**
  74976. * Binds the world matrix to the material
  74977. * @param world defines the world transformation matrix
  74978. */
  74979. bindOnlyWorldMatrix(world: Matrix): void;
  74980. /**
  74981. * Binds the material to the mesh
  74982. * @param world defines the world transformation matrix
  74983. * @param mesh defines the mesh to bind the material to
  74984. */
  74985. bind(world: Matrix, mesh?: Mesh): void;
  74986. /**
  74987. * Gets the active textures from the material
  74988. * @returns an array of textures
  74989. */
  74990. getActiveTextures(): BaseTexture[];
  74991. /**
  74992. * Specifies if the material uses a texture
  74993. * @param texture defines the texture to check against the material
  74994. * @returns a boolean specifying if the material uses the texture
  74995. */
  74996. hasTexture(texture: BaseTexture): boolean;
  74997. /**
  74998. * Makes a duplicate of the material, and gives it a new name
  74999. * @param name defines the new name for the duplicated material
  75000. * @returns the cloned material
  75001. */
  75002. clone(name: string): ShaderMaterial;
  75003. /**
  75004. * Disposes the material
  75005. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75006. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75007. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75008. */
  75009. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75010. /**
  75011. * Serializes this material in a JSON representation
  75012. * @returns the serialized material object
  75013. */
  75014. serialize(): any;
  75015. /**
  75016. * Creates a shader material from parsed shader material data
  75017. * @param source defines the JSON represnetation of the material
  75018. * @param scene defines the hosting scene
  75019. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75020. * @returns a new material
  75021. */
  75022. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75023. }
  75024. }
  75025. declare module BABYLON {
  75026. /** @hidden */
  75027. export var clipPlaneFragmentDeclaration: {
  75028. name: string;
  75029. shader: string;
  75030. };
  75031. }
  75032. declare module BABYLON {
  75033. /** @hidden */
  75034. export var clipPlaneFragment: {
  75035. name: string;
  75036. shader: string;
  75037. };
  75038. }
  75039. declare module BABYLON {
  75040. /** @hidden */
  75041. export var colorPixelShader: {
  75042. name: string;
  75043. shader: string;
  75044. };
  75045. }
  75046. declare module BABYLON {
  75047. /** @hidden */
  75048. export var clipPlaneVertexDeclaration: {
  75049. name: string;
  75050. shader: string;
  75051. };
  75052. }
  75053. declare module BABYLON {
  75054. /** @hidden */
  75055. export var clipPlaneVertex: {
  75056. name: string;
  75057. shader: string;
  75058. };
  75059. }
  75060. declare module BABYLON {
  75061. /** @hidden */
  75062. export var colorVertexShader: {
  75063. name: string;
  75064. shader: string;
  75065. };
  75066. }
  75067. declare module BABYLON {
  75068. /**
  75069. * Line mesh
  75070. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75071. */
  75072. export class LinesMesh extends Mesh {
  75073. /**
  75074. * If vertex color should be applied to the mesh
  75075. */
  75076. readonly useVertexColor?: boolean | undefined;
  75077. /**
  75078. * If vertex alpha should be applied to the mesh
  75079. */
  75080. readonly useVertexAlpha?: boolean | undefined;
  75081. /**
  75082. * Color of the line (Default: White)
  75083. */
  75084. color: Color3;
  75085. /**
  75086. * Alpha of the line (Default: 1)
  75087. */
  75088. alpha: number;
  75089. /**
  75090. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75091. * This margin is expressed in world space coordinates, so its value may vary.
  75092. * Default value is 0.1
  75093. */
  75094. intersectionThreshold: number;
  75095. private _colorShader;
  75096. private color4;
  75097. /**
  75098. * Creates a new LinesMesh
  75099. * @param name defines the name
  75100. * @param scene defines the hosting scene
  75101. * @param parent defines the parent mesh if any
  75102. * @param source defines the optional source LinesMesh used to clone data from
  75103. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75104. * When false, achieved by calling a clone(), also passing False.
  75105. * This will make creation of children, recursive.
  75106. * @param useVertexColor defines if this LinesMesh supports vertex color
  75107. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75108. */
  75109. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75110. /**
  75111. * If vertex color should be applied to the mesh
  75112. */
  75113. useVertexColor?: boolean | undefined,
  75114. /**
  75115. * If vertex alpha should be applied to the mesh
  75116. */
  75117. useVertexAlpha?: boolean | undefined);
  75118. private _addClipPlaneDefine;
  75119. private _removeClipPlaneDefine;
  75120. isReady(): boolean;
  75121. /**
  75122. * Returns the string "LineMesh"
  75123. */
  75124. getClassName(): string;
  75125. /**
  75126. * @hidden
  75127. */
  75128. /**
  75129. * @hidden
  75130. */
  75131. material: Material;
  75132. /**
  75133. * @hidden
  75134. */
  75135. readonly checkCollisions: boolean;
  75136. /** @hidden */
  75137. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75138. /** @hidden */
  75139. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75140. /**
  75141. * Disposes of the line mesh
  75142. * @param doNotRecurse If children should be disposed
  75143. */
  75144. dispose(doNotRecurse?: boolean): void;
  75145. /**
  75146. * Returns a new LineMesh object cloned from the current one.
  75147. */
  75148. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75149. /**
  75150. * Creates a new InstancedLinesMesh object from the mesh model.
  75151. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75152. * @param name defines the name of the new instance
  75153. * @returns a new InstancedLinesMesh
  75154. */
  75155. createInstance(name: string): InstancedLinesMesh;
  75156. }
  75157. /**
  75158. * Creates an instance based on a source LinesMesh
  75159. */
  75160. export class InstancedLinesMesh extends InstancedMesh {
  75161. /**
  75162. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75163. * This margin is expressed in world space coordinates, so its value may vary.
  75164. * Initilized with the intersectionThreshold value of the source LinesMesh
  75165. */
  75166. intersectionThreshold: number;
  75167. constructor(name: string, source: LinesMesh);
  75168. /**
  75169. * Returns the string "InstancedLinesMesh".
  75170. */
  75171. getClassName(): string;
  75172. }
  75173. }
  75174. declare module BABYLON {
  75175. /**
  75176. * Mesh representing the gorund
  75177. */
  75178. export class GroundMesh extends Mesh {
  75179. /** If octree should be generated */
  75180. generateOctree: boolean;
  75181. private _heightQuads;
  75182. /** @hidden */
  75183. _subdivisionsX: number;
  75184. /** @hidden */
  75185. _subdivisionsY: number;
  75186. /** @hidden */
  75187. _width: number;
  75188. /** @hidden */
  75189. _height: number;
  75190. /** @hidden */
  75191. _minX: number;
  75192. /** @hidden */
  75193. _maxX: number;
  75194. /** @hidden */
  75195. _minZ: number;
  75196. /** @hidden */
  75197. _maxZ: number;
  75198. constructor(name: string, scene: Scene);
  75199. /**
  75200. * "GroundMesh"
  75201. * @returns "GroundMesh"
  75202. */
  75203. getClassName(): string;
  75204. /**
  75205. * The minimum of x and y subdivisions
  75206. */
  75207. readonly subdivisions: number;
  75208. /**
  75209. * X subdivisions
  75210. */
  75211. readonly subdivisionsX: number;
  75212. /**
  75213. * Y subdivisions
  75214. */
  75215. readonly subdivisionsY: number;
  75216. /**
  75217. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75218. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75219. * @param chunksCount the number of subdivisions for x and y
  75220. * @param octreeBlocksSize (Default: 32)
  75221. */
  75222. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75223. /**
  75224. * Returns a height (y) value in the Worl system :
  75225. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75226. * @param x x coordinate
  75227. * @param z z coordinate
  75228. * @returns the ground y position if (x, z) are outside the ground surface.
  75229. */
  75230. getHeightAtCoordinates(x: number, z: number): number;
  75231. /**
  75232. * Returns a normalized vector (Vector3) orthogonal to the ground
  75233. * at the ground coordinates (x, z) expressed in the World system.
  75234. * @param x x coordinate
  75235. * @param z z coordinate
  75236. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75237. */
  75238. getNormalAtCoordinates(x: number, z: number): Vector3;
  75239. /**
  75240. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75241. * at the ground coordinates (x, z) expressed in the World system.
  75242. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75243. * @param x x coordinate
  75244. * @param z z coordinate
  75245. * @param ref vector to store the result
  75246. * @returns the GroundMesh.
  75247. */
  75248. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75249. /**
  75250. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75251. * if the ground has been updated.
  75252. * This can be used in the render loop.
  75253. * @returns the GroundMesh.
  75254. */
  75255. updateCoordinateHeights(): GroundMesh;
  75256. private _getFacetAt;
  75257. private _initHeightQuads;
  75258. private _computeHeightQuads;
  75259. /**
  75260. * Serializes this ground mesh
  75261. * @param serializationObject object to write serialization to
  75262. */
  75263. serialize(serializationObject: any): void;
  75264. /**
  75265. * Parses a serialized ground mesh
  75266. * @param parsedMesh the serialized mesh
  75267. * @param scene the scene to create the ground mesh in
  75268. * @returns the created ground mesh
  75269. */
  75270. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75271. }
  75272. }
  75273. declare module BABYLON {
  75274. /**
  75275. * Interface for Physics-Joint data
  75276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75277. */
  75278. export interface PhysicsJointData {
  75279. /**
  75280. * The main pivot of the joint
  75281. */
  75282. mainPivot?: Vector3;
  75283. /**
  75284. * The connected pivot of the joint
  75285. */
  75286. connectedPivot?: Vector3;
  75287. /**
  75288. * The main axis of the joint
  75289. */
  75290. mainAxis?: Vector3;
  75291. /**
  75292. * The connected axis of the joint
  75293. */
  75294. connectedAxis?: Vector3;
  75295. /**
  75296. * The collision of the joint
  75297. */
  75298. collision?: boolean;
  75299. /**
  75300. * Native Oimo/Cannon/Energy data
  75301. */
  75302. nativeParams?: any;
  75303. }
  75304. /**
  75305. * This is a holder class for the physics joint created by the physics plugin
  75306. * It holds a set of functions to control the underlying joint
  75307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75308. */
  75309. export class PhysicsJoint {
  75310. /**
  75311. * The type of the physics joint
  75312. */
  75313. type: number;
  75314. /**
  75315. * The data for the physics joint
  75316. */
  75317. jointData: PhysicsJointData;
  75318. private _physicsJoint;
  75319. protected _physicsPlugin: IPhysicsEnginePlugin;
  75320. /**
  75321. * Initializes the physics joint
  75322. * @param type The type of the physics joint
  75323. * @param jointData The data for the physics joint
  75324. */
  75325. constructor(
  75326. /**
  75327. * The type of the physics joint
  75328. */
  75329. type: number,
  75330. /**
  75331. * The data for the physics joint
  75332. */
  75333. jointData: PhysicsJointData);
  75334. /**
  75335. * Gets the physics joint
  75336. */
  75337. /**
  75338. * Sets the physics joint
  75339. */
  75340. physicsJoint: any;
  75341. /**
  75342. * Sets the physics plugin
  75343. */
  75344. physicsPlugin: IPhysicsEnginePlugin;
  75345. /**
  75346. * Execute a function that is physics-plugin specific.
  75347. * @param {Function} func the function that will be executed.
  75348. * It accepts two parameters: the physics world and the physics joint
  75349. */
  75350. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75351. /**
  75352. * Distance-Joint type
  75353. */
  75354. static DistanceJoint: number;
  75355. /**
  75356. * Hinge-Joint type
  75357. */
  75358. static HingeJoint: number;
  75359. /**
  75360. * Ball-and-Socket joint type
  75361. */
  75362. static BallAndSocketJoint: number;
  75363. /**
  75364. * Wheel-Joint type
  75365. */
  75366. static WheelJoint: number;
  75367. /**
  75368. * Slider-Joint type
  75369. */
  75370. static SliderJoint: number;
  75371. /**
  75372. * Prismatic-Joint type
  75373. */
  75374. static PrismaticJoint: number;
  75375. /**
  75376. * Universal-Joint type
  75377. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75378. */
  75379. static UniversalJoint: number;
  75380. /**
  75381. * Hinge-Joint 2 type
  75382. */
  75383. static Hinge2Joint: number;
  75384. /**
  75385. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75386. */
  75387. static PointToPointJoint: number;
  75388. /**
  75389. * Spring-Joint type
  75390. */
  75391. static SpringJoint: number;
  75392. /**
  75393. * Lock-Joint type
  75394. */
  75395. static LockJoint: number;
  75396. }
  75397. /**
  75398. * A class representing a physics distance joint
  75399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75400. */
  75401. export class DistanceJoint extends PhysicsJoint {
  75402. /**
  75403. *
  75404. * @param jointData The data for the Distance-Joint
  75405. */
  75406. constructor(jointData: DistanceJointData);
  75407. /**
  75408. * Update the predefined distance.
  75409. * @param maxDistance The maximum preferred distance
  75410. * @param minDistance The minimum preferred distance
  75411. */
  75412. updateDistance(maxDistance: number, minDistance?: number): void;
  75413. }
  75414. /**
  75415. * Represents a Motor-Enabled Joint
  75416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75417. */
  75418. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75419. /**
  75420. * Initializes the Motor-Enabled Joint
  75421. * @param type The type of the joint
  75422. * @param jointData The physica joint data for the joint
  75423. */
  75424. constructor(type: number, jointData: PhysicsJointData);
  75425. /**
  75426. * Set the motor values.
  75427. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75428. * @param force the force to apply
  75429. * @param maxForce max force for this motor.
  75430. */
  75431. setMotor(force?: number, maxForce?: number): void;
  75432. /**
  75433. * Set the motor's limits.
  75434. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75435. * @param upperLimit The upper limit of the motor
  75436. * @param lowerLimit The lower limit of the motor
  75437. */
  75438. setLimit(upperLimit: number, lowerLimit?: number): void;
  75439. }
  75440. /**
  75441. * This class represents a single physics Hinge-Joint
  75442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75443. */
  75444. export class HingeJoint extends MotorEnabledJoint {
  75445. /**
  75446. * Initializes the Hinge-Joint
  75447. * @param jointData The joint data for the Hinge-Joint
  75448. */
  75449. constructor(jointData: PhysicsJointData);
  75450. /**
  75451. * Set the motor values.
  75452. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75453. * @param {number} force the force to apply
  75454. * @param {number} maxForce max force for this motor.
  75455. */
  75456. setMotor(force?: number, maxForce?: number): void;
  75457. /**
  75458. * Set the motor's limits.
  75459. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75460. * @param upperLimit The upper limit of the motor
  75461. * @param lowerLimit The lower limit of the motor
  75462. */
  75463. setLimit(upperLimit: number, lowerLimit?: number): void;
  75464. }
  75465. /**
  75466. * This class represents a dual hinge physics joint (same as wheel joint)
  75467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75468. */
  75469. export class Hinge2Joint extends MotorEnabledJoint {
  75470. /**
  75471. * Initializes the Hinge2-Joint
  75472. * @param jointData The joint data for the Hinge2-Joint
  75473. */
  75474. constructor(jointData: PhysicsJointData);
  75475. /**
  75476. * Set the motor values.
  75477. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75478. * @param {number} targetSpeed the speed the motor is to reach
  75479. * @param {number} maxForce max force for this motor.
  75480. * @param {motorIndex} the motor's index, 0 or 1.
  75481. */
  75482. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75483. /**
  75484. * Set the motor limits.
  75485. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75486. * @param {number} upperLimit the upper limit
  75487. * @param {number} lowerLimit lower limit
  75488. * @param {motorIndex} the motor's index, 0 or 1.
  75489. */
  75490. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75491. }
  75492. /**
  75493. * Interface for a motor enabled joint
  75494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75495. */
  75496. export interface IMotorEnabledJoint {
  75497. /**
  75498. * Physics joint
  75499. */
  75500. physicsJoint: any;
  75501. /**
  75502. * Sets the motor of the motor-enabled joint
  75503. * @param force The force of the motor
  75504. * @param maxForce The maximum force of the motor
  75505. * @param motorIndex The index of the motor
  75506. */
  75507. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75508. /**
  75509. * Sets the limit of the motor
  75510. * @param upperLimit The upper limit of the motor
  75511. * @param lowerLimit The lower limit of the motor
  75512. * @param motorIndex The index of the motor
  75513. */
  75514. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75515. }
  75516. /**
  75517. * Joint data for a Distance-Joint
  75518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75519. */
  75520. export interface DistanceJointData extends PhysicsJointData {
  75521. /**
  75522. * Max distance the 2 joint objects can be apart
  75523. */
  75524. maxDistance: number;
  75525. }
  75526. /**
  75527. * Joint data from a spring joint
  75528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75529. */
  75530. export interface SpringJointData extends PhysicsJointData {
  75531. /**
  75532. * Length of the spring
  75533. */
  75534. length: number;
  75535. /**
  75536. * Stiffness of the spring
  75537. */
  75538. stiffness: number;
  75539. /**
  75540. * Damping of the spring
  75541. */
  75542. damping: number;
  75543. /** this callback will be called when applying the force to the impostors. */
  75544. forceApplicationCallback: () => void;
  75545. }
  75546. }
  75547. declare module BABYLON {
  75548. /**
  75549. * Holds the data for the raycast result
  75550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75551. */
  75552. export class PhysicsRaycastResult {
  75553. private _hasHit;
  75554. private _hitDistance;
  75555. private _hitNormalWorld;
  75556. private _hitPointWorld;
  75557. private _rayFromWorld;
  75558. private _rayToWorld;
  75559. /**
  75560. * Gets if there was a hit
  75561. */
  75562. readonly hasHit: boolean;
  75563. /**
  75564. * Gets the distance from the hit
  75565. */
  75566. readonly hitDistance: number;
  75567. /**
  75568. * Gets the hit normal/direction in the world
  75569. */
  75570. readonly hitNormalWorld: Vector3;
  75571. /**
  75572. * Gets the hit point in the world
  75573. */
  75574. readonly hitPointWorld: Vector3;
  75575. /**
  75576. * Gets the ray "start point" of the ray in the world
  75577. */
  75578. readonly rayFromWorld: Vector3;
  75579. /**
  75580. * Gets the ray "end point" of the ray in the world
  75581. */
  75582. readonly rayToWorld: Vector3;
  75583. /**
  75584. * Sets the hit data (normal & point in world space)
  75585. * @param hitNormalWorld defines the normal in world space
  75586. * @param hitPointWorld defines the point in world space
  75587. */
  75588. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  75589. /**
  75590. * Sets the distance from the start point to the hit point
  75591. * @param distance
  75592. */
  75593. setHitDistance(distance: number): void;
  75594. /**
  75595. * Calculates the distance manually
  75596. */
  75597. calculateHitDistance(): void;
  75598. /**
  75599. * Resets all the values to default
  75600. * @param from The from point on world space
  75601. * @param to The to point on world space
  75602. */
  75603. reset(from?: Vector3, to?: Vector3): void;
  75604. }
  75605. /**
  75606. * Interface for the size containing width and height
  75607. */
  75608. interface IXYZ {
  75609. /**
  75610. * X
  75611. */
  75612. x: number;
  75613. /**
  75614. * Y
  75615. */
  75616. y: number;
  75617. /**
  75618. * Z
  75619. */
  75620. z: number;
  75621. }
  75622. }
  75623. declare module BABYLON {
  75624. /**
  75625. * Interface used to describe a physics joint
  75626. */
  75627. export interface PhysicsImpostorJoint {
  75628. /** Defines the main impostor to which the joint is linked */
  75629. mainImpostor: PhysicsImpostor;
  75630. /** Defines the impostor that is connected to the main impostor using this joint */
  75631. connectedImpostor: PhysicsImpostor;
  75632. /** Defines the joint itself */
  75633. joint: PhysicsJoint;
  75634. }
  75635. /** @hidden */
  75636. export interface IPhysicsEnginePlugin {
  75637. world: any;
  75638. name: string;
  75639. setGravity(gravity: Vector3): void;
  75640. setTimeStep(timeStep: number): void;
  75641. getTimeStep(): number;
  75642. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  75643. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75644. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75645. generatePhysicsBody(impostor: PhysicsImpostor): void;
  75646. removePhysicsBody(impostor: PhysicsImpostor): void;
  75647. generateJoint(joint: PhysicsImpostorJoint): void;
  75648. removeJoint(joint: PhysicsImpostorJoint): void;
  75649. isSupported(): boolean;
  75650. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  75651. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  75652. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75653. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75654. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75655. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75656. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  75657. getBodyMass(impostor: PhysicsImpostor): number;
  75658. getBodyFriction(impostor: PhysicsImpostor): number;
  75659. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  75660. getBodyRestitution(impostor: PhysicsImpostor): number;
  75661. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  75662. getBodyPressure?(impostor: PhysicsImpostor): number;
  75663. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  75664. getBodyStiffness?(impostor: PhysicsImpostor): number;
  75665. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  75666. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  75667. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  75668. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  75669. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  75670. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75671. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75672. sleepBody(impostor: PhysicsImpostor): void;
  75673. wakeUpBody(impostor: PhysicsImpostor): void;
  75674. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75675. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  75676. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75677. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75678. getRadius(impostor: PhysicsImpostor): number;
  75679. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75680. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75681. dispose(): void;
  75682. }
  75683. /**
  75684. * Interface used to define a physics engine
  75685. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75686. */
  75687. export interface IPhysicsEngine {
  75688. /**
  75689. * Gets the gravity vector used by the simulation
  75690. */
  75691. gravity: Vector3;
  75692. /**
  75693. * Sets the gravity vector used by the simulation
  75694. * @param gravity defines the gravity vector to use
  75695. */
  75696. setGravity(gravity: Vector3): void;
  75697. /**
  75698. * Set the time step of the physics engine.
  75699. * Default is 1/60.
  75700. * To slow it down, enter 1/600 for example.
  75701. * To speed it up, 1/30
  75702. * @param newTimeStep the new timestep to apply to this world.
  75703. */
  75704. setTimeStep(newTimeStep: number): void;
  75705. /**
  75706. * Get the time step of the physics engine.
  75707. * @returns the current time step
  75708. */
  75709. getTimeStep(): number;
  75710. /**
  75711. * Release all resources
  75712. */
  75713. dispose(): void;
  75714. /**
  75715. * Gets the name of the current physics plugin
  75716. * @returns the name of the plugin
  75717. */
  75718. getPhysicsPluginName(): string;
  75719. /**
  75720. * Adding a new impostor for the impostor tracking.
  75721. * This will be done by the impostor itself.
  75722. * @param impostor the impostor to add
  75723. */
  75724. addImpostor(impostor: PhysicsImpostor): void;
  75725. /**
  75726. * Remove an impostor from the engine.
  75727. * This impostor and its mesh will not longer be updated by the physics engine.
  75728. * @param impostor the impostor to remove
  75729. */
  75730. removeImpostor(impostor: PhysicsImpostor): void;
  75731. /**
  75732. * Add a joint to the physics engine
  75733. * @param mainImpostor defines the main impostor to which the joint is added.
  75734. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75735. * @param joint defines the joint that will connect both impostors.
  75736. */
  75737. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75738. /**
  75739. * Removes a joint from the simulation
  75740. * @param mainImpostor defines the impostor used with the joint
  75741. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75742. * @param joint defines the joint to remove
  75743. */
  75744. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75745. /**
  75746. * Gets the current plugin used to run the simulation
  75747. * @returns current plugin
  75748. */
  75749. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75750. /**
  75751. * Gets the list of physic impostors
  75752. * @returns an array of PhysicsImpostor
  75753. */
  75754. getImpostors(): Array<PhysicsImpostor>;
  75755. /**
  75756. * Gets the impostor for a physics enabled object
  75757. * @param object defines the object impersonated by the impostor
  75758. * @returns the PhysicsImpostor or null if not found
  75759. */
  75760. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75761. /**
  75762. * Gets the impostor for a physics body object
  75763. * @param body defines physics body used by the impostor
  75764. * @returns the PhysicsImpostor or null if not found
  75765. */
  75766. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75767. /**
  75768. * Does a raycast in the physics world
  75769. * @param from when should the ray start?
  75770. * @param to when should the ray end?
  75771. * @returns PhysicsRaycastResult
  75772. */
  75773. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75774. /**
  75775. * Called by the scene. No need to call it.
  75776. * @param delta defines the timespam between frames
  75777. */
  75778. _step(delta: number): void;
  75779. }
  75780. }
  75781. declare module BABYLON {
  75782. /**
  75783. * The interface for the physics imposter parameters
  75784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75785. */
  75786. export interface PhysicsImpostorParameters {
  75787. /**
  75788. * The mass of the physics imposter
  75789. */
  75790. mass: number;
  75791. /**
  75792. * The friction of the physics imposter
  75793. */
  75794. friction?: number;
  75795. /**
  75796. * The coefficient of restitution of the physics imposter
  75797. */
  75798. restitution?: number;
  75799. /**
  75800. * The native options of the physics imposter
  75801. */
  75802. nativeOptions?: any;
  75803. /**
  75804. * Specifies if the parent should be ignored
  75805. */
  75806. ignoreParent?: boolean;
  75807. /**
  75808. * Specifies if bi-directional transformations should be disabled
  75809. */
  75810. disableBidirectionalTransformation?: boolean;
  75811. /**
  75812. * The pressure inside the physics imposter, soft object only
  75813. */
  75814. pressure?: number;
  75815. /**
  75816. * The stiffness the physics imposter, soft object only
  75817. */
  75818. stiffness?: number;
  75819. /**
  75820. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  75821. */
  75822. velocityIterations?: number;
  75823. /**
  75824. * The number of iterations used in maintaining consistent vertex positions, soft object only
  75825. */
  75826. positionIterations?: number;
  75827. /**
  75828. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  75829. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  75830. * Add to fix multiple points
  75831. */
  75832. fixedPoints?: number;
  75833. /**
  75834. * The collision margin around a soft object
  75835. */
  75836. margin?: number;
  75837. /**
  75838. * The collision margin around a soft object
  75839. */
  75840. damping?: number;
  75841. /**
  75842. * The path for a rope based on an extrusion
  75843. */
  75844. path?: any;
  75845. /**
  75846. * The shape of an extrusion used for a rope based on an extrusion
  75847. */
  75848. shape?: any;
  75849. }
  75850. /**
  75851. * Interface for a physics-enabled object
  75852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75853. */
  75854. export interface IPhysicsEnabledObject {
  75855. /**
  75856. * The position of the physics-enabled object
  75857. */
  75858. position: Vector3;
  75859. /**
  75860. * The rotation of the physics-enabled object
  75861. */
  75862. rotationQuaternion: Nullable<Quaternion>;
  75863. /**
  75864. * The scale of the physics-enabled object
  75865. */
  75866. scaling: Vector3;
  75867. /**
  75868. * The rotation of the physics-enabled object
  75869. */
  75870. rotation?: Vector3;
  75871. /**
  75872. * The parent of the physics-enabled object
  75873. */
  75874. parent?: any;
  75875. /**
  75876. * The bounding info of the physics-enabled object
  75877. * @returns The bounding info of the physics-enabled object
  75878. */
  75879. getBoundingInfo(): BoundingInfo;
  75880. /**
  75881. * Computes the world matrix
  75882. * @param force Specifies if the world matrix should be computed by force
  75883. * @returns A world matrix
  75884. */
  75885. computeWorldMatrix(force: boolean): Matrix;
  75886. /**
  75887. * Gets the world matrix
  75888. * @returns A world matrix
  75889. */
  75890. getWorldMatrix?(): Matrix;
  75891. /**
  75892. * Gets the child meshes
  75893. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  75894. * @returns An array of abstract meshes
  75895. */
  75896. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  75897. /**
  75898. * Gets the vertex data
  75899. * @param kind The type of vertex data
  75900. * @returns A nullable array of numbers, or a float32 array
  75901. */
  75902. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  75903. /**
  75904. * Gets the indices from the mesh
  75905. * @returns A nullable array of index arrays
  75906. */
  75907. getIndices?(): Nullable<IndicesArray>;
  75908. /**
  75909. * Gets the scene from the mesh
  75910. * @returns the indices array or null
  75911. */
  75912. getScene?(): Scene;
  75913. /**
  75914. * Gets the absolute position from the mesh
  75915. * @returns the absolute position
  75916. */
  75917. getAbsolutePosition(): Vector3;
  75918. /**
  75919. * Gets the absolute pivot point from the mesh
  75920. * @returns the absolute pivot point
  75921. */
  75922. getAbsolutePivotPoint(): Vector3;
  75923. /**
  75924. * Rotates the mesh
  75925. * @param axis The axis of rotation
  75926. * @param amount The amount of rotation
  75927. * @param space The space of the rotation
  75928. * @returns The rotation transform node
  75929. */
  75930. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  75931. /**
  75932. * Translates the mesh
  75933. * @param axis The axis of translation
  75934. * @param distance The distance of translation
  75935. * @param space The space of the translation
  75936. * @returns The transform node
  75937. */
  75938. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  75939. /**
  75940. * Sets the absolute position of the mesh
  75941. * @param absolutePosition The absolute position of the mesh
  75942. * @returns The transform node
  75943. */
  75944. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  75945. /**
  75946. * Gets the class name of the mesh
  75947. * @returns The class name
  75948. */
  75949. getClassName(): string;
  75950. }
  75951. /**
  75952. * Represents a physics imposter
  75953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75954. */
  75955. export class PhysicsImpostor {
  75956. /**
  75957. * The physics-enabled object used as the physics imposter
  75958. */
  75959. object: IPhysicsEnabledObject;
  75960. /**
  75961. * The type of the physics imposter
  75962. */
  75963. type: number;
  75964. private _options;
  75965. private _scene?;
  75966. /**
  75967. * The default object size of the imposter
  75968. */
  75969. static DEFAULT_OBJECT_SIZE: Vector3;
  75970. /**
  75971. * The identity quaternion of the imposter
  75972. */
  75973. static IDENTITY_QUATERNION: Quaternion;
  75974. /** @hidden */
  75975. _pluginData: any;
  75976. private _physicsEngine;
  75977. private _physicsBody;
  75978. private _bodyUpdateRequired;
  75979. private _onBeforePhysicsStepCallbacks;
  75980. private _onAfterPhysicsStepCallbacks;
  75981. /** @hidden */
  75982. _onPhysicsCollideCallbacks: Array<{
  75983. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  75984. otherImpostors: Array<PhysicsImpostor>;
  75985. }>;
  75986. private _deltaPosition;
  75987. private _deltaRotation;
  75988. private _deltaRotationConjugated;
  75989. /** @hidden */
  75990. _isFromLine: boolean;
  75991. private _parent;
  75992. private _isDisposed;
  75993. private static _tmpVecs;
  75994. private static _tmpQuat;
  75995. /**
  75996. * Specifies if the physics imposter is disposed
  75997. */
  75998. readonly isDisposed: boolean;
  75999. /**
  76000. * Gets the mass of the physics imposter
  76001. */
  76002. mass: number;
  76003. /**
  76004. * Gets the coefficient of friction
  76005. */
  76006. /**
  76007. * Sets the coefficient of friction
  76008. */
  76009. friction: number;
  76010. /**
  76011. * Gets the coefficient of restitution
  76012. */
  76013. /**
  76014. * Sets the coefficient of restitution
  76015. */
  76016. restitution: number;
  76017. /**
  76018. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76019. */
  76020. /**
  76021. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76022. */
  76023. pressure: number;
  76024. /**
  76025. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76026. */
  76027. /**
  76028. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76029. */
  76030. stiffness: number;
  76031. /**
  76032. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76033. */
  76034. /**
  76035. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76036. */
  76037. velocityIterations: number;
  76038. /**
  76039. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76040. */
  76041. /**
  76042. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76043. */
  76044. positionIterations: number;
  76045. /**
  76046. * The unique id of the physics imposter
  76047. * set by the physics engine when adding this impostor to the array
  76048. */
  76049. uniqueId: number;
  76050. /**
  76051. * @hidden
  76052. */
  76053. soft: boolean;
  76054. /**
  76055. * @hidden
  76056. */
  76057. segments: number;
  76058. private _joints;
  76059. /**
  76060. * Initializes the physics imposter
  76061. * @param object The physics-enabled object used as the physics imposter
  76062. * @param type The type of the physics imposter
  76063. * @param _options The options for the physics imposter
  76064. * @param _scene The Babylon scene
  76065. */
  76066. constructor(
  76067. /**
  76068. * The physics-enabled object used as the physics imposter
  76069. */
  76070. object: IPhysicsEnabledObject,
  76071. /**
  76072. * The type of the physics imposter
  76073. */
  76074. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76075. /**
  76076. * This function will completly initialize this impostor.
  76077. * It will create a new body - but only if this mesh has no parent.
  76078. * If it has, this impostor will not be used other than to define the impostor
  76079. * of the child mesh.
  76080. * @hidden
  76081. */
  76082. _init(): void;
  76083. private _getPhysicsParent;
  76084. /**
  76085. * Should a new body be generated.
  76086. * @returns boolean specifying if body initialization is required
  76087. */
  76088. isBodyInitRequired(): boolean;
  76089. /**
  76090. * Sets the updated scaling
  76091. * @param updated Specifies if the scaling is updated
  76092. */
  76093. setScalingUpdated(): void;
  76094. /**
  76095. * Force a regeneration of this or the parent's impostor's body.
  76096. * Use under cautious - This will remove all joints already implemented.
  76097. */
  76098. forceUpdate(): void;
  76099. /**
  76100. * Gets the body that holds this impostor. Either its own, or its parent.
  76101. */
  76102. /**
  76103. * Set the physics body. Used mainly by the physics engine/plugin
  76104. */
  76105. physicsBody: any;
  76106. /**
  76107. * Get the parent of the physics imposter
  76108. * @returns Physics imposter or null
  76109. */
  76110. /**
  76111. * Sets the parent of the physics imposter
  76112. */
  76113. parent: Nullable<PhysicsImpostor>;
  76114. /**
  76115. * Resets the update flags
  76116. */
  76117. resetUpdateFlags(): void;
  76118. /**
  76119. * Gets the object extend size
  76120. * @returns the object extend size
  76121. */
  76122. getObjectExtendSize(): Vector3;
  76123. /**
  76124. * Gets the object center
  76125. * @returns The object center
  76126. */
  76127. getObjectCenter(): Vector3;
  76128. /**
  76129. * Get a specific parametes from the options parameter
  76130. * @param paramName The object parameter name
  76131. * @returns The object parameter
  76132. */
  76133. getParam(paramName: string): any;
  76134. /**
  76135. * Sets a specific parameter in the options given to the physics plugin
  76136. * @param paramName The parameter name
  76137. * @param value The value of the parameter
  76138. */
  76139. setParam(paramName: string, value: number): void;
  76140. /**
  76141. * Specifically change the body's mass option. Won't recreate the physics body object
  76142. * @param mass The mass of the physics imposter
  76143. */
  76144. setMass(mass: number): void;
  76145. /**
  76146. * Gets the linear velocity
  76147. * @returns linear velocity or null
  76148. */
  76149. getLinearVelocity(): Nullable<Vector3>;
  76150. /**
  76151. * Sets the linear velocity
  76152. * @param velocity linear velocity or null
  76153. */
  76154. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76155. /**
  76156. * Gets the angular velocity
  76157. * @returns angular velocity or null
  76158. */
  76159. getAngularVelocity(): Nullable<Vector3>;
  76160. /**
  76161. * Sets the angular velocity
  76162. * @param velocity The velocity or null
  76163. */
  76164. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76165. /**
  76166. * Execute a function with the physics plugin native code
  76167. * Provide a function the will have two variables - the world object and the physics body object
  76168. * @param func The function to execute with the physics plugin native code
  76169. */
  76170. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76171. /**
  76172. * Register a function that will be executed before the physics world is stepping forward
  76173. * @param func The function to execute before the physics world is stepped forward
  76174. */
  76175. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76176. /**
  76177. * Unregister a function that will be executed before the physics world is stepping forward
  76178. * @param func The function to execute before the physics world is stepped forward
  76179. */
  76180. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76181. /**
  76182. * Register a function that will be executed after the physics step
  76183. * @param func The function to execute after physics step
  76184. */
  76185. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76186. /**
  76187. * Unregisters a function that will be executed after the physics step
  76188. * @param func The function to execute after physics step
  76189. */
  76190. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76191. /**
  76192. * register a function that will be executed when this impostor collides against a different body
  76193. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76194. * @param func Callback that is executed on collision
  76195. */
  76196. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76197. /**
  76198. * Unregisters the physics imposter on contact
  76199. * @param collideAgainst The physics object to collide against
  76200. * @param func Callback to execute on collision
  76201. */
  76202. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76203. private _tmpQuat;
  76204. private _tmpQuat2;
  76205. /**
  76206. * Get the parent rotation
  76207. * @returns The parent rotation
  76208. */
  76209. getParentsRotation(): Quaternion;
  76210. /**
  76211. * this function is executed by the physics engine.
  76212. */
  76213. beforeStep: () => void;
  76214. /**
  76215. * this function is executed by the physics engine
  76216. */
  76217. afterStep: () => void;
  76218. /**
  76219. * Legacy collision detection event support
  76220. */
  76221. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76222. /**
  76223. * event and body object due to cannon's event-based architecture.
  76224. */
  76225. onCollide: (e: {
  76226. body: any;
  76227. }) => void;
  76228. /**
  76229. * Apply a force
  76230. * @param force The force to apply
  76231. * @param contactPoint The contact point for the force
  76232. * @returns The physics imposter
  76233. */
  76234. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76235. /**
  76236. * Apply an impulse
  76237. * @param force The impulse force
  76238. * @param contactPoint The contact point for the impulse force
  76239. * @returns The physics imposter
  76240. */
  76241. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76242. /**
  76243. * A help function to create a joint
  76244. * @param otherImpostor A physics imposter used to create a joint
  76245. * @param jointType The type of joint
  76246. * @param jointData The data for the joint
  76247. * @returns The physics imposter
  76248. */
  76249. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76250. /**
  76251. * Add a joint to this impostor with a different impostor
  76252. * @param otherImpostor A physics imposter used to add a joint
  76253. * @param joint The joint to add
  76254. * @returns The physics imposter
  76255. */
  76256. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76257. /**
  76258. * Add an anchor to a cloth impostor
  76259. * @param otherImpostor rigid impostor to anchor to
  76260. * @param width ratio across width from 0 to 1
  76261. * @param height ratio up height from 0 to 1
  76262. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76263. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76264. * @returns impostor the soft imposter
  76265. */
  76266. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76267. /**
  76268. * Add a hook to a rope impostor
  76269. * @param otherImpostor rigid impostor to anchor to
  76270. * @param length ratio across rope from 0 to 1
  76271. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76272. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76273. * @returns impostor the rope imposter
  76274. */
  76275. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76276. /**
  76277. * Will keep this body still, in a sleep mode.
  76278. * @returns the physics imposter
  76279. */
  76280. sleep(): PhysicsImpostor;
  76281. /**
  76282. * Wake the body up.
  76283. * @returns The physics imposter
  76284. */
  76285. wakeUp(): PhysicsImpostor;
  76286. /**
  76287. * Clones the physics imposter
  76288. * @param newObject The physics imposter clones to this physics-enabled object
  76289. * @returns A nullable physics imposter
  76290. */
  76291. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76292. /**
  76293. * Disposes the physics imposter
  76294. */
  76295. dispose(): void;
  76296. /**
  76297. * Sets the delta position
  76298. * @param position The delta position amount
  76299. */
  76300. setDeltaPosition(position: Vector3): void;
  76301. /**
  76302. * Sets the delta rotation
  76303. * @param rotation The delta rotation amount
  76304. */
  76305. setDeltaRotation(rotation: Quaternion): void;
  76306. /**
  76307. * Gets the box size of the physics imposter and stores the result in the input parameter
  76308. * @param result Stores the box size
  76309. * @returns The physics imposter
  76310. */
  76311. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76312. /**
  76313. * Gets the radius of the physics imposter
  76314. * @returns Radius of the physics imposter
  76315. */
  76316. getRadius(): number;
  76317. /**
  76318. * Sync a bone with this impostor
  76319. * @param bone The bone to sync to the impostor.
  76320. * @param boneMesh The mesh that the bone is influencing.
  76321. * @param jointPivot The pivot of the joint / bone in local space.
  76322. * @param distToJoint Optional distance from the impostor to the joint.
  76323. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76324. */
  76325. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76326. /**
  76327. * Sync impostor to a bone
  76328. * @param bone The bone that the impostor will be synced to.
  76329. * @param boneMesh The mesh that the bone is influencing.
  76330. * @param jointPivot The pivot of the joint / bone in local space.
  76331. * @param distToJoint Optional distance from the impostor to the joint.
  76332. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76333. * @param boneAxis Optional vector3 axis the bone is aligned with
  76334. */
  76335. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76336. /**
  76337. * No-Imposter type
  76338. */
  76339. static NoImpostor: number;
  76340. /**
  76341. * Sphere-Imposter type
  76342. */
  76343. static SphereImpostor: number;
  76344. /**
  76345. * Box-Imposter type
  76346. */
  76347. static BoxImpostor: number;
  76348. /**
  76349. * Plane-Imposter type
  76350. */
  76351. static PlaneImpostor: number;
  76352. /**
  76353. * Mesh-imposter type
  76354. */
  76355. static MeshImpostor: number;
  76356. /**
  76357. * Cylinder-Imposter type
  76358. */
  76359. static CylinderImpostor: number;
  76360. /**
  76361. * Particle-Imposter type
  76362. */
  76363. static ParticleImpostor: number;
  76364. /**
  76365. * Heightmap-Imposter type
  76366. */
  76367. static HeightmapImpostor: number;
  76368. /**
  76369. * ConvexHull-Impostor type (Ammo.js plugin only)
  76370. */
  76371. static ConvexHullImpostor: number;
  76372. /**
  76373. * Rope-Imposter type
  76374. */
  76375. static RopeImpostor: number;
  76376. /**
  76377. * Cloth-Imposter type
  76378. */
  76379. static ClothImpostor: number;
  76380. /**
  76381. * Softbody-Imposter type
  76382. */
  76383. static SoftbodyImpostor: number;
  76384. }
  76385. }
  76386. declare module BABYLON {
  76387. /**
  76388. * @hidden
  76389. **/
  76390. export class _CreationDataStorage {
  76391. closePath?: boolean;
  76392. closeArray?: boolean;
  76393. idx: number[];
  76394. dashSize: number;
  76395. gapSize: number;
  76396. path3D: Path3D;
  76397. pathArray: Vector3[][];
  76398. arc: number;
  76399. radius: number;
  76400. cap: number;
  76401. tessellation: number;
  76402. }
  76403. /**
  76404. * @hidden
  76405. **/
  76406. class _InstanceDataStorage {
  76407. visibleInstances: any;
  76408. batchCache: _InstancesBatch;
  76409. instancesBufferSize: number;
  76410. instancesBuffer: Nullable<Buffer>;
  76411. instancesData: Float32Array;
  76412. overridenInstanceCount: number;
  76413. isFrozen: boolean;
  76414. previousBatch: Nullable<_InstancesBatch>;
  76415. hardwareInstancedRendering: boolean;
  76416. sideOrientation: number;
  76417. }
  76418. /**
  76419. * @hidden
  76420. **/
  76421. export class _InstancesBatch {
  76422. mustReturn: boolean;
  76423. visibleInstances: Nullable<InstancedMesh[]>[];
  76424. renderSelf: boolean[];
  76425. hardwareInstancedRendering: boolean[];
  76426. }
  76427. /**
  76428. * Class used to represent renderable models
  76429. */
  76430. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76431. /**
  76432. * Mesh side orientation : usually the external or front surface
  76433. */
  76434. static readonly FRONTSIDE: number;
  76435. /**
  76436. * Mesh side orientation : usually the internal or back surface
  76437. */
  76438. static readonly BACKSIDE: number;
  76439. /**
  76440. * Mesh side orientation : both internal and external or front and back surfaces
  76441. */
  76442. static readonly DOUBLESIDE: number;
  76443. /**
  76444. * Mesh side orientation : by default, `FRONTSIDE`
  76445. */
  76446. static readonly DEFAULTSIDE: number;
  76447. /**
  76448. * Mesh cap setting : no cap
  76449. */
  76450. static readonly NO_CAP: number;
  76451. /**
  76452. * Mesh cap setting : one cap at the beginning of the mesh
  76453. */
  76454. static readonly CAP_START: number;
  76455. /**
  76456. * Mesh cap setting : one cap at the end of the mesh
  76457. */
  76458. static readonly CAP_END: number;
  76459. /**
  76460. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76461. */
  76462. static readonly CAP_ALL: number;
  76463. /**
  76464. * Mesh pattern setting : no flip or rotate
  76465. */
  76466. static readonly NO_FLIP: number;
  76467. /**
  76468. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76469. */
  76470. static readonly FLIP_TILE: number;
  76471. /**
  76472. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76473. */
  76474. static readonly ROTATE_TILE: number;
  76475. /**
  76476. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76477. */
  76478. static readonly FLIP_ROW: number;
  76479. /**
  76480. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76481. */
  76482. static readonly ROTATE_ROW: number;
  76483. /**
  76484. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76485. */
  76486. static readonly FLIP_N_ROTATE_TILE: number;
  76487. /**
  76488. * Mesh pattern setting : rotate pattern and rotate
  76489. */
  76490. static readonly FLIP_N_ROTATE_ROW: number;
  76491. /**
  76492. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76493. */
  76494. static readonly CENTER: number;
  76495. /**
  76496. * Mesh tile positioning : part tiles on left
  76497. */
  76498. static readonly LEFT: number;
  76499. /**
  76500. * Mesh tile positioning : part tiles on right
  76501. */
  76502. static readonly RIGHT: number;
  76503. /**
  76504. * Mesh tile positioning : part tiles on top
  76505. */
  76506. static readonly TOP: number;
  76507. /**
  76508. * Mesh tile positioning : part tiles on bottom
  76509. */
  76510. static readonly BOTTOM: number;
  76511. /**
  76512. * Gets the default side orientation.
  76513. * @param orientation the orientation to value to attempt to get
  76514. * @returns the default orientation
  76515. * @hidden
  76516. */
  76517. static _GetDefaultSideOrientation(orientation?: number): number;
  76518. private _internalMeshDataInfo;
  76519. /**
  76520. * An event triggered before rendering the mesh
  76521. */
  76522. readonly onBeforeRenderObservable: Observable<Mesh>;
  76523. /**
  76524. * An event triggered before binding the mesh
  76525. */
  76526. readonly onBeforeBindObservable: Observable<Mesh>;
  76527. /**
  76528. * An event triggered after rendering the mesh
  76529. */
  76530. readonly onAfterRenderObservable: Observable<Mesh>;
  76531. /**
  76532. * An event triggered before drawing the mesh
  76533. */
  76534. readonly onBeforeDrawObservable: Observable<Mesh>;
  76535. private _onBeforeDrawObserver;
  76536. /**
  76537. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76538. */
  76539. onBeforeDraw: () => void;
  76540. /**
  76541. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76542. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76543. */
  76544. delayLoadState: number;
  76545. /**
  76546. * Gets the list of instances created from this mesh
  76547. * it is not supposed to be modified manually.
  76548. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76549. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76550. */
  76551. instances: InstancedMesh[];
  76552. /**
  76553. * Gets the file containing delay loading data for this mesh
  76554. */
  76555. delayLoadingFile: string;
  76556. /** @hidden */
  76557. _binaryInfo: any;
  76558. /**
  76559. * User defined function used to change how LOD level selection is done
  76560. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76561. */
  76562. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76563. /**
  76564. * Gets or sets the morph target manager
  76565. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76566. */
  76567. morphTargetManager: Nullable<MorphTargetManager>;
  76568. /** @hidden */
  76569. _creationDataStorage: Nullable<_CreationDataStorage>;
  76570. /** @hidden */
  76571. _geometry: Nullable<Geometry>;
  76572. /** @hidden */
  76573. _delayInfo: Array<string>;
  76574. /** @hidden */
  76575. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76576. /** @hidden */
  76577. _instanceDataStorage: _InstanceDataStorage;
  76578. private _effectiveMaterial;
  76579. /** @hidden */
  76580. _shouldGenerateFlatShading: boolean;
  76581. /** @hidden */
  76582. _originalBuilderSideOrientation: number;
  76583. /**
  76584. * Use this property to change the original side orientation defined at construction time
  76585. */
  76586. overrideMaterialSideOrientation: Nullable<number>;
  76587. /**
  76588. * Gets the source mesh (the one used to clone this one from)
  76589. */
  76590. readonly source: Nullable<Mesh>;
  76591. /**
  76592. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76593. */
  76594. isUnIndexed: boolean;
  76595. /**
  76596. * @constructor
  76597. * @param name The value used by scene.getMeshByName() to do a lookup.
  76598. * @param scene The scene to add this mesh to.
  76599. * @param parent The parent of this mesh, if it has one
  76600. * @param source An optional Mesh from which geometry is shared, cloned.
  76601. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76602. * When false, achieved by calling a clone(), also passing False.
  76603. * This will make creation of children, recursive.
  76604. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76605. */
  76606. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76607. /**
  76608. * Gets the class name
  76609. * @returns the string "Mesh".
  76610. */
  76611. getClassName(): string;
  76612. /** @hidden */
  76613. readonly _isMesh: boolean;
  76614. /**
  76615. * Returns a description of this mesh
  76616. * @param fullDetails define if full details about this mesh must be used
  76617. * @returns a descriptive string representing this mesh
  76618. */
  76619. toString(fullDetails?: boolean): string;
  76620. /** @hidden */
  76621. _unBindEffect(): void;
  76622. /**
  76623. * Gets a boolean indicating if this mesh has LOD
  76624. */
  76625. readonly hasLODLevels: boolean;
  76626. /**
  76627. * Gets the list of MeshLODLevel associated with the current mesh
  76628. * @returns an array of MeshLODLevel
  76629. */
  76630. getLODLevels(): MeshLODLevel[];
  76631. private _sortLODLevels;
  76632. /**
  76633. * Add a mesh as LOD level triggered at the given distance.
  76634. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76635. * @param distance The distance from the center of the object to show this level
  76636. * @param mesh The mesh to be added as LOD level (can be null)
  76637. * @return This mesh (for chaining)
  76638. */
  76639. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76640. /**
  76641. * Returns the LOD level mesh at the passed distance or null if not found.
  76642. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76643. * @param distance The distance from the center of the object to show this level
  76644. * @returns a Mesh or `null`
  76645. */
  76646. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76647. /**
  76648. * Remove a mesh from the LOD array
  76649. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76650. * @param mesh defines the mesh to be removed
  76651. * @return This mesh (for chaining)
  76652. */
  76653. removeLODLevel(mesh: Mesh): Mesh;
  76654. /**
  76655. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76656. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76657. * @param camera defines the camera to use to compute distance
  76658. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76659. * @return This mesh (for chaining)
  76660. */
  76661. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76662. /**
  76663. * Gets the mesh internal Geometry object
  76664. */
  76665. readonly geometry: Nullable<Geometry>;
  76666. /**
  76667. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76668. * @returns the total number of vertices
  76669. */
  76670. getTotalVertices(): number;
  76671. /**
  76672. * Returns the content of an associated vertex buffer
  76673. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76674. * - VertexBuffer.PositionKind
  76675. * - VertexBuffer.UVKind
  76676. * - VertexBuffer.UV2Kind
  76677. * - VertexBuffer.UV3Kind
  76678. * - VertexBuffer.UV4Kind
  76679. * - VertexBuffer.UV5Kind
  76680. * - VertexBuffer.UV6Kind
  76681. * - VertexBuffer.ColorKind
  76682. * - VertexBuffer.MatricesIndicesKind
  76683. * - VertexBuffer.MatricesIndicesExtraKind
  76684. * - VertexBuffer.MatricesWeightsKind
  76685. * - VertexBuffer.MatricesWeightsExtraKind
  76686. * @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
  76687. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76688. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76689. */
  76690. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76691. /**
  76692. * Returns the mesh VertexBuffer object from the requested `kind`
  76693. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76694. * - VertexBuffer.PositionKind
  76695. * - VertexBuffer.NormalKind
  76696. * - VertexBuffer.UVKind
  76697. * - VertexBuffer.UV2Kind
  76698. * - VertexBuffer.UV3Kind
  76699. * - VertexBuffer.UV4Kind
  76700. * - VertexBuffer.UV5Kind
  76701. * - VertexBuffer.UV6Kind
  76702. * - VertexBuffer.ColorKind
  76703. * - VertexBuffer.MatricesIndicesKind
  76704. * - VertexBuffer.MatricesIndicesExtraKind
  76705. * - VertexBuffer.MatricesWeightsKind
  76706. * - VertexBuffer.MatricesWeightsExtraKind
  76707. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76708. */
  76709. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76710. /**
  76711. * Tests if a specific vertex buffer is associated with this mesh
  76712. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76713. * - VertexBuffer.PositionKind
  76714. * - VertexBuffer.NormalKind
  76715. * - VertexBuffer.UVKind
  76716. * - VertexBuffer.UV2Kind
  76717. * - VertexBuffer.UV3Kind
  76718. * - VertexBuffer.UV4Kind
  76719. * - VertexBuffer.UV5Kind
  76720. * - VertexBuffer.UV6Kind
  76721. * - VertexBuffer.ColorKind
  76722. * - VertexBuffer.MatricesIndicesKind
  76723. * - VertexBuffer.MatricesIndicesExtraKind
  76724. * - VertexBuffer.MatricesWeightsKind
  76725. * - VertexBuffer.MatricesWeightsExtraKind
  76726. * @returns a boolean
  76727. */
  76728. isVerticesDataPresent(kind: string): boolean;
  76729. /**
  76730. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  76731. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76732. * - VertexBuffer.PositionKind
  76733. * - VertexBuffer.UVKind
  76734. * - VertexBuffer.UV2Kind
  76735. * - VertexBuffer.UV3Kind
  76736. * - VertexBuffer.UV4Kind
  76737. * - VertexBuffer.UV5Kind
  76738. * - VertexBuffer.UV6Kind
  76739. * - VertexBuffer.ColorKind
  76740. * - VertexBuffer.MatricesIndicesKind
  76741. * - VertexBuffer.MatricesIndicesExtraKind
  76742. * - VertexBuffer.MatricesWeightsKind
  76743. * - VertexBuffer.MatricesWeightsExtraKind
  76744. * @returns a boolean
  76745. */
  76746. isVertexBufferUpdatable(kind: string): boolean;
  76747. /**
  76748. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  76749. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76750. * - VertexBuffer.PositionKind
  76751. * - VertexBuffer.NormalKind
  76752. * - VertexBuffer.UVKind
  76753. * - VertexBuffer.UV2Kind
  76754. * - VertexBuffer.UV3Kind
  76755. * - VertexBuffer.UV4Kind
  76756. * - VertexBuffer.UV5Kind
  76757. * - VertexBuffer.UV6Kind
  76758. * - VertexBuffer.ColorKind
  76759. * - VertexBuffer.MatricesIndicesKind
  76760. * - VertexBuffer.MatricesIndicesExtraKind
  76761. * - VertexBuffer.MatricesWeightsKind
  76762. * - VertexBuffer.MatricesWeightsExtraKind
  76763. * @returns an array of strings
  76764. */
  76765. getVerticesDataKinds(): string[];
  76766. /**
  76767. * Returns a positive integer : the total number of indices in this mesh geometry.
  76768. * @returns the numner of indices or zero if the mesh has no geometry.
  76769. */
  76770. getTotalIndices(): number;
  76771. /**
  76772. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76773. * @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.
  76774. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  76775. * @returns the indices array or an empty array if the mesh has no geometry
  76776. */
  76777. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  76778. readonly isBlocked: boolean;
  76779. /**
  76780. * Determine if the current mesh is ready to be rendered
  76781. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76782. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  76783. * @returns true if all associated assets are ready (material, textures, shaders)
  76784. */
  76785. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  76786. /**
  76787. * 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.
  76788. */
  76789. readonly areNormalsFrozen: boolean;
  76790. /**
  76791. * 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.
  76792. * @returns the current mesh
  76793. */
  76794. freezeNormals(): Mesh;
  76795. /**
  76796. * 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
  76797. * @returns the current mesh
  76798. */
  76799. unfreezeNormals(): Mesh;
  76800. /**
  76801. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  76802. */
  76803. overridenInstanceCount: number;
  76804. /** @hidden */
  76805. _preActivate(): Mesh;
  76806. /** @hidden */
  76807. _preActivateForIntermediateRendering(renderId: number): Mesh;
  76808. /** @hidden */
  76809. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  76810. /**
  76811. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76812. * This means the mesh underlying bounding box and sphere are recomputed.
  76813. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76814. * @returns the current mesh
  76815. */
  76816. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  76817. /** @hidden */
  76818. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  76819. /**
  76820. * This function will subdivide the mesh into multiple submeshes
  76821. * @param count defines the expected number of submeshes
  76822. */
  76823. subdivide(count: number): void;
  76824. /**
  76825. * Copy a FloatArray into a specific associated vertex buffer
  76826. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76827. * - VertexBuffer.PositionKind
  76828. * - VertexBuffer.UVKind
  76829. * - VertexBuffer.UV2Kind
  76830. * - VertexBuffer.UV3Kind
  76831. * - VertexBuffer.UV4Kind
  76832. * - VertexBuffer.UV5Kind
  76833. * - VertexBuffer.UV6Kind
  76834. * - VertexBuffer.ColorKind
  76835. * - VertexBuffer.MatricesIndicesKind
  76836. * - VertexBuffer.MatricesIndicesExtraKind
  76837. * - VertexBuffer.MatricesWeightsKind
  76838. * - VertexBuffer.MatricesWeightsExtraKind
  76839. * @param data defines the data source
  76840. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76841. * @param stride defines the data stride size (can be null)
  76842. * @returns the current mesh
  76843. */
  76844. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76845. /**
  76846. * Flags an associated vertex buffer as updatable
  76847. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  76848. * - VertexBuffer.PositionKind
  76849. * - VertexBuffer.UVKind
  76850. * - VertexBuffer.UV2Kind
  76851. * - VertexBuffer.UV3Kind
  76852. * - VertexBuffer.UV4Kind
  76853. * - VertexBuffer.UV5Kind
  76854. * - VertexBuffer.UV6Kind
  76855. * - VertexBuffer.ColorKind
  76856. * - VertexBuffer.MatricesIndicesKind
  76857. * - VertexBuffer.MatricesIndicesExtraKind
  76858. * - VertexBuffer.MatricesWeightsKind
  76859. * - VertexBuffer.MatricesWeightsExtraKind
  76860. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76861. */
  76862. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  76863. /**
  76864. * Sets the mesh global Vertex Buffer
  76865. * @param buffer defines the buffer to use
  76866. * @returns the current mesh
  76867. */
  76868. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  76869. /**
  76870. * Update a specific associated vertex buffer
  76871. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76872. * - VertexBuffer.PositionKind
  76873. * - VertexBuffer.UVKind
  76874. * - VertexBuffer.UV2Kind
  76875. * - VertexBuffer.UV3Kind
  76876. * - VertexBuffer.UV4Kind
  76877. * - VertexBuffer.UV5Kind
  76878. * - VertexBuffer.UV6Kind
  76879. * - VertexBuffer.ColorKind
  76880. * - VertexBuffer.MatricesIndicesKind
  76881. * - VertexBuffer.MatricesIndicesExtraKind
  76882. * - VertexBuffer.MatricesWeightsKind
  76883. * - VertexBuffer.MatricesWeightsExtraKind
  76884. * @param data defines the data source
  76885. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  76886. * @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)
  76887. * @returns the current mesh
  76888. */
  76889. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76890. /**
  76891. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  76892. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  76893. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  76894. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  76895. * @returns the current mesh
  76896. */
  76897. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  76898. /**
  76899. * Creates a un-shared specific occurence of the geometry for the mesh.
  76900. * @returns the current mesh
  76901. */
  76902. makeGeometryUnique(): Mesh;
  76903. /**
  76904. * Set the index buffer of this mesh
  76905. * @param indices defines the source data
  76906. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  76907. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  76908. * @returns the current mesh
  76909. */
  76910. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  76911. /**
  76912. * Update the current index buffer
  76913. * @param indices defines the source data
  76914. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  76915. * @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)
  76916. * @returns the current mesh
  76917. */
  76918. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  76919. /**
  76920. * Invert the geometry to move from a right handed system to a left handed one.
  76921. * @returns the current mesh
  76922. */
  76923. toLeftHanded(): Mesh;
  76924. /** @hidden */
  76925. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  76926. /** @hidden */
  76927. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  76928. /**
  76929. * Registers for this mesh a javascript function called just before the rendering process
  76930. * @param func defines the function to call before rendering this mesh
  76931. * @returns the current mesh
  76932. */
  76933. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76934. /**
  76935. * Disposes a previously registered javascript function called before the rendering
  76936. * @param func defines the function to remove
  76937. * @returns the current mesh
  76938. */
  76939. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  76940. /**
  76941. * Registers for this mesh a javascript function called just after the rendering is complete
  76942. * @param func defines the function to call after rendering this mesh
  76943. * @returns the current mesh
  76944. */
  76945. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76946. /**
  76947. * Disposes a previously registered javascript function called after the rendering.
  76948. * @param func defines the function to remove
  76949. * @returns the current mesh
  76950. */
  76951. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  76952. /** @hidden */
  76953. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  76954. /** @hidden */
  76955. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  76956. /** @hidden */
  76957. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  76958. /** @hidden */
  76959. _freeze(): void;
  76960. /** @hidden */
  76961. _unFreeze(): void;
  76962. /**
  76963. * 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
  76964. * @param subMesh defines the subMesh to render
  76965. * @param enableAlphaMode defines if alpha mode can be changed
  76966. * @returns the current mesh
  76967. */
  76968. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  76969. private _onBeforeDraw;
  76970. /**
  76971. * Renormalize the mesh and patch it up if there are no weights
  76972. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  76973. * However in the case of zero weights then we set just a single influence to 1.
  76974. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  76975. */
  76976. cleanMatrixWeights(): void;
  76977. private normalizeSkinFourWeights;
  76978. private normalizeSkinWeightsAndExtra;
  76979. /**
  76980. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  76981. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  76982. * the user know there was an issue with importing the mesh
  76983. * @returns a validation object with skinned, valid and report string
  76984. */
  76985. validateSkinning(): {
  76986. skinned: boolean;
  76987. valid: boolean;
  76988. report: string;
  76989. };
  76990. /** @hidden */
  76991. _checkDelayState(): Mesh;
  76992. private _queueLoad;
  76993. /**
  76994. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  76995. * A mesh is in the frustum if its bounding box intersects the frustum
  76996. * @param frustumPlanes defines the frustum to test
  76997. * @returns true if the mesh is in the frustum planes
  76998. */
  76999. isInFrustum(frustumPlanes: Plane[]): boolean;
  77000. /**
  77001. * Sets the mesh material by the material or multiMaterial `id` property
  77002. * @param id is a string identifying the material or the multiMaterial
  77003. * @returns the current mesh
  77004. */
  77005. setMaterialByID(id: string): Mesh;
  77006. /**
  77007. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77008. * @returns an array of IAnimatable
  77009. */
  77010. getAnimatables(): IAnimatable[];
  77011. /**
  77012. * Modifies the mesh geometry according to the passed transformation matrix.
  77013. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77014. * The mesh normals are modified using the same transformation.
  77015. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77016. * @param transform defines the transform matrix to use
  77017. * @see http://doc.babylonjs.com/resources/baking_transformations
  77018. * @returns the current mesh
  77019. */
  77020. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77021. /**
  77022. * Modifies the mesh geometry according to its own current World Matrix.
  77023. * The mesh World Matrix is then reset.
  77024. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77025. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77026. * @see http://doc.babylonjs.com/resources/baking_transformations
  77027. * @returns the current mesh
  77028. */
  77029. bakeCurrentTransformIntoVertices(): Mesh;
  77030. /** @hidden */
  77031. readonly _positions: Nullable<Vector3[]>;
  77032. /** @hidden */
  77033. _resetPointsArrayCache(): Mesh;
  77034. /** @hidden */
  77035. _generatePointsArray(): boolean;
  77036. /**
  77037. * Returns a new Mesh object generated from the current mesh properties.
  77038. * This method must not get confused with createInstance()
  77039. * @param name is a string, the name given to the new mesh
  77040. * @param newParent can be any Node object (default `null`)
  77041. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77042. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77043. * @returns a new mesh
  77044. */
  77045. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77046. /**
  77047. * Releases resources associated with this mesh.
  77048. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77049. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77050. */
  77051. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77052. /**
  77053. * Modifies the mesh geometry according to a displacement map.
  77054. * 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.
  77055. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77056. * @param url is a string, the URL from the image file is to be downloaded.
  77057. * @param minHeight is the lower limit of the displacement.
  77058. * @param maxHeight is the upper limit of the displacement.
  77059. * @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.
  77060. * @param uvOffset is an optional vector2 used to offset UV.
  77061. * @param uvScale is an optional vector2 used to scale UV.
  77062. * @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.
  77063. * @returns the Mesh.
  77064. */
  77065. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77066. /**
  77067. * Modifies the mesh geometry according to a displacementMap buffer.
  77068. * 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.
  77069. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77070. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77071. * @param heightMapWidth is the width of the buffer image.
  77072. * @param heightMapHeight is the height of the buffer image.
  77073. * @param minHeight is the lower limit of the displacement.
  77074. * @param maxHeight is the upper limit of the displacement.
  77075. * @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.
  77076. * @param uvOffset is an optional vector2 used to offset UV.
  77077. * @param uvScale is an optional vector2 used to scale UV.
  77078. * @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.
  77079. * @returns the Mesh.
  77080. */
  77081. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77082. /**
  77083. * Modify the mesh to get a flat shading rendering.
  77084. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77085. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77086. * @returns current mesh
  77087. */
  77088. convertToFlatShadedMesh(): Mesh;
  77089. /**
  77090. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77091. * In other words, more vertices, no more indices and a single bigger VBO.
  77092. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77093. * @returns current mesh
  77094. */
  77095. convertToUnIndexedMesh(): Mesh;
  77096. /**
  77097. * Inverses facet orientations.
  77098. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77099. * @param flipNormals will also inverts the normals
  77100. * @returns current mesh
  77101. */
  77102. flipFaces(flipNormals?: boolean): Mesh;
  77103. /**
  77104. * Increase the number of facets and hence vertices in a mesh
  77105. * Vertex normals are interpolated from existing vertex normals
  77106. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77107. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77108. */
  77109. increaseVertices(numberPerEdge: number): void;
  77110. /**
  77111. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77112. * This will undo any application of covertToFlatShadedMesh
  77113. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77114. */
  77115. forceSharedVertices(): void;
  77116. /** @hidden */
  77117. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77118. /** @hidden */
  77119. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77120. /**
  77121. * Creates a new InstancedMesh object from the mesh model.
  77122. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77123. * @param name defines the name of the new instance
  77124. * @returns a new InstancedMesh
  77125. */
  77126. createInstance(name: string): InstancedMesh;
  77127. /**
  77128. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77129. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77130. * @returns the current mesh
  77131. */
  77132. synchronizeInstances(): Mesh;
  77133. /**
  77134. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77135. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77136. * This should be used together with the simplification to avoid disappearing triangles.
  77137. * @param successCallback an optional success callback to be called after the optimization finished.
  77138. * @returns the current mesh
  77139. */
  77140. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77141. /**
  77142. * Serialize current mesh
  77143. * @param serializationObject defines the object which will receive the serialization data
  77144. */
  77145. serialize(serializationObject: any): void;
  77146. /** @hidden */
  77147. _syncGeometryWithMorphTargetManager(): void;
  77148. /** @hidden */
  77149. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77150. /**
  77151. * Returns a new Mesh object parsed from the source provided.
  77152. * @param parsedMesh is the source
  77153. * @param scene defines the hosting scene
  77154. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77155. * @returns a new Mesh
  77156. */
  77157. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77158. /**
  77159. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77160. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77161. * @param name defines the name of the mesh to create
  77162. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77163. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77164. * @param closePath creates a seam between the first and the last points of each path of the path array
  77165. * @param offset is taken in account only if the `pathArray` is containing a single path
  77166. * @param scene defines the hosting scene
  77167. * @param updatable defines if the mesh must be flagged as updatable
  77168. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77169. * @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)
  77170. * @returns a new Mesh
  77171. */
  77172. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77173. /**
  77174. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77175. * @param name defines the name of the mesh to create
  77176. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77177. * @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
  77178. * @param scene defines the hosting scene
  77179. * @param updatable defines if the mesh must be flagged as updatable
  77180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77181. * @returns a new Mesh
  77182. */
  77183. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77184. /**
  77185. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77186. * @param name defines the name of the mesh to create
  77187. * @param size sets the size (float) of each box side (default 1)
  77188. * @param scene defines the hosting scene
  77189. * @param updatable defines if the mesh must be flagged as updatable
  77190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77191. * @returns a new Mesh
  77192. */
  77193. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77194. /**
  77195. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77196. * @param name defines the name of the mesh to create
  77197. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77198. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77199. * @param scene defines the hosting scene
  77200. * @param updatable defines if the mesh must be flagged as updatable
  77201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77202. * @returns a new Mesh
  77203. */
  77204. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77205. /**
  77206. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77207. * @param name defines the name of the mesh to create
  77208. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77209. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77210. * @param scene defines the hosting scene
  77211. * @returns a new Mesh
  77212. */
  77213. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77214. /**
  77215. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77216. * @param name defines the name of the mesh to create
  77217. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77218. * @param diameterTop set the top cap diameter (floats, default 1)
  77219. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77220. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77221. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77222. * @param scene defines the hosting scene
  77223. * @param updatable defines if the mesh must be flagged as updatable
  77224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77225. * @returns a new Mesh
  77226. */
  77227. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77228. /**
  77229. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77230. * @param name defines the name of the mesh to create
  77231. * @param diameter sets the diameter size (float) of the torus (default 1)
  77232. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77233. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77234. * @param scene defines the hosting scene
  77235. * @param updatable defines if the mesh must be flagged as updatable
  77236. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77237. * @returns a new Mesh
  77238. */
  77239. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77240. /**
  77241. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77242. * @param name defines the name of the mesh to create
  77243. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77244. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77245. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77246. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77247. * @param p the number of windings on X axis (positive integers, default 2)
  77248. * @param q the number of windings on Y axis (positive integers, default 3)
  77249. * @param scene defines the hosting scene
  77250. * @param updatable defines if the mesh must be flagged as updatable
  77251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77252. * @returns a new Mesh
  77253. */
  77254. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77255. /**
  77256. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77257. * @param name defines the name of the mesh to create
  77258. * @param points is an array successive Vector3
  77259. * @param scene defines the hosting scene
  77260. * @param updatable defines if the mesh must be flagged as updatable
  77261. * @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).
  77262. * @returns a new Mesh
  77263. */
  77264. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77265. /**
  77266. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77267. * @param name defines the name of the mesh to create
  77268. * @param points is an array successive Vector3
  77269. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77270. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77271. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77272. * @param scene defines the hosting scene
  77273. * @param updatable defines if the mesh must be flagged as updatable
  77274. * @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)
  77275. * @returns a new Mesh
  77276. */
  77277. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77278. /**
  77279. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77280. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77281. * 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.
  77282. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77283. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77284. * Remember you can only change the shape positions, not their number when updating a polygon.
  77285. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77286. * @param name defines the name of the mesh to create
  77287. * @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
  77288. * @param scene defines the hosting scene
  77289. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77290. * @param updatable defines if the mesh must be flagged as updatable
  77291. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77292. * @param earcutInjection can be used to inject your own earcut reference
  77293. * @returns a new Mesh
  77294. */
  77295. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77296. /**
  77297. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77298. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77299. * @param name defines the name of the mesh to create
  77300. * @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
  77301. * @param depth defines the height of extrusion
  77302. * @param scene defines the hosting scene
  77303. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77304. * @param updatable defines if the mesh must be flagged as updatable
  77305. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77306. * @param earcutInjection can be used to inject your own earcut reference
  77307. * @returns a new Mesh
  77308. */
  77309. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77310. /**
  77311. * Creates an extruded shape mesh.
  77312. * 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
  77313. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77314. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77315. * @param name defines the name of the mesh to create
  77316. * @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
  77317. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77318. * @param scale is the value to scale the shape
  77319. * @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
  77320. * @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
  77321. * @param scene defines the hosting scene
  77322. * @param updatable defines if the mesh must be flagged as updatable
  77323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77324. * @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)
  77325. * @returns a new Mesh
  77326. */
  77327. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77328. /**
  77329. * Creates an custom extruded shape mesh.
  77330. * The custom extrusion is a parametric shape.
  77331. * It has no predefined shape. Its final shape will depend on the input parameters.
  77332. * Please consider using the same method from the MeshBuilder class instead
  77333. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77334. * @param name defines the name of the mesh to create
  77335. * @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
  77336. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77337. * @param scaleFunction is a custom Javascript function called on each path point
  77338. * @param rotationFunction is a custom Javascript function called on each path point
  77339. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77340. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77341. * @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
  77342. * @param scene defines the hosting scene
  77343. * @param updatable defines if the mesh must be flagged as updatable
  77344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77345. * @param 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)
  77346. * @returns a new Mesh
  77347. */
  77348. 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;
  77349. /**
  77350. * Creates lathe mesh.
  77351. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77352. * Please consider using the same method from the MeshBuilder class instead
  77353. * @param name defines the name of the mesh to create
  77354. * @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
  77355. * @param radius is the radius value of the lathe
  77356. * @param tessellation is the side number of the lathe.
  77357. * @param scene defines the hosting scene
  77358. * @param updatable defines if the mesh must be flagged as updatable
  77359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77360. * @returns a new Mesh
  77361. */
  77362. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77363. /**
  77364. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77365. * @param name defines the name of the mesh to create
  77366. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77367. * @param scene defines the hosting scene
  77368. * @param updatable defines if the mesh must be flagged as updatable
  77369. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77370. * @returns a new Mesh
  77371. */
  77372. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77373. /**
  77374. * Creates a ground mesh.
  77375. * Please consider using the same method from the MeshBuilder class instead
  77376. * @param name defines the name of the mesh to create
  77377. * @param width set the width of the ground
  77378. * @param height set the height of the ground
  77379. * @param subdivisions sets the number of subdivisions per side
  77380. * @param scene defines the hosting scene
  77381. * @param updatable defines if the mesh must be flagged as updatable
  77382. * @returns a new Mesh
  77383. */
  77384. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77385. /**
  77386. * Creates a tiled ground mesh.
  77387. * Please consider using the same method from the MeshBuilder class instead
  77388. * @param name defines the name of the mesh to create
  77389. * @param xmin set the ground minimum X coordinate
  77390. * @param zmin set the ground minimum Y coordinate
  77391. * @param xmax set the ground maximum X coordinate
  77392. * @param zmax set the ground maximum Z coordinate
  77393. * @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
  77394. * @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
  77395. * @param scene defines the hosting scene
  77396. * @param updatable defines if the mesh must be flagged as updatable
  77397. * @returns a new Mesh
  77398. */
  77399. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77400. w: number;
  77401. h: number;
  77402. }, precision: {
  77403. w: number;
  77404. h: number;
  77405. }, scene: Scene, updatable?: boolean): Mesh;
  77406. /**
  77407. * Creates a ground mesh from a height map.
  77408. * Please consider using the same method from the MeshBuilder class instead
  77409. * @see http://doc.babylonjs.com/babylon101/height_map
  77410. * @param name defines the name of the mesh to create
  77411. * @param url sets the URL of the height map image resource
  77412. * @param width set the ground width size
  77413. * @param height set the ground height size
  77414. * @param subdivisions sets the number of subdivision per side
  77415. * @param minHeight is the minimum altitude on the ground
  77416. * @param maxHeight is the maximum altitude on the ground
  77417. * @param scene defines the hosting scene
  77418. * @param updatable defines if the mesh must be flagged as updatable
  77419. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77420. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77421. * @returns a new Mesh
  77422. */
  77423. 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;
  77424. /**
  77425. * Creates a tube mesh.
  77426. * The tube is a parametric shape.
  77427. * It has no predefined shape. Its final shape will depend on the input parameters.
  77428. * Please consider using the same method from the MeshBuilder class instead
  77429. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77430. * @param name defines the name of the mesh to create
  77431. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77432. * @param radius sets the tube radius size
  77433. * @param tessellation is the number of sides on the tubular surface
  77434. * @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
  77435. * @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
  77436. * @param scene defines the hosting scene
  77437. * @param updatable defines if the mesh must be flagged as updatable
  77438. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77439. * @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)
  77440. * @returns a new Mesh
  77441. */
  77442. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77443. (i: number, distance: number): number;
  77444. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77445. /**
  77446. * Creates a polyhedron mesh.
  77447. * Please consider using the same method from the MeshBuilder class instead.
  77448. * * 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
  77449. * * The parameter `size` (positive float, default 1) sets the polygon size
  77450. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77451. * * 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`
  77452. * * 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
  77453. * * 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)`)
  77454. * * 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
  77455. * * 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
  77456. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77457. * * If you create a double-sided mesh, you can choose what parts of 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
  77458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77459. * @param name defines the name of the mesh to create
  77460. * @param options defines the options used to create the mesh
  77461. * @param scene defines the hosting scene
  77462. * @returns a new Mesh
  77463. */
  77464. static CreatePolyhedron(name: string, options: {
  77465. type?: number;
  77466. size?: number;
  77467. sizeX?: number;
  77468. sizeY?: number;
  77469. sizeZ?: number;
  77470. custom?: any;
  77471. faceUV?: Vector4[];
  77472. faceColors?: Color4[];
  77473. updatable?: boolean;
  77474. sideOrientation?: number;
  77475. }, scene: Scene): Mesh;
  77476. /**
  77477. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77478. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77479. * * 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`)
  77480. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77481. * * 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
  77482. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77483. * * If you create a double-sided mesh, you can choose what parts of 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
  77484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77485. * @param name defines the name of the mesh
  77486. * @param options defines the options used to create the mesh
  77487. * @param scene defines the hosting scene
  77488. * @returns a new Mesh
  77489. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77490. */
  77491. static CreateIcoSphere(name: string, options: {
  77492. radius?: number;
  77493. flat?: boolean;
  77494. subdivisions?: number;
  77495. sideOrientation?: number;
  77496. updatable?: boolean;
  77497. }, scene: Scene): Mesh;
  77498. /**
  77499. * Creates a decal mesh.
  77500. * Please consider using the same method from the MeshBuilder class instead.
  77501. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77502. * @param name defines the name of the mesh
  77503. * @param sourceMesh defines the mesh receiving the decal
  77504. * @param position sets the position of the decal in world coordinates
  77505. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77506. * @param size sets the decal scaling
  77507. * @param angle sets the angle to rotate the decal
  77508. * @returns a new Mesh
  77509. */
  77510. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77511. /**
  77512. * Prepare internal position array for software CPU skinning
  77513. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77514. */
  77515. setPositionsForCPUSkinning(): Float32Array;
  77516. /**
  77517. * Prepare internal normal array for software CPU skinning
  77518. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77519. */
  77520. setNormalsForCPUSkinning(): Float32Array;
  77521. /**
  77522. * Updates the vertex buffer by applying transformation from the bones
  77523. * @param skeleton defines the skeleton to apply to current mesh
  77524. * @returns the current mesh
  77525. */
  77526. applySkeleton(skeleton: Skeleton): Mesh;
  77527. /**
  77528. * 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
  77529. * @param meshes defines the list of meshes to scan
  77530. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77531. */
  77532. static MinMax(meshes: AbstractMesh[]): {
  77533. min: Vector3;
  77534. max: Vector3;
  77535. };
  77536. /**
  77537. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77538. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77539. * @returns a vector3
  77540. */
  77541. static Center(meshesOrMinMaxVector: {
  77542. min: Vector3;
  77543. max: Vector3;
  77544. } | AbstractMesh[]): Vector3;
  77545. /**
  77546. * Merge the array of meshes into a single mesh for performance reasons.
  77547. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77548. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77549. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77550. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77551. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77552. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77553. * @returns a new mesh
  77554. */
  77555. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77556. /** @hidden */
  77557. addInstance(instance: InstancedMesh): void;
  77558. /** @hidden */
  77559. removeInstance(instance: InstancedMesh): void;
  77560. }
  77561. }
  77562. declare module BABYLON {
  77563. /**
  77564. * Interface used to define Action
  77565. */
  77566. export interface IAction {
  77567. /**
  77568. * Trigger for the action
  77569. */
  77570. trigger: number;
  77571. /** Options of the trigger */
  77572. triggerOptions: any;
  77573. /**
  77574. * Gets the trigger parameters
  77575. * @returns the trigger parameters
  77576. */
  77577. getTriggerParameter(): any;
  77578. /**
  77579. * Internal only - executes current action event
  77580. * @hidden
  77581. */
  77582. _executeCurrent(evt?: ActionEvent): void;
  77583. /**
  77584. * Serialize placeholder for child classes
  77585. * @param parent of child
  77586. * @returns the serialized object
  77587. */
  77588. serialize(parent: any): any;
  77589. /**
  77590. * Internal only
  77591. * @hidden
  77592. */
  77593. _prepare(): void;
  77594. /**
  77595. * Internal only - manager for action
  77596. * @hidden
  77597. */
  77598. _actionManager: AbstractActionManager;
  77599. /**
  77600. * Adds action to chain of actions, may be a DoNothingAction
  77601. * @param action defines the next action to execute
  77602. * @returns The action passed in
  77603. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77604. */
  77605. then(action: IAction): IAction;
  77606. }
  77607. /**
  77608. * The action to be carried out following a trigger
  77609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77610. */
  77611. export class Action implements IAction {
  77612. /** the trigger, with or without parameters, for the action */
  77613. triggerOptions: any;
  77614. /**
  77615. * Trigger for the action
  77616. */
  77617. trigger: number;
  77618. /**
  77619. * Internal only - manager for action
  77620. * @hidden
  77621. */
  77622. _actionManager: ActionManager;
  77623. private _nextActiveAction;
  77624. private _child;
  77625. private _condition?;
  77626. private _triggerParameter;
  77627. /**
  77628. * An event triggered prior to action being executed.
  77629. */
  77630. onBeforeExecuteObservable: Observable<Action>;
  77631. /**
  77632. * Creates a new Action
  77633. * @param triggerOptions the trigger, with or without parameters, for the action
  77634. * @param condition an optional determinant of action
  77635. */
  77636. constructor(
  77637. /** the trigger, with or without parameters, for the action */
  77638. triggerOptions: any, condition?: Condition);
  77639. /**
  77640. * Internal only
  77641. * @hidden
  77642. */
  77643. _prepare(): void;
  77644. /**
  77645. * Gets the trigger parameters
  77646. * @returns the trigger parameters
  77647. */
  77648. getTriggerParameter(): any;
  77649. /**
  77650. * Internal only - executes current action event
  77651. * @hidden
  77652. */
  77653. _executeCurrent(evt?: ActionEvent): void;
  77654. /**
  77655. * Execute placeholder for child classes
  77656. * @param evt optional action event
  77657. */
  77658. execute(evt?: ActionEvent): void;
  77659. /**
  77660. * Skips to next active action
  77661. */
  77662. skipToNextActiveAction(): void;
  77663. /**
  77664. * Adds action to chain of actions, may be a DoNothingAction
  77665. * @param action defines the next action to execute
  77666. * @returns The action passed in
  77667. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77668. */
  77669. then(action: Action): Action;
  77670. /**
  77671. * Internal only
  77672. * @hidden
  77673. */
  77674. _getProperty(propertyPath: string): string;
  77675. /**
  77676. * Internal only
  77677. * @hidden
  77678. */
  77679. _getEffectiveTarget(target: any, propertyPath: string): any;
  77680. /**
  77681. * Serialize placeholder for child classes
  77682. * @param parent of child
  77683. * @returns the serialized object
  77684. */
  77685. serialize(parent: any): any;
  77686. /**
  77687. * Internal only called by serialize
  77688. * @hidden
  77689. */
  77690. protected _serialize(serializedAction: any, parent?: any): any;
  77691. /**
  77692. * Internal only
  77693. * @hidden
  77694. */
  77695. static _SerializeValueAsString: (value: any) => string;
  77696. /**
  77697. * Internal only
  77698. * @hidden
  77699. */
  77700. static _GetTargetProperty: (target: Scene | Node) => {
  77701. name: string;
  77702. targetType: string;
  77703. value: string;
  77704. };
  77705. }
  77706. }
  77707. declare module BABYLON {
  77708. /**
  77709. * A Condition applied to an Action
  77710. */
  77711. export class Condition {
  77712. /**
  77713. * Internal only - manager for action
  77714. * @hidden
  77715. */
  77716. _actionManager: ActionManager;
  77717. /**
  77718. * Internal only
  77719. * @hidden
  77720. */
  77721. _evaluationId: number;
  77722. /**
  77723. * Internal only
  77724. * @hidden
  77725. */
  77726. _currentResult: boolean;
  77727. /**
  77728. * Creates a new Condition
  77729. * @param actionManager the manager of the action the condition is applied to
  77730. */
  77731. constructor(actionManager: ActionManager);
  77732. /**
  77733. * Check if the current condition is valid
  77734. * @returns a boolean
  77735. */
  77736. isValid(): boolean;
  77737. /**
  77738. * Internal only
  77739. * @hidden
  77740. */
  77741. _getProperty(propertyPath: string): string;
  77742. /**
  77743. * Internal only
  77744. * @hidden
  77745. */
  77746. _getEffectiveTarget(target: any, propertyPath: string): any;
  77747. /**
  77748. * Serialize placeholder for child classes
  77749. * @returns the serialized object
  77750. */
  77751. serialize(): any;
  77752. /**
  77753. * Internal only
  77754. * @hidden
  77755. */
  77756. protected _serialize(serializedCondition: any): any;
  77757. }
  77758. /**
  77759. * Defines specific conditional operators as extensions of Condition
  77760. */
  77761. export class ValueCondition extends Condition {
  77762. /** path to specify the property of the target the conditional operator uses */
  77763. propertyPath: string;
  77764. /** the value compared by the conditional operator against the current value of the property */
  77765. value: any;
  77766. /** the conditional operator, default ValueCondition.IsEqual */
  77767. operator: number;
  77768. /**
  77769. * Internal only
  77770. * @hidden
  77771. */
  77772. private static _IsEqual;
  77773. /**
  77774. * Internal only
  77775. * @hidden
  77776. */
  77777. private static _IsDifferent;
  77778. /**
  77779. * Internal only
  77780. * @hidden
  77781. */
  77782. private static _IsGreater;
  77783. /**
  77784. * Internal only
  77785. * @hidden
  77786. */
  77787. private static _IsLesser;
  77788. /**
  77789. * returns the number for IsEqual
  77790. */
  77791. static readonly IsEqual: number;
  77792. /**
  77793. * Returns the number for IsDifferent
  77794. */
  77795. static readonly IsDifferent: number;
  77796. /**
  77797. * Returns the number for IsGreater
  77798. */
  77799. static readonly IsGreater: number;
  77800. /**
  77801. * Returns the number for IsLesser
  77802. */
  77803. static readonly IsLesser: number;
  77804. /**
  77805. * Internal only The action manager for the condition
  77806. * @hidden
  77807. */
  77808. _actionManager: ActionManager;
  77809. /**
  77810. * Internal only
  77811. * @hidden
  77812. */
  77813. private _target;
  77814. /**
  77815. * Internal only
  77816. * @hidden
  77817. */
  77818. private _effectiveTarget;
  77819. /**
  77820. * Internal only
  77821. * @hidden
  77822. */
  77823. private _property;
  77824. /**
  77825. * Creates a new ValueCondition
  77826. * @param actionManager manager for the action the condition applies to
  77827. * @param target for the action
  77828. * @param propertyPath path to specify the property of the target the conditional operator uses
  77829. * @param value the value compared by the conditional operator against the current value of the property
  77830. * @param operator the conditional operator, default ValueCondition.IsEqual
  77831. */
  77832. constructor(actionManager: ActionManager, target: any,
  77833. /** path to specify the property of the target the conditional operator uses */
  77834. propertyPath: string,
  77835. /** the value compared by the conditional operator against the current value of the property */
  77836. value: any,
  77837. /** the conditional operator, default ValueCondition.IsEqual */
  77838. operator?: number);
  77839. /**
  77840. * Compares the given value with the property value for the specified conditional operator
  77841. * @returns the result of the comparison
  77842. */
  77843. isValid(): boolean;
  77844. /**
  77845. * Serialize the ValueCondition into a JSON compatible object
  77846. * @returns serialization object
  77847. */
  77848. serialize(): any;
  77849. /**
  77850. * Gets the name of the conditional operator for the ValueCondition
  77851. * @param operator the conditional operator
  77852. * @returns the name
  77853. */
  77854. static GetOperatorName(operator: number): string;
  77855. }
  77856. /**
  77857. * Defines a predicate condition as an extension of Condition
  77858. */
  77859. export class PredicateCondition extends Condition {
  77860. /** defines the predicate function used to validate the condition */
  77861. predicate: () => boolean;
  77862. /**
  77863. * Internal only - manager for action
  77864. * @hidden
  77865. */
  77866. _actionManager: ActionManager;
  77867. /**
  77868. * Creates a new PredicateCondition
  77869. * @param actionManager manager for the action the condition applies to
  77870. * @param predicate defines the predicate function used to validate the condition
  77871. */
  77872. constructor(actionManager: ActionManager,
  77873. /** defines the predicate function used to validate the condition */
  77874. predicate: () => boolean);
  77875. /**
  77876. * @returns the validity of the predicate condition
  77877. */
  77878. isValid(): boolean;
  77879. }
  77880. /**
  77881. * Defines a state condition as an extension of Condition
  77882. */
  77883. export class StateCondition extends Condition {
  77884. /** Value to compare with target state */
  77885. value: string;
  77886. /**
  77887. * Internal only - manager for action
  77888. * @hidden
  77889. */
  77890. _actionManager: ActionManager;
  77891. /**
  77892. * Internal only
  77893. * @hidden
  77894. */
  77895. private _target;
  77896. /**
  77897. * Creates a new StateCondition
  77898. * @param actionManager manager for the action the condition applies to
  77899. * @param target of the condition
  77900. * @param value to compare with target state
  77901. */
  77902. constructor(actionManager: ActionManager, target: any,
  77903. /** Value to compare with target state */
  77904. value: string);
  77905. /**
  77906. * Gets a boolean indicating if the current condition is met
  77907. * @returns the validity of the state
  77908. */
  77909. isValid(): boolean;
  77910. /**
  77911. * Serialize the StateCondition into a JSON compatible object
  77912. * @returns serialization object
  77913. */
  77914. serialize(): any;
  77915. }
  77916. }
  77917. declare module BABYLON {
  77918. /**
  77919. * This defines an action responsible to toggle a boolean once triggered.
  77920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77921. */
  77922. export class SwitchBooleanAction extends Action {
  77923. /**
  77924. * The path to the boolean property in the target object
  77925. */
  77926. propertyPath: string;
  77927. private _target;
  77928. private _effectiveTarget;
  77929. private _property;
  77930. /**
  77931. * Instantiate the action
  77932. * @param triggerOptions defines the trigger options
  77933. * @param target defines the object containing the boolean
  77934. * @param propertyPath defines the path to the boolean property in the target object
  77935. * @param condition defines the trigger related conditions
  77936. */
  77937. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77938. /** @hidden */
  77939. _prepare(): void;
  77940. /**
  77941. * Execute the action toggle the boolean value.
  77942. */
  77943. execute(): void;
  77944. /**
  77945. * Serializes the actions and its related information.
  77946. * @param parent defines the object to serialize in
  77947. * @returns the serialized object
  77948. */
  77949. serialize(parent: any): any;
  77950. }
  77951. /**
  77952. * This defines an action responsible to set a the state field of the target
  77953. * to a desired value once triggered.
  77954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77955. */
  77956. export class SetStateAction extends Action {
  77957. /**
  77958. * The value to store in the state field.
  77959. */
  77960. value: string;
  77961. private _target;
  77962. /**
  77963. * Instantiate the action
  77964. * @param triggerOptions defines the trigger options
  77965. * @param target defines the object containing the state property
  77966. * @param value defines the value to store in the state field
  77967. * @param condition defines the trigger related conditions
  77968. */
  77969. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77970. /**
  77971. * Execute the action and store the value on the target state property.
  77972. */
  77973. execute(): void;
  77974. /**
  77975. * Serializes the actions and its related information.
  77976. * @param parent defines the object to serialize in
  77977. * @returns the serialized object
  77978. */
  77979. serialize(parent: any): any;
  77980. }
  77981. /**
  77982. * This defines an action responsible to set a property of the target
  77983. * to a desired value once triggered.
  77984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77985. */
  77986. export class SetValueAction extends Action {
  77987. /**
  77988. * The path of the property to set in the target.
  77989. */
  77990. propertyPath: string;
  77991. /**
  77992. * The value to set in the property
  77993. */
  77994. value: any;
  77995. private _target;
  77996. private _effectiveTarget;
  77997. private _property;
  77998. /**
  77999. * Instantiate the action
  78000. * @param triggerOptions defines the trigger options
  78001. * @param target defines the object containing the property
  78002. * @param propertyPath defines the path of the property to set in the target
  78003. * @param value defines the value to set in the property
  78004. * @param condition defines the trigger related conditions
  78005. */
  78006. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78007. /** @hidden */
  78008. _prepare(): void;
  78009. /**
  78010. * Execute the action and set the targetted property to the desired value.
  78011. */
  78012. execute(): void;
  78013. /**
  78014. * Serializes the actions and its related information.
  78015. * @param parent defines the object to serialize in
  78016. * @returns the serialized object
  78017. */
  78018. serialize(parent: any): any;
  78019. }
  78020. /**
  78021. * This defines an action responsible to increment the target value
  78022. * to a desired value once triggered.
  78023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78024. */
  78025. export class IncrementValueAction extends Action {
  78026. /**
  78027. * The path of the property to increment in the target.
  78028. */
  78029. propertyPath: string;
  78030. /**
  78031. * The value we should increment the property by.
  78032. */
  78033. value: any;
  78034. private _target;
  78035. private _effectiveTarget;
  78036. private _property;
  78037. /**
  78038. * Instantiate the action
  78039. * @param triggerOptions defines the trigger options
  78040. * @param target defines the object containing the property
  78041. * @param propertyPath defines the path of the property to increment in the target
  78042. * @param value defines the value value we should increment the property by
  78043. * @param condition defines the trigger related conditions
  78044. */
  78045. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78046. /** @hidden */
  78047. _prepare(): void;
  78048. /**
  78049. * Execute the action and increment the target of the value amount.
  78050. */
  78051. execute(): void;
  78052. /**
  78053. * Serializes the actions and its related information.
  78054. * @param parent defines the object to serialize in
  78055. * @returns the serialized object
  78056. */
  78057. serialize(parent: any): any;
  78058. }
  78059. /**
  78060. * This defines an action responsible to start an animation once triggered.
  78061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78062. */
  78063. export class PlayAnimationAction extends Action {
  78064. /**
  78065. * Where the animation should start (animation frame)
  78066. */
  78067. from: number;
  78068. /**
  78069. * Where the animation should stop (animation frame)
  78070. */
  78071. to: number;
  78072. /**
  78073. * Define if the animation should loop or stop after the first play.
  78074. */
  78075. loop?: boolean;
  78076. private _target;
  78077. /**
  78078. * Instantiate the action
  78079. * @param triggerOptions defines the trigger options
  78080. * @param target defines the target animation or animation name
  78081. * @param from defines from where the animation should start (animation frame)
  78082. * @param end defines where the animation should stop (animation frame)
  78083. * @param loop defines if the animation should loop or stop after the first play
  78084. * @param condition defines the trigger related conditions
  78085. */
  78086. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78087. /** @hidden */
  78088. _prepare(): void;
  78089. /**
  78090. * Execute the action and play the animation.
  78091. */
  78092. execute(): void;
  78093. /**
  78094. * Serializes the actions and its related information.
  78095. * @param parent defines the object to serialize in
  78096. * @returns the serialized object
  78097. */
  78098. serialize(parent: any): any;
  78099. }
  78100. /**
  78101. * This defines an action responsible to stop an animation once triggered.
  78102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78103. */
  78104. export class StopAnimationAction extends Action {
  78105. private _target;
  78106. /**
  78107. * Instantiate the action
  78108. * @param triggerOptions defines the trigger options
  78109. * @param target defines the target animation or animation name
  78110. * @param condition defines the trigger related conditions
  78111. */
  78112. constructor(triggerOptions: any, target: any, condition?: Condition);
  78113. /** @hidden */
  78114. _prepare(): void;
  78115. /**
  78116. * Execute the action and stop the animation.
  78117. */
  78118. execute(): void;
  78119. /**
  78120. * Serializes the actions and its related information.
  78121. * @param parent defines the object to serialize in
  78122. * @returns the serialized object
  78123. */
  78124. serialize(parent: any): any;
  78125. }
  78126. /**
  78127. * This defines an action responsible that does nothing once triggered.
  78128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78129. */
  78130. export class DoNothingAction extends Action {
  78131. /**
  78132. * Instantiate the action
  78133. * @param triggerOptions defines the trigger options
  78134. * @param condition defines the trigger related conditions
  78135. */
  78136. constructor(triggerOptions?: any, condition?: Condition);
  78137. /**
  78138. * Execute the action and do nothing.
  78139. */
  78140. execute(): void;
  78141. /**
  78142. * Serializes the actions and its related information.
  78143. * @param parent defines the object to serialize in
  78144. * @returns the serialized object
  78145. */
  78146. serialize(parent: any): any;
  78147. }
  78148. /**
  78149. * This defines an action responsible to trigger several actions once triggered.
  78150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78151. */
  78152. export class CombineAction extends Action {
  78153. /**
  78154. * The list of aggregated animations to run.
  78155. */
  78156. children: Action[];
  78157. /**
  78158. * Instantiate the action
  78159. * @param triggerOptions defines the trigger options
  78160. * @param children defines the list of aggregated animations to run
  78161. * @param condition defines the trigger related conditions
  78162. */
  78163. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78164. /** @hidden */
  78165. _prepare(): void;
  78166. /**
  78167. * Execute the action and executes all the aggregated actions.
  78168. */
  78169. execute(evt: ActionEvent): void;
  78170. /**
  78171. * Serializes the actions and its related information.
  78172. * @param parent defines the object to serialize in
  78173. * @returns the serialized object
  78174. */
  78175. serialize(parent: any): any;
  78176. }
  78177. /**
  78178. * This defines an action responsible to run code (external event) once triggered.
  78179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78180. */
  78181. export class ExecuteCodeAction extends Action {
  78182. /**
  78183. * The callback function to run.
  78184. */
  78185. func: (evt: ActionEvent) => void;
  78186. /**
  78187. * Instantiate the action
  78188. * @param triggerOptions defines the trigger options
  78189. * @param func defines the callback function to run
  78190. * @param condition defines the trigger related conditions
  78191. */
  78192. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78193. /**
  78194. * Execute the action and run the attached code.
  78195. */
  78196. execute(evt: ActionEvent): void;
  78197. }
  78198. /**
  78199. * This defines an action responsible to set the parent property of the target once triggered.
  78200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78201. */
  78202. export class SetParentAction extends Action {
  78203. private _parent;
  78204. private _target;
  78205. /**
  78206. * Instantiate the action
  78207. * @param triggerOptions defines the trigger options
  78208. * @param target defines the target containing the parent property
  78209. * @param parent defines from where the animation should start (animation frame)
  78210. * @param condition defines the trigger related conditions
  78211. */
  78212. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78213. /** @hidden */
  78214. _prepare(): void;
  78215. /**
  78216. * Execute the action and set the parent property.
  78217. */
  78218. execute(): void;
  78219. /**
  78220. * Serializes the actions and its related information.
  78221. * @param parent defines the object to serialize in
  78222. * @returns the serialized object
  78223. */
  78224. serialize(parent: any): any;
  78225. }
  78226. }
  78227. declare module BABYLON {
  78228. /**
  78229. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78230. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78232. */
  78233. export class ActionManager extends AbstractActionManager {
  78234. /**
  78235. * Nothing
  78236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78237. */
  78238. static readonly NothingTrigger: number;
  78239. /**
  78240. * On pick
  78241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78242. */
  78243. static readonly OnPickTrigger: number;
  78244. /**
  78245. * On left pick
  78246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78247. */
  78248. static readonly OnLeftPickTrigger: number;
  78249. /**
  78250. * On right pick
  78251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78252. */
  78253. static readonly OnRightPickTrigger: number;
  78254. /**
  78255. * On center pick
  78256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78257. */
  78258. static readonly OnCenterPickTrigger: number;
  78259. /**
  78260. * On pick down
  78261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78262. */
  78263. static readonly OnPickDownTrigger: number;
  78264. /**
  78265. * On double pick
  78266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78267. */
  78268. static readonly OnDoublePickTrigger: number;
  78269. /**
  78270. * On pick up
  78271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78272. */
  78273. static readonly OnPickUpTrigger: number;
  78274. /**
  78275. * On pick out.
  78276. * This trigger will only be raised if you also declared a OnPickDown
  78277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78278. */
  78279. static readonly OnPickOutTrigger: number;
  78280. /**
  78281. * On long press
  78282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78283. */
  78284. static readonly OnLongPressTrigger: number;
  78285. /**
  78286. * On pointer over
  78287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78288. */
  78289. static readonly OnPointerOverTrigger: number;
  78290. /**
  78291. * On pointer out
  78292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78293. */
  78294. static readonly OnPointerOutTrigger: number;
  78295. /**
  78296. * On every frame
  78297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78298. */
  78299. static readonly OnEveryFrameTrigger: number;
  78300. /**
  78301. * On intersection enter
  78302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78303. */
  78304. static readonly OnIntersectionEnterTrigger: number;
  78305. /**
  78306. * On intersection exit
  78307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78308. */
  78309. static readonly OnIntersectionExitTrigger: number;
  78310. /**
  78311. * On key down
  78312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78313. */
  78314. static readonly OnKeyDownTrigger: number;
  78315. /**
  78316. * On key up
  78317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78318. */
  78319. static readonly OnKeyUpTrigger: number;
  78320. private _scene;
  78321. /**
  78322. * Creates a new action manager
  78323. * @param scene defines the hosting scene
  78324. */
  78325. constructor(scene: Scene);
  78326. /**
  78327. * Releases all associated resources
  78328. */
  78329. dispose(): void;
  78330. /**
  78331. * Gets hosting scene
  78332. * @returns the hosting scene
  78333. */
  78334. getScene(): Scene;
  78335. /**
  78336. * Does this action manager handles actions of any of the given triggers
  78337. * @param triggers defines the triggers to be tested
  78338. * @return a boolean indicating whether one (or more) of the triggers is handled
  78339. */
  78340. hasSpecificTriggers(triggers: number[]): boolean;
  78341. /**
  78342. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78343. * speed.
  78344. * @param triggerA defines the trigger to be tested
  78345. * @param triggerB defines the trigger to be tested
  78346. * @return a boolean indicating whether one (or more) of the triggers is handled
  78347. */
  78348. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78349. /**
  78350. * Does this action manager handles actions of a given trigger
  78351. * @param trigger defines the trigger to be tested
  78352. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78353. * @return whether the trigger is handled
  78354. */
  78355. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78356. /**
  78357. * Does this action manager has pointer triggers
  78358. */
  78359. readonly hasPointerTriggers: boolean;
  78360. /**
  78361. * Does this action manager has pick triggers
  78362. */
  78363. readonly hasPickTriggers: boolean;
  78364. /**
  78365. * Registers an action to this action manager
  78366. * @param action defines the action to be registered
  78367. * @return the action amended (prepared) after registration
  78368. */
  78369. registerAction(action: IAction): Nullable<IAction>;
  78370. /**
  78371. * Unregisters an action to this action manager
  78372. * @param action defines the action to be unregistered
  78373. * @return a boolean indicating whether the action has been unregistered
  78374. */
  78375. unregisterAction(action: IAction): Boolean;
  78376. /**
  78377. * Process a specific trigger
  78378. * @param trigger defines the trigger to process
  78379. * @param evt defines the event details to be processed
  78380. */
  78381. processTrigger(trigger: number, evt?: IActionEvent): void;
  78382. /** @hidden */
  78383. _getEffectiveTarget(target: any, propertyPath: string): any;
  78384. /** @hidden */
  78385. _getProperty(propertyPath: string): string;
  78386. /**
  78387. * Serialize this manager to a JSON object
  78388. * @param name defines the property name to store this manager
  78389. * @returns a JSON representation of this manager
  78390. */
  78391. serialize(name: string): any;
  78392. /**
  78393. * Creates a new ActionManager from a JSON data
  78394. * @param parsedActions defines the JSON data to read from
  78395. * @param object defines the hosting mesh
  78396. * @param scene defines the hosting scene
  78397. */
  78398. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78399. /**
  78400. * Get a trigger name by index
  78401. * @param trigger defines the trigger index
  78402. * @returns a trigger name
  78403. */
  78404. static GetTriggerName(trigger: number): string;
  78405. }
  78406. }
  78407. declare module BABYLON {
  78408. /**
  78409. * Class representing a ray with position and direction
  78410. */
  78411. export class Ray {
  78412. /** origin point */
  78413. origin: Vector3;
  78414. /** direction */
  78415. direction: Vector3;
  78416. /** length of the ray */
  78417. length: number;
  78418. private static readonly TmpVector3;
  78419. private _tmpRay;
  78420. /**
  78421. * Creates a new ray
  78422. * @param origin origin point
  78423. * @param direction direction
  78424. * @param length length of the ray
  78425. */
  78426. constructor(
  78427. /** origin point */
  78428. origin: Vector3,
  78429. /** direction */
  78430. direction: Vector3,
  78431. /** length of the ray */
  78432. length?: number);
  78433. /**
  78434. * Checks if the ray intersects a box
  78435. * @param minimum bound of the box
  78436. * @param maximum bound of the box
  78437. * @param intersectionTreshold extra extend to be added to the box in all direction
  78438. * @returns if the box was hit
  78439. */
  78440. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78441. /**
  78442. * Checks if the ray intersects a box
  78443. * @param box the bounding box to check
  78444. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78445. * @returns if the box was hit
  78446. */
  78447. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78448. /**
  78449. * If the ray hits a sphere
  78450. * @param sphere the bounding sphere to check
  78451. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78452. * @returns true if it hits the sphere
  78453. */
  78454. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78455. /**
  78456. * If the ray hits a triange
  78457. * @param vertex0 triangle vertex
  78458. * @param vertex1 triangle vertex
  78459. * @param vertex2 triangle vertex
  78460. * @returns intersection information if hit
  78461. */
  78462. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78463. /**
  78464. * Checks if ray intersects a plane
  78465. * @param plane the plane to check
  78466. * @returns the distance away it was hit
  78467. */
  78468. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78469. /**
  78470. * Checks if ray intersects a mesh
  78471. * @param mesh the mesh to check
  78472. * @param fastCheck if only the bounding box should checked
  78473. * @returns picking info of the intersecton
  78474. */
  78475. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78476. /**
  78477. * Checks if ray intersects a mesh
  78478. * @param meshes the meshes to check
  78479. * @param fastCheck if only the bounding box should checked
  78480. * @param results array to store result in
  78481. * @returns Array of picking infos
  78482. */
  78483. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78484. private _comparePickingInfo;
  78485. private static smallnum;
  78486. private static rayl;
  78487. /**
  78488. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78489. * @param sega the first point of the segment to test the intersection against
  78490. * @param segb the second point of the segment to test the intersection against
  78491. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78492. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78493. */
  78494. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78495. /**
  78496. * Update the ray from viewport position
  78497. * @param x position
  78498. * @param y y position
  78499. * @param viewportWidth viewport width
  78500. * @param viewportHeight viewport height
  78501. * @param world world matrix
  78502. * @param view view matrix
  78503. * @param projection projection matrix
  78504. * @returns this ray updated
  78505. */
  78506. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78507. /**
  78508. * Creates a ray with origin and direction of 0,0,0
  78509. * @returns the new ray
  78510. */
  78511. static Zero(): Ray;
  78512. /**
  78513. * Creates a new ray from screen space and viewport
  78514. * @param x position
  78515. * @param y y position
  78516. * @param viewportWidth viewport width
  78517. * @param viewportHeight viewport height
  78518. * @param world world matrix
  78519. * @param view view matrix
  78520. * @param projection projection matrix
  78521. * @returns new ray
  78522. */
  78523. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78524. /**
  78525. * 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
  78526. * transformed to the given world matrix.
  78527. * @param origin The origin point
  78528. * @param end The end point
  78529. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78530. * @returns the new ray
  78531. */
  78532. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78533. /**
  78534. * Transforms a ray by a matrix
  78535. * @param ray ray to transform
  78536. * @param matrix matrix to apply
  78537. * @returns the resulting new ray
  78538. */
  78539. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78540. /**
  78541. * Transforms a ray by a matrix
  78542. * @param ray ray to transform
  78543. * @param matrix matrix to apply
  78544. * @param result ray to store result in
  78545. */
  78546. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78547. /**
  78548. * Unproject a ray from screen space to object space
  78549. * @param sourceX defines the screen space x coordinate to use
  78550. * @param sourceY defines the screen space y coordinate to use
  78551. * @param viewportWidth defines the current width of the viewport
  78552. * @param viewportHeight defines the current height of the viewport
  78553. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78554. * @param view defines the view matrix to use
  78555. * @param projection defines the projection matrix to use
  78556. */
  78557. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78558. }
  78559. /**
  78560. * Type used to define predicate used to select faces when a mesh intersection is detected
  78561. */
  78562. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78563. interface Scene {
  78564. /** @hidden */
  78565. _tempPickingRay: Nullable<Ray>;
  78566. /** @hidden */
  78567. _cachedRayForTransform: Ray;
  78568. /** @hidden */
  78569. _pickWithRayInverseMatrix: Matrix;
  78570. /** @hidden */
  78571. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78572. /** @hidden */
  78573. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78574. }
  78575. }
  78576. declare module BABYLON {
  78577. interface Scene {
  78578. /** @hidden */
  78579. _pointerOverSprite: Nullable<Sprite>;
  78580. /** @hidden */
  78581. _pickedDownSprite: Nullable<Sprite>;
  78582. /** @hidden */
  78583. _tempSpritePickingRay: Nullable<Ray>;
  78584. /**
  78585. * All of the sprite managers added to this scene
  78586. * @see http://doc.babylonjs.com/babylon101/sprites
  78587. */
  78588. spriteManagers: Array<ISpriteManager>;
  78589. /**
  78590. * An event triggered when sprites rendering is about to start
  78591. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78592. */
  78593. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78594. /**
  78595. * An event triggered when sprites rendering is done
  78596. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78597. */
  78598. onAfterSpritesRenderingObservable: Observable<Scene>;
  78599. /** @hidden */
  78600. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78601. /** Launch a ray to try to pick a sprite in the scene
  78602. * @param x position on screen
  78603. * @param y position on screen
  78604. * @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
  78605. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78606. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78607. * @returns a PickingInfo
  78608. */
  78609. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78610. /** Use the given ray to pick a sprite in the scene
  78611. * @param ray The ray (in world space) to use to pick meshes
  78612. * @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
  78613. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78614. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78615. * @returns a PickingInfo
  78616. */
  78617. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78618. /**
  78619. * Force the sprite under the pointer
  78620. * @param sprite defines the sprite to use
  78621. */
  78622. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78623. /**
  78624. * Gets the sprite under the pointer
  78625. * @returns a Sprite or null if no sprite is under the pointer
  78626. */
  78627. getPointerOverSprite(): Nullable<Sprite>;
  78628. }
  78629. /**
  78630. * Defines the sprite scene component responsible to manage sprites
  78631. * in a given scene.
  78632. */
  78633. export class SpriteSceneComponent implements ISceneComponent {
  78634. /**
  78635. * The component name helpfull to identify the component in the list of scene components.
  78636. */
  78637. readonly name: string;
  78638. /**
  78639. * The scene the component belongs to.
  78640. */
  78641. scene: Scene;
  78642. /** @hidden */
  78643. private _spritePredicate;
  78644. /**
  78645. * Creates a new instance of the component for the given scene
  78646. * @param scene Defines the scene to register the component in
  78647. */
  78648. constructor(scene: Scene);
  78649. /**
  78650. * Registers the component in a given scene
  78651. */
  78652. register(): void;
  78653. /**
  78654. * Rebuilds the elements related to this component in case of
  78655. * context lost for instance.
  78656. */
  78657. rebuild(): void;
  78658. /**
  78659. * Disposes the component and the associated ressources.
  78660. */
  78661. dispose(): void;
  78662. private _pickSpriteButKeepRay;
  78663. private _pointerMove;
  78664. private _pointerDown;
  78665. private _pointerUp;
  78666. }
  78667. }
  78668. declare module BABYLON {
  78669. /** @hidden */
  78670. export var fogFragmentDeclaration: {
  78671. name: string;
  78672. shader: string;
  78673. };
  78674. }
  78675. declare module BABYLON {
  78676. /** @hidden */
  78677. export var fogFragment: {
  78678. name: string;
  78679. shader: string;
  78680. };
  78681. }
  78682. declare module BABYLON {
  78683. /** @hidden */
  78684. export var spritesPixelShader: {
  78685. name: string;
  78686. shader: string;
  78687. };
  78688. }
  78689. declare module BABYLON {
  78690. /** @hidden */
  78691. export var fogVertexDeclaration: {
  78692. name: string;
  78693. shader: string;
  78694. };
  78695. }
  78696. declare module BABYLON {
  78697. /** @hidden */
  78698. export var spritesVertexShader: {
  78699. name: string;
  78700. shader: string;
  78701. };
  78702. }
  78703. declare module BABYLON {
  78704. /**
  78705. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78706. */
  78707. export interface ISpriteManager extends IDisposable {
  78708. /**
  78709. * Restricts the camera to viewing objects with the same layerMask.
  78710. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78711. */
  78712. layerMask: number;
  78713. /**
  78714. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78715. */
  78716. isPickable: boolean;
  78717. /**
  78718. * Specifies the rendering group id for this mesh (0 by default)
  78719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78720. */
  78721. renderingGroupId: number;
  78722. /**
  78723. * Defines the list of sprites managed by the manager.
  78724. */
  78725. sprites: Array<Sprite>;
  78726. /**
  78727. * Tests the intersection of a sprite with a specific ray.
  78728. * @param ray The ray we are sending to test the collision
  78729. * @param camera The camera space we are sending rays in
  78730. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78731. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78732. * @returns picking info or null.
  78733. */
  78734. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78735. /**
  78736. * Renders the list of sprites on screen.
  78737. */
  78738. render(): void;
  78739. }
  78740. /**
  78741. * Class used to manage multiple sprites on the same spritesheet
  78742. * @see http://doc.babylonjs.com/babylon101/sprites
  78743. */
  78744. export class SpriteManager implements ISpriteManager {
  78745. /** defines the manager's name */
  78746. name: string;
  78747. /** Gets the list of sprites */
  78748. sprites: Sprite[];
  78749. /** Gets or sets the rendering group id (0 by default) */
  78750. renderingGroupId: number;
  78751. /** Gets or sets camera layer mask */
  78752. layerMask: number;
  78753. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78754. fogEnabled: boolean;
  78755. /** Gets or sets a boolean indicating if the sprites are pickable */
  78756. isPickable: boolean;
  78757. /** Defines the default width of a cell in the spritesheet */
  78758. cellWidth: number;
  78759. /** Defines the default height of a cell in the spritesheet */
  78760. cellHeight: number;
  78761. /**
  78762. * An event triggered when the manager is disposed.
  78763. */
  78764. onDisposeObservable: Observable<SpriteManager>;
  78765. private _onDisposeObserver;
  78766. /**
  78767. * Callback called when the manager is disposed
  78768. */
  78769. onDispose: () => void;
  78770. private _capacity;
  78771. private _spriteTexture;
  78772. private _epsilon;
  78773. private _scene;
  78774. private _vertexData;
  78775. private _buffer;
  78776. private _vertexBuffers;
  78777. private _indexBuffer;
  78778. private _effectBase;
  78779. private _effectFog;
  78780. /**
  78781. * Gets or sets the spritesheet texture
  78782. */
  78783. texture: Texture;
  78784. /**
  78785. * Creates a new sprite manager
  78786. * @param name defines the manager's name
  78787. * @param imgUrl defines the sprite sheet url
  78788. * @param capacity defines the maximum allowed number of sprites
  78789. * @param cellSize defines the size of a sprite cell
  78790. * @param scene defines the hosting scene
  78791. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78792. * @param samplingMode defines the smapling mode to use with spritesheet
  78793. */
  78794. constructor(
  78795. /** defines the manager's name */
  78796. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  78797. private _appendSpriteVertex;
  78798. /**
  78799. * Intersects the sprites with a ray
  78800. * @param ray defines the ray to intersect with
  78801. * @param camera defines the current active camera
  78802. * @param predicate defines a predicate used to select candidate sprites
  78803. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78804. * @returns null if no hit or a PickingInfo
  78805. */
  78806. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78807. /**
  78808. * Render all child sprites
  78809. */
  78810. render(): void;
  78811. /**
  78812. * Release associated resources
  78813. */
  78814. dispose(): void;
  78815. }
  78816. }
  78817. declare module BABYLON {
  78818. /**
  78819. * Class used to represent a sprite
  78820. * @see http://doc.babylonjs.com/babylon101/sprites
  78821. */
  78822. export class Sprite {
  78823. /** defines the name */
  78824. name: string;
  78825. /** Gets or sets the current world position */
  78826. position: Vector3;
  78827. /** Gets or sets the main color */
  78828. color: Color4;
  78829. /** Gets or sets the width */
  78830. width: number;
  78831. /** Gets or sets the height */
  78832. height: number;
  78833. /** Gets or sets rotation angle */
  78834. angle: number;
  78835. /** Gets or sets the cell index in the sprite sheet */
  78836. cellIndex: number;
  78837. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78838. invertU: number;
  78839. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78840. invertV: number;
  78841. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78842. disposeWhenFinishedAnimating: boolean;
  78843. /** Gets the list of attached animations */
  78844. animations: Animation[];
  78845. /** Gets or sets a boolean indicating if the sprite can be picked */
  78846. isPickable: boolean;
  78847. /**
  78848. * Gets or sets the associated action manager
  78849. */
  78850. actionManager: Nullable<ActionManager>;
  78851. private _animationStarted;
  78852. private _loopAnimation;
  78853. private _fromIndex;
  78854. private _toIndex;
  78855. private _delay;
  78856. private _direction;
  78857. private _manager;
  78858. private _time;
  78859. private _onAnimationEnd;
  78860. /**
  78861. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78862. */
  78863. isVisible: boolean;
  78864. /**
  78865. * Gets or sets the sprite size
  78866. */
  78867. size: number;
  78868. /**
  78869. * Creates a new Sprite
  78870. * @param name defines the name
  78871. * @param manager defines the manager
  78872. */
  78873. constructor(
  78874. /** defines the name */
  78875. name: string, manager: ISpriteManager);
  78876. /**
  78877. * Starts an animation
  78878. * @param from defines the initial key
  78879. * @param to defines the end key
  78880. * @param loop defines if the animation must loop
  78881. * @param delay defines the start delay (in ms)
  78882. * @param onAnimationEnd defines a callback to call when animation ends
  78883. */
  78884. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78885. /** Stops current animation (if any) */
  78886. stopAnimation(): void;
  78887. /** @hidden */
  78888. _animate(deltaTime: number): void;
  78889. /** Release associated resources */
  78890. dispose(): void;
  78891. }
  78892. }
  78893. declare module BABYLON {
  78894. /**
  78895. * Information about the result of picking within a scene
  78896. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78897. */
  78898. export class PickingInfo {
  78899. /** @hidden */
  78900. _pickingUnavailable: boolean;
  78901. /**
  78902. * If the pick collided with an object
  78903. */
  78904. hit: boolean;
  78905. /**
  78906. * Distance away where the pick collided
  78907. */
  78908. distance: number;
  78909. /**
  78910. * The location of pick collision
  78911. */
  78912. pickedPoint: Nullable<Vector3>;
  78913. /**
  78914. * The mesh corresponding the the pick collision
  78915. */
  78916. pickedMesh: Nullable<AbstractMesh>;
  78917. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78918. bu: number;
  78919. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78920. bv: number;
  78921. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78922. faceId: number;
  78923. /** Id of the the submesh that was picked */
  78924. subMeshId: number;
  78925. /** If a sprite was picked, this will be the sprite the pick collided with */
  78926. pickedSprite: Nullable<Sprite>;
  78927. /**
  78928. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78929. */
  78930. originMesh: Nullable<AbstractMesh>;
  78931. /**
  78932. * The ray that was used to perform the picking.
  78933. */
  78934. ray: Nullable<Ray>;
  78935. /**
  78936. * Gets the normal correspodning to the face the pick collided with
  78937. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78938. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78939. * @returns The normal correspodning to the face the pick collided with
  78940. */
  78941. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78942. /**
  78943. * Gets the texture coordinates of where the pick occured
  78944. * @returns the vector containing the coordnates of the texture
  78945. */
  78946. getTextureCoordinates(): Nullable<Vector2>;
  78947. }
  78948. }
  78949. declare module BABYLON {
  78950. /**
  78951. * Gather the list of pointer event types as constants.
  78952. */
  78953. export class PointerEventTypes {
  78954. /**
  78955. * 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.
  78956. */
  78957. static readonly POINTERDOWN: number;
  78958. /**
  78959. * The pointerup event is fired when a pointer is no longer active.
  78960. */
  78961. static readonly POINTERUP: number;
  78962. /**
  78963. * The pointermove event is fired when a pointer changes coordinates.
  78964. */
  78965. static readonly POINTERMOVE: number;
  78966. /**
  78967. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78968. */
  78969. static readonly POINTERWHEEL: number;
  78970. /**
  78971. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78972. */
  78973. static readonly POINTERPICK: number;
  78974. /**
  78975. * The pointertap event is fired when a the object has been touched and released without drag.
  78976. */
  78977. static readonly POINTERTAP: number;
  78978. /**
  78979. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78980. */
  78981. static readonly POINTERDOUBLETAP: number;
  78982. }
  78983. /**
  78984. * Base class of pointer info types.
  78985. */
  78986. export class PointerInfoBase {
  78987. /**
  78988. * Defines the type of event (PointerEventTypes)
  78989. */
  78990. type: number;
  78991. /**
  78992. * Defines the related dom event
  78993. */
  78994. event: PointerEvent | MouseWheelEvent;
  78995. /**
  78996. * Instantiates the base class of pointers info.
  78997. * @param type Defines the type of event (PointerEventTypes)
  78998. * @param event Defines the related dom event
  78999. */
  79000. constructor(
  79001. /**
  79002. * Defines the type of event (PointerEventTypes)
  79003. */
  79004. type: number,
  79005. /**
  79006. * Defines the related dom event
  79007. */
  79008. event: PointerEvent | MouseWheelEvent);
  79009. }
  79010. /**
  79011. * This class is used to store pointer related info for the onPrePointerObservable event.
  79012. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79013. */
  79014. export class PointerInfoPre extends PointerInfoBase {
  79015. /**
  79016. * Ray from a pointer if availible (eg. 6dof controller)
  79017. */
  79018. ray: Nullable<Ray>;
  79019. /**
  79020. * Defines the local position of the pointer on the canvas.
  79021. */
  79022. localPosition: Vector2;
  79023. /**
  79024. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79025. */
  79026. skipOnPointerObservable: boolean;
  79027. /**
  79028. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79029. * @param type Defines the type of event (PointerEventTypes)
  79030. * @param event Defines the related dom event
  79031. * @param localX Defines the local x coordinates of the pointer when the event occured
  79032. * @param localY Defines the local y coordinates of the pointer when the event occured
  79033. */
  79034. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79035. }
  79036. /**
  79037. * This type contains all the data related to a pointer event in Babylon.js.
  79038. * 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.
  79039. */
  79040. export class PointerInfo extends PointerInfoBase {
  79041. /**
  79042. * Defines the picking info associated to the info (if any)\
  79043. */
  79044. pickInfo: Nullable<PickingInfo>;
  79045. /**
  79046. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79047. * @param type Defines the type of event (PointerEventTypes)
  79048. * @param event Defines the related dom event
  79049. * @param pickInfo Defines the picking info associated to the info (if any)\
  79050. */
  79051. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79052. /**
  79053. * Defines the picking info associated to the info (if any)\
  79054. */
  79055. pickInfo: Nullable<PickingInfo>);
  79056. }
  79057. /**
  79058. * Data relating to a touch event on the screen.
  79059. */
  79060. export interface PointerTouch {
  79061. /**
  79062. * X coordinate of touch.
  79063. */
  79064. x: number;
  79065. /**
  79066. * Y coordinate of touch.
  79067. */
  79068. y: number;
  79069. /**
  79070. * Id of touch. Unique for each finger.
  79071. */
  79072. pointerId: number;
  79073. /**
  79074. * Event type passed from DOM.
  79075. */
  79076. type: any;
  79077. }
  79078. }
  79079. declare module BABYLON {
  79080. /**
  79081. * Manage the mouse inputs to control the movement of a free camera.
  79082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79083. */
  79084. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79085. /**
  79086. * Define if touch is enabled in the mouse input
  79087. */
  79088. touchEnabled: boolean;
  79089. /**
  79090. * Defines the camera the input is attached to.
  79091. */
  79092. camera: FreeCamera;
  79093. /**
  79094. * Defines the buttons associated with the input to handle camera move.
  79095. */
  79096. buttons: number[];
  79097. /**
  79098. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79099. */
  79100. angularSensibility: number;
  79101. private _pointerInput;
  79102. private _onMouseMove;
  79103. private _observer;
  79104. private previousPosition;
  79105. /**
  79106. * Observable for when a pointer move event occurs containing the move offset
  79107. */
  79108. onPointerMovedObservable: Observable<{
  79109. offsetX: number;
  79110. offsetY: number;
  79111. }>;
  79112. /**
  79113. * @hidden
  79114. * If the camera should be rotated automatically based on pointer movement
  79115. */
  79116. _allowCameraRotation: boolean;
  79117. /**
  79118. * Manage the mouse inputs to control the movement of a free camera.
  79119. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79120. * @param touchEnabled Defines if touch is enabled or not
  79121. */
  79122. constructor(
  79123. /**
  79124. * Define if touch is enabled in the mouse input
  79125. */
  79126. touchEnabled?: boolean);
  79127. /**
  79128. * Attach the input controls to a specific dom element to get the input from.
  79129. * @param element Defines the element the controls should be listened from
  79130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79131. */
  79132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79133. /**
  79134. * Called on JS contextmenu event.
  79135. * Override this method to provide functionality.
  79136. */
  79137. protected onContextMenu(evt: PointerEvent): void;
  79138. /**
  79139. * Detach the current controls from the specified dom element.
  79140. * @param element Defines the element to stop listening the inputs from
  79141. */
  79142. detachControl(element: Nullable<HTMLElement>): void;
  79143. /**
  79144. * Gets the class name of the current intput.
  79145. * @returns the class name
  79146. */
  79147. getClassName(): string;
  79148. /**
  79149. * Get the friendly name associated with the input class.
  79150. * @returns the input friendly name
  79151. */
  79152. getSimpleName(): string;
  79153. }
  79154. }
  79155. declare module BABYLON {
  79156. /**
  79157. * Manage the touch inputs to control the movement of a free camera.
  79158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79159. */
  79160. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79161. /**
  79162. * Defines the camera the input is attached to.
  79163. */
  79164. camera: FreeCamera;
  79165. /**
  79166. * Defines the touch sensibility for rotation.
  79167. * The higher the faster.
  79168. */
  79169. touchAngularSensibility: number;
  79170. /**
  79171. * Defines the touch sensibility for move.
  79172. * The higher the faster.
  79173. */
  79174. touchMoveSensibility: number;
  79175. private _offsetX;
  79176. private _offsetY;
  79177. private _pointerPressed;
  79178. private _pointerInput;
  79179. private _observer;
  79180. private _onLostFocus;
  79181. /**
  79182. * Attach the input controls to a specific dom element to get the input from.
  79183. * @param element Defines the element the controls should be listened from
  79184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79185. */
  79186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79187. /**
  79188. * Detach the current controls from the specified dom element.
  79189. * @param element Defines the element to stop listening the inputs from
  79190. */
  79191. detachControl(element: Nullable<HTMLElement>): void;
  79192. /**
  79193. * Update the current camera state depending on the inputs that have been used this frame.
  79194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79195. */
  79196. checkInputs(): void;
  79197. /**
  79198. * Gets the class name of the current intput.
  79199. * @returns the class name
  79200. */
  79201. getClassName(): string;
  79202. /**
  79203. * Get the friendly name associated with the input class.
  79204. * @returns the input friendly name
  79205. */
  79206. getSimpleName(): string;
  79207. }
  79208. }
  79209. declare module BABYLON {
  79210. /**
  79211. * Default Inputs manager for the FreeCamera.
  79212. * It groups all the default supported inputs for ease of use.
  79213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79214. */
  79215. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79216. /**
  79217. * @hidden
  79218. */
  79219. _mouseInput: Nullable<FreeCameraMouseInput>;
  79220. /**
  79221. * Instantiates a new FreeCameraInputsManager.
  79222. * @param camera Defines the camera the inputs belong to
  79223. */
  79224. constructor(camera: FreeCamera);
  79225. /**
  79226. * Add keyboard input support to the input manager.
  79227. * @returns the current input manager
  79228. */
  79229. addKeyboard(): FreeCameraInputsManager;
  79230. /**
  79231. * Add mouse input support to the input manager.
  79232. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79233. * @returns the current input manager
  79234. */
  79235. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79236. /**
  79237. * Removes the mouse input support from the manager
  79238. * @returns the current input manager
  79239. */
  79240. removeMouse(): FreeCameraInputsManager;
  79241. /**
  79242. * Add touch input support to the input manager.
  79243. * @returns the current input manager
  79244. */
  79245. addTouch(): FreeCameraInputsManager;
  79246. /**
  79247. * Remove all attached input methods from a camera
  79248. */
  79249. clear(): void;
  79250. }
  79251. }
  79252. declare module BABYLON {
  79253. /**
  79254. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79255. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79256. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79257. */
  79258. export class FreeCamera extends TargetCamera {
  79259. /**
  79260. * Define the collision ellipsoid of the camera.
  79261. * This is helpful to simulate a camera body like the player body around the camera
  79262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79263. */
  79264. ellipsoid: Vector3;
  79265. /**
  79266. * Define an offset for the position of the ellipsoid around the camera.
  79267. * This can be helpful to determine the center of the body near the gravity center of the body
  79268. * instead of its head.
  79269. */
  79270. ellipsoidOffset: Vector3;
  79271. /**
  79272. * Enable or disable collisions of the camera with the rest of the scene objects.
  79273. */
  79274. checkCollisions: boolean;
  79275. /**
  79276. * Enable or disable gravity on the camera.
  79277. */
  79278. applyGravity: boolean;
  79279. /**
  79280. * Define the input manager associated to the camera.
  79281. */
  79282. inputs: FreeCameraInputsManager;
  79283. /**
  79284. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79285. * Higher values reduce sensitivity.
  79286. */
  79287. /**
  79288. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79289. * Higher values reduce sensitivity.
  79290. */
  79291. angularSensibility: number;
  79292. /**
  79293. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79294. */
  79295. keysUp: number[];
  79296. /**
  79297. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79298. */
  79299. keysDown: number[];
  79300. /**
  79301. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79302. */
  79303. keysLeft: number[];
  79304. /**
  79305. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79306. */
  79307. keysRight: number[];
  79308. /**
  79309. * Event raised when the camera collide with a mesh in the scene.
  79310. */
  79311. onCollide: (collidedMesh: AbstractMesh) => void;
  79312. private _collider;
  79313. private _needMoveForGravity;
  79314. private _oldPosition;
  79315. private _diffPosition;
  79316. private _newPosition;
  79317. /** @hidden */
  79318. _localDirection: Vector3;
  79319. /** @hidden */
  79320. _transformedDirection: Vector3;
  79321. /**
  79322. * Instantiates a Free Camera.
  79323. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79324. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79325. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79326. * @param name Define the name of the camera in the scene
  79327. * @param position Define the start position of the camera in the scene
  79328. * @param scene Define the scene the camera belongs to
  79329. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79330. */
  79331. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79332. /**
  79333. * Attached controls to the current camera.
  79334. * @param element Defines the element the controls should be listened from
  79335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79336. */
  79337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79338. /**
  79339. * Detach the current controls from the camera.
  79340. * The camera will stop reacting to inputs.
  79341. * @param element Defines the element to stop listening the inputs from
  79342. */
  79343. detachControl(element: HTMLElement): void;
  79344. private _collisionMask;
  79345. /**
  79346. * Define a collision mask to limit the list of object the camera can collide with
  79347. */
  79348. collisionMask: number;
  79349. /** @hidden */
  79350. _collideWithWorld(displacement: Vector3): void;
  79351. private _onCollisionPositionChange;
  79352. /** @hidden */
  79353. _checkInputs(): void;
  79354. /** @hidden */
  79355. _decideIfNeedsToMove(): boolean;
  79356. /** @hidden */
  79357. _updatePosition(): void;
  79358. /**
  79359. * Destroy the camera and release the current resources hold by it.
  79360. */
  79361. dispose(): void;
  79362. /**
  79363. * Gets the current object class name.
  79364. * @return the class name
  79365. */
  79366. getClassName(): string;
  79367. }
  79368. }
  79369. declare module BABYLON {
  79370. /**
  79371. * Represents a gamepad control stick position
  79372. */
  79373. export class StickValues {
  79374. /**
  79375. * The x component of the control stick
  79376. */
  79377. x: number;
  79378. /**
  79379. * The y component of the control stick
  79380. */
  79381. y: number;
  79382. /**
  79383. * Initializes the gamepad x and y control stick values
  79384. * @param x The x component of the gamepad control stick value
  79385. * @param y The y component of the gamepad control stick value
  79386. */
  79387. constructor(
  79388. /**
  79389. * The x component of the control stick
  79390. */
  79391. x: number,
  79392. /**
  79393. * The y component of the control stick
  79394. */
  79395. y: number);
  79396. }
  79397. /**
  79398. * An interface which manages callbacks for gamepad button changes
  79399. */
  79400. export interface GamepadButtonChanges {
  79401. /**
  79402. * Called when a gamepad has been changed
  79403. */
  79404. changed: boolean;
  79405. /**
  79406. * Called when a gamepad press event has been triggered
  79407. */
  79408. pressChanged: boolean;
  79409. /**
  79410. * Called when a touch event has been triggered
  79411. */
  79412. touchChanged: boolean;
  79413. /**
  79414. * Called when a value has changed
  79415. */
  79416. valueChanged: boolean;
  79417. }
  79418. /**
  79419. * Represents a gamepad
  79420. */
  79421. export class Gamepad {
  79422. /**
  79423. * The id of the gamepad
  79424. */
  79425. id: string;
  79426. /**
  79427. * The index of the gamepad
  79428. */
  79429. index: number;
  79430. /**
  79431. * The browser gamepad
  79432. */
  79433. browserGamepad: any;
  79434. /**
  79435. * Specifies what type of gamepad this represents
  79436. */
  79437. type: number;
  79438. private _leftStick;
  79439. private _rightStick;
  79440. /** @hidden */
  79441. _isConnected: boolean;
  79442. private _leftStickAxisX;
  79443. private _leftStickAxisY;
  79444. private _rightStickAxisX;
  79445. private _rightStickAxisY;
  79446. /**
  79447. * Triggered when the left control stick has been changed
  79448. */
  79449. private _onleftstickchanged;
  79450. /**
  79451. * Triggered when the right control stick has been changed
  79452. */
  79453. private _onrightstickchanged;
  79454. /**
  79455. * Represents a gamepad controller
  79456. */
  79457. static GAMEPAD: number;
  79458. /**
  79459. * Represents a generic controller
  79460. */
  79461. static GENERIC: number;
  79462. /**
  79463. * Represents an XBox controller
  79464. */
  79465. static XBOX: number;
  79466. /**
  79467. * Represents a pose-enabled controller
  79468. */
  79469. static POSE_ENABLED: number;
  79470. /**
  79471. * Specifies whether the left control stick should be Y-inverted
  79472. */
  79473. protected _invertLeftStickY: boolean;
  79474. /**
  79475. * Specifies if the gamepad has been connected
  79476. */
  79477. readonly isConnected: boolean;
  79478. /**
  79479. * Initializes the gamepad
  79480. * @param id The id of the gamepad
  79481. * @param index The index of the gamepad
  79482. * @param browserGamepad The browser gamepad
  79483. * @param leftStickX The x component of the left joystick
  79484. * @param leftStickY The y component of the left joystick
  79485. * @param rightStickX The x component of the right joystick
  79486. * @param rightStickY The y component of the right joystick
  79487. */
  79488. constructor(
  79489. /**
  79490. * The id of the gamepad
  79491. */
  79492. id: string,
  79493. /**
  79494. * The index of the gamepad
  79495. */
  79496. index: number,
  79497. /**
  79498. * The browser gamepad
  79499. */
  79500. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79501. /**
  79502. * Callback triggered when the left joystick has changed
  79503. * @param callback
  79504. */
  79505. onleftstickchanged(callback: (values: StickValues) => void): void;
  79506. /**
  79507. * Callback triggered when the right joystick has changed
  79508. * @param callback
  79509. */
  79510. onrightstickchanged(callback: (values: StickValues) => void): void;
  79511. /**
  79512. * Gets the left joystick
  79513. */
  79514. /**
  79515. * Sets the left joystick values
  79516. */
  79517. leftStick: StickValues;
  79518. /**
  79519. * Gets the right joystick
  79520. */
  79521. /**
  79522. * Sets the right joystick value
  79523. */
  79524. rightStick: StickValues;
  79525. /**
  79526. * Updates the gamepad joystick positions
  79527. */
  79528. update(): void;
  79529. /**
  79530. * Disposes the gamepad
  79531. */
  79532. dispose(): void;
  79533. }
  79534. /**
  79535. * Represents a generic gamepad
  79536. */
  79537. export class GenericPad extends Gamepad {
  79538. private _buttons;
  79539. private _onbuttondown;
  79540. private _onbuttonup;
  79541. /**
  79542. * Observable triggered when a button has been pressed
  79543. */
  79544. onButtonDownObservable: Observable<number>;
  79545. /**
  79546. * Observable triggered when a button has been released
  79547. */
  79548. onButtonUpObservable: Observable<number>;
  79549. /**
  79550. * Callback triggered when a button has been pressed
  79551. * @param callback Called when a button has been pressed
  79552. */
  79553. onbuttondown(callback: (buttonPressed: number) => void): void;
  79554. /**
  79555. * Callback triggered when a button has been released
  79556. * @param callback Called when a button has been released
  79557. */
  79558. onbuttonup(callback: (buttonReleased: number) => void): void;
  79559. /**
  79560. * Initializes the generic gamepad
  79561. * @param id The id of the generic gamepad
  79562. * @param index The index of the generic gamepad
  79563. * @param browserGamepad The browser gamepad
  79564. */
  79565. constructor(id: string, index: number, browserGamepad: any);
  79566. private _setButtonValue;
  79567. /**
  79568. * Updates the generic gamepad
  79569. */
  79570. update(): void;
  79571. /**
  79572. * Disposes the generic gamepad
  79573. */
  79574. dispose(): void;
  79575. }
  79576. }
  79577. declare module BABYLON {
  79578. /**
  79579. * Defines the types of pose enabled controllers that are supported
  79580. */
  79581. export enum PoseEnabledControllerType {
  79582. /**
  79583. * HTC Vive
  79584. */
  79585. VIVE = 0,
  79586. /**
  79587. * Oculus Rift
  79588. */
  79589. OCULUS = 1,
  79590. /**
  79591. * Windows mixed reality
  79592. */
  79593. WINDOWS = 2,
  79594. /**
  79595. * Samsung gear VR
  79596. */
  79597. GEAR_VR = 3,
  79598. /**
  79599. * Google Daydream
  79600. */
  79601. DAYDREAM = 4,
  79602. /**
  79603. * Generic
  79604. */
  79605. GENERIC = 5
  79606. }
  79607. /**
  79608. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79609. */
  79610. export interface MutableGamepadButton {
  79611. /**
  79612. * Value of the button/trigger
  79613. */
  79614. value: number;
  79615. /**
  79616. * If the button/trigger is currently touched
  79617. */
  79618. touched: boolean;
  79619. /**
  79620. * If the button/trigger is currently pressed
  79621. */
  79622. pressed: boolean;
  79623. }
  79624. /**
  79625. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79626. * @hidden
  79627. */
  79628. export interface ExtendedGamepadButton extends GamepadButton {
  79629. /**
  79630. * If the button/trigger is currently pressed
  79631. */
  79632. readonly pressed: boolean;
  79633. /**
  79634. * If the button/trigger is currently touched
  79635. */
  79636. readonly touched: boolean;
  79637. /**
  79638. * Value of the button/trigger
  79639. */
  79640. readonly value: number;
  79641. }
  79642. /** @hidden */
  79643. export interface _GamePadFactory {
  79644. /**
  79645. * Returns wether or not the current gamepad can be created for this type of controller.
  79646. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79647. * @returns true if it can be created, otherwise false
  79648. */
  79649. canCreate(gamepadInfo: any): boolean;
  79650. /**
  79651. * Creates a new instance of the Gamepad.
  79652. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79653. * @returns the new gamepad instance
  79654. */
  79655. create(gamepadInfo: any): Gamepad;
  79656. }
  79657. /**
  79658. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79659. */
  79660. export class PoseEnabledControllerHelper {
  79661. /** @hidden */
  79662. static _ControllerFactories: _GamePadFactory[];
  79663. /** @hidden */
  79664. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79665. /**
  79666. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79667. * @param vrGamepad the gamepad to initialized
  79668. * @returns a vr controller of the type the gamepad identified as
  79669. */
  79670. static InitiateController(vrGamepad: any): Gamepad;
  79671. }
  79672. /**
  79673. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79674. */
  79675. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79676. private _deviceRoomPosition;
  79677. private _deviceRoomRotationQuaternion;
  79678. /**
  79679. * The device position in babylon space
  79680. */
  79681. devicePosition: Vector3;
  79682. /**
  79683. * The device rotation in babylon space
  79684. */
  79685. deviceRotationQuaternion: Quaternion;
  79686. /**
  79687. * The scale factor of the device in babylon space
  79688. */
  79689. deviceScaleFactor: number;
  79690. /**
  79691. * (Likely devicePosition should be used instead) The device position in its room space
  79692. */
  79693. position: Vector3;
  79694. /**
  79695. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79696. */
  79697. rotationQuaternion: Quaternion;
  79698. /**
  79699. * The type of controller (Eg. Windows mixed reality)
  79700. */
  79701. controllerType: PoseEnabledControllerType;
  79702. protected _calculatedPosition: Vector3;
  79703. private _calculatedRotation;
  79704. /**
  79705. * The raw pose from the device
  79706. */
  79707. rawPose: DevicePose;
  79708. private _trackPosition;
  79709. private _maxRotationDistFromHeadset;
  79710. private _draggedRoomRotation;
  79711. /**
  79712. * @hidden
  79713. */
  79714. _disableTrackPosition(fixedPosition: Vector3): void;
  79715. /**
  79716. * Internal, the mesh attached to the controller
  79717. * @hidden
  79718. */
  79719. _mesh: Nullable<AbstractMesh>;
  79720. private _poseControlledCamera;
  79721. private _leftHandSystemQuaternion;
  79722. /**
  79723. * Internal, matrix used to convert room space to babylon space
  79724. * @hidden
  79725. */
  79726. _deviceToWorld: Matrix;
  79727. /**
  79728. * Node to be used when casting a ray from the controller
  79729. * @hidden
  79730. */
  79731. _pointingPoseNode: Nullable<TransformNode>;
  79732. /**
  79733. * Name of the child mesh that can be used to cast a ray from the controller
  79734. */
  79735. static readonly POINTING_POSE: string;
  79736. /**
  79737. * Creates a new PoseEnabledController from a gamepad
  79738. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79739. */
  79740. constructor(browserGamepad: any);
  79741. private _workingMatrix;
  79742. /**
  79743. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79744. */
  79745. update(): void;
  79746. /**
  79747. * Updates only the pose device and mesh without doing any button event checking
  79748. */
  79749. protected _updatePoseAndMesh(): void;
  79750. /**
  79751. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79752. * @param poseData raw pose fromthe device
  79753. */
  79754. updateFromDevice(poseData: DevicePose): void;
  79755. /**
  79756. * @hidden
  79757. */
  79758. _meshAttachedObservable: Observable<AbstractMesh>;
  79759. /**
  79760. * Attaches a mesh to the controller
  79761. * @param mesh the mesh to be attached
  79762. */
  79763. attachToMesh(mesh: AbstractMesh): void;
  79764. /**
  79765. * Attaches the controllers mesh to a camera
  79766. * @param camera the camera the mesh should be attached to
  79767. */
  79768. attachToPoseControlledCamera(camera: TargetCamera): void;
  79769. /**
  79770. * Disposes of the controller
  79771. */
  79772. dispose(): void;
  79773. /**
  79774. * The mesh that is attached to the controller
  79775. */
  79776. readonly mesh: Nullable<AbstractMesh>;
  79777. /**
  79778. * Gets the ray of the controller in the direction the controller is pointing
  79779. * @param length the length the resulting ray should be
  79780. * @returns a ray in the direction the controller is pointing
  79781. */
  79782. getForwardRay(length?: number): Ray;
  79783. }
  79784. }
  79785. declare module BABYLON {
  79786. /**
  79787. * Defines the WebVRController object that represents controllers tracked in 3D space
  79788. */
  79789. export abstract class WebVRController extends PoseEnabledController {
  79790. /**
  79791. * Internal, the default controller model for the controller
  79792. */
  79793. protected _defaultModel: AbstractMesh;
  79794. /**
  79795. * Fired when the trigger state has changed
  79796. */
  79797. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79798. /**
  79799. * Fired when the main button state has changed
  79800. */
  79801. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79802. /**
  79803. * Fired when the secondary button state has changed
  79804. */
  79805. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79806. /**
  79807. * Fired when the pad state has changed
  79808. */
  79809. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79810. /**
  79811. * Fired when controllers stick values have changed
  79812. */
  79813. onPadValuesChangedObservable: Observable<StickValues>;
  79814. /**
  79815. * Array of button availible on the controller
  79816. */
  79817. protected _buttons: Array<MutableGamepadButton>;
  79818. private _onButtonStateChange;
  79819. /**
  79820. * Fired when a controller button's state has changed
  79821. * @param callback the callback containing the button that was modified
  79822. */
  79823. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79824. /**
  79825. * X and Y axis corresponding to the controllers joystick
  79826. */
  79827. pad: StickValues;
  79828. /**
  79829. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79830. */
  79831. hand: string;
  79832. /**
  79833. * The default controller model for the controller
  79834. */
  79835. readonly defaultModel: AbstractMesh;
  79836. /**
  79837. * Creates a new WebVRController from a gamepad
  79838. * @param vrGamepad the gamepad that the WebVRController should be created from
  79839. */
  79840. constructor(vrGamepad: any);
  79841. /**
  79842. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79843. */
  79844. update(): void;
  79845. /**
  79846. * Function to be called when a button is modified
  79847. */
  79848. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79849. /**
  79850. * Loads a mesh and attaches it to the controller
  79851. * @param scene the scene the mesh should be added to
  79852. * @param meshLoaded callback for when the mesh has been loaded
  79853. */
  79854. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79855. private _setButtonValue;
  79856. private _changes;
  79857. private _checkChanges;
  79858. /**
  79859. * Disposes of th webVRCOntroller
  79860. */
  79861. dispose(): void;
  79862. }
  79863. }
  79864. declare module BABYLON {
  79865. /**
  79866. * The HemisphericLight simulates the ambient environment light,
  79867. * so the passed direction is the light reflection direction, not the incoming direction.
  79868. */
  79869. export class HemisphericLight extends Light {
  79870. /**
  79871. * The groundColor is the light in the opposite direction to the one specified during creation.
  79872. * 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.
  79873. */
  79874. groundColor: Color3;
  79875. /**
  79876. * The light reflection direction, not the incoming direction.
  79877. */
  79878. direction: Vector3;
  79879. /**
  79880. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79881. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79882. * The HemisphericLight can't cast shadows.
  79883. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79884. * @param name The friendly name of the light
  79885. * @param direction The direction of the light reflection
  79886. * @param scene The scene the light belongs to
  79887. */
  79888. constructor(name: string, direction: Vector3, scene: Scene);
  79889. protected _buildUniformLayout(): void;
  79890. /**
  79891. * Returns the string "HemisphericLight".
  79892. * @return The class name
  79893. */
  79894. getClassName(): string;
  79895. /**
  79896. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79897. * Returns the updated direction.
  79898. * @param target The target the direction should point to
  79899. * @return The computed direction
  79900. */
  79901. setDirectionToTarget(target: Vector3): Vector3;
  79902. /**
  79903. * Returns the shadow generator associated to the light.
  79904. * @returns Always null for hemispheric lights because it does not support shadows.
  79905. */
  79906. getShadowGenerator(): Nullable<IShadowGenerator>;
  79907. /**
  79908. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79909. * @param effect The effect to update
  79910. * @param lightIndex The index of the light in the effect to update
  79911. * @returns The hemispheric light
  79912. */
  79913. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79914. /**
  79915. * Computes the world matrix of the node
  79916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79917. * @param useWasUpdatedFlag defines a reserved property
  79918. * @returns the world matrix
  79919. */
  79920. computeWorldMatrix(): Matrix;
  79921. /**
  79922. * Returns the integer 3.
  79923. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79924. */
  79925. getTypeID(): number;
  79926. /**
  79927. * Prepares the list of defines specific to the light type.
  79928. * @param defines the list of defines
  79929. * @param lightIndex defines the index of the light for the effect
  79930. */
  79931. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79932. }
  79933. }
  79934. declare module BABYLON {
  79935. /** @hidden */
  79936. export var vrMultiviewToSingleviewPixelShader: {
  79937. name: string;
  79938. shader: string;
  79939. };
  79940. }
  79941. declare module BABYLON {
  79942. /**
  79943. * Renders to multiple views with a single draw call
  79944. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  79945. */
  79946. export class MultiviewRenderTarget extends RenderTargetTexture {
  79947. /**
  79948. * Creates a multiview render target
  79949. * @param scene scene used with the render target
  79950. * @param size the size of the render target (used for each view)
  79951. */
  79952. constructor(scene: Scene, size?: number | {
  79953. width: number;
  79954. height: number;
  79955. } | {
  79956. ratio: number;
  79957. });
  79958. /**
  79959. * @hidden
  79960. * @param faceIndex the face index, if its a cube texture
  79961. */
  79962. _bindFrameBuffer(faceIndex?: number): void;
  79963. /**
  79964. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  79965. * @returns the view count
  79966. */
  79967. getViewCount(): number;
  79968. }
  79969. }
  79970. declare module BABYLON {
  79971. interface Engine {
  79972. /**
  79973. * Creates a new multiview render target
  79974. * @param width defines the width of the texture
  79975. * @param height defines the height of the texture
  79976. * @returns the created multiview texture
  79977. */
  79978. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  79979. /**
  79980. * Binds a multiview framebuffer to be drawn to
  79981. * @param multiviewTexture texture to bind
  79982. */
  79983. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  79984. }
  79985. interface Camera {
  79986. /**
  79987. * @hidden
  79988. * 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)
  79989. */
  79990. _useMultiviewToSingleView: boolean;
  79991. /**
  79992. * @hidden
  79993. * 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)
  79994. */
  79995. _multiviewTexture: Nullable<RenderTargetTexture>;
  79996. /**
  79997. * @hidden
  79998. * ensures the multiview texture of the camera exists and has the specified width/height
  79999. * @param width height to set on the multiview texture
  80000. * @param height width to set on the multiview texture
  80001. */
  80002. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80003. }
  80004. interface Scene {
  80005. /** @hidden */
  80006. _transformMatrixR: Matrix;
  80007. /** @hidden */
  80008. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80009. /** @hidden */
  80010. _createMultiviewUbo(): void;
  80011. /** @hidden */
  80012. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80013. /** @hidden */
  80014. _renderMultiviewToSingleView(camera: Camera): void;
  80015. }
  80016. }
  80017. declare module BABYLON {
  80018. /**
  80019. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80020. * This will not be used for webXR as it supports displaying texture arrays directly
  80021. */
  80022. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80023. /**
  80024. * Initializes a VRMultiviewToSingleview
  80025. * @param name name of the post process
  80026. * @param camera camera to be applied to
  80027. * @param scaleFactor scaling factor to the size of the output texture
  80028. */
  80029. constructor(name: string, camera: Camera, scaleFactor: number);
  80030. }
  80031. }
  80032. declare module BABYLON {
  80033. interface Engine {
  80034. /** @hidden */
  80035. _vrDisplay: any;
  80036. /** @hidden */
  80037. _vrSupported: boolean;
  80038. /** @hidden */
  80039. _oldSize: Size;
  80040. /** @hidden */
  80041. _oldHardwareScaleFactor: number;
  80042. /** @hidden */
  80043. _vrExclusivePointerMode: boolean;
  80044. /** @hidden */
  80045. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80046. /** @hidden */
  80047. _onVRDisplayPointerRestricted: () => void;
  80048. /** @hidden */
  80049. _onVRDisplayPointerUnrestricted: () => void;
  80050. /** @hidden */
  80051. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80052. /** @hidden */
  80053. _onVrDisplayDisconnect: Nullable<() => void>;
  80054. /** @hidden */
  80055. _onVrDisplayPresentChange: Nullable<() => void>;
  80056. /**
  80057. * Observable signaled when VR display mode changes
  80058. */
  80059. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80060. /**
  80061. * Observable signaled when VR request present is complete
  80062. */
  80063. onVRRequestPresentComplete: Observable<boolean>;
  80064. /**
  80065. * Observable signaled when VR request present starts
  80066. */
  80067. onVRRequestPresentStart: Observable<Engine>;
  80068. /**
  80069. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80070. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80071. */
  80072. isInVRExclusivePointerMode: boolean;
  80073. /**
  80074. * Gets a boolean indicating if a webVR device was detected
  80075. * @returns true if a webVR device was detected
  80076. */
  80077. isVRDevicePresent(): boolean;
  80078. /**
  80079. * Gets the current webVR device
  80080. * @returns the current webVR device (or null)
  80081. */
  80082. getVRDevice(): any;
  80083. /**
  80084. * Initializes a webVR display and starts listening to display change events
  80085. * The onVRDisplayChangedObservable will be notified upon these changes
  80086. * @returns A promise containing a VRDisplay and if vr is supported
  80087. */
  80088. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80089. /** @hidden */
  80090. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80091. /**
  80092. * Call this function to switch to webVR mode
  80093. * Will do nothing if webVR is not supported or if there is no webVR device
  80094. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80095. */
  80096. enableVR(): void;
  80097. /** @hidden */
  80098. _onVRFullScreenTriggered(): void;
  80099. }
  80100. }
  80101. declare module BABYLON {
  80102. /**
  80103. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80104. * IMPORTANT!! The data is right-hand data.
  80105. * @export
  80106. * @interface DevicePose
  80107. */
  80108. export interface DevicePose {
  80109. /**
  80110. * The position of the device, values in array are [x,y,z].
  80111. */
  80112. readonly position: Nullable<Float32Array>;
  80113. /**
  80114. * The linearVelocity of the device, values in array are [x,y,z].
  80115. */
  80116. readonly linearVelocity: Nullable<Float32Array>;
  80117. /**
  80118. * The linearAcceleration of the device, values in array are [x,y,z].
  80119. */
  80120. readonly linearAcceleration: Nullable<Float32Array>;
  80121. /**
  80122. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80123. */
  80124. readonly orientation: Nullable<Float32Array>;
  80125. /**
  80126. * The angularVelocity of the device, values in array are [x,y,z].
  80127. */
  80128. readonly angularVelocity: Nullable<Float32Array>;
  80129. /**
  80130. * The angularAcceleration of the device, values in array are [x,y,z].
  80131. */
  80132. readonly angularAcceleration: Nullable<Float32Array>;
  80133. }
  80134. /**
  80135. * Interface representing a pose controlled object in Babylon.
  80136. * A pose controlled object has both regular pose values as well as pose values
  80137. * from an external device such as a VR head mounted display
  80138. */
  80139. export interface PoseControlled {
  80140. /**
  80141. * The position of the object in babylon space.
  80142. */
  80143. position: Vector3;
  80144. /**
  80145. * The rotation quaternion of the object in babylon space.
  80146. */
  80147. rotationQuaternion: Quaternion;
  80148. /**
  80149. * The position of the device in babylon space.
  80150. */
  80151. devicePosition?: Vector3;
  80152. /**
  80153. * The rotation quaternion of the device in babylon space.
  80154. */
  80155. deviceRotationQuaternion: Quaternion;
  80156. /**
  80157. * The raw pose coming from the device.
  80158. */
  80159. rawPose: Nullable<DevicePose>;
  80160. /**
  80161. * The scale of the device to be used when translating from device space to babylon space.
  80162. */
  80163. deviceScaleFactor: number;
  80164. /**
  80165. * Updates the poseControlled values based on the input device pose.
  80166. * @param poseData the pose data to update the object with
  80167. */
  80168. updateFromDevice(poseData: DevicePose): void;
  80169. }
  80170. /**
  80171. * Set of options to customize the webVRCamera
  80172. */
  80173. export interface WebVROptions {
  80174. /**
  80175. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80176. */
  80177. trackPosition?: boolean;
  80178. /**
  80179. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80180. */
  80181. positionScale?: number;
  80182. /**
  80183. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80184. */
  80185. displayName?: string;
  80186. /**
  80187. * Should the native controller meshes be initialized. (default: true)
  80188. */
  80189. controllerMeshes?: boolean;
  80190. /**
  80191. * Creating a default HemiLight only on controllers. (default: true)
  80192. */
  80193. defaultLightingOnControllers?: boolean;
  80194. /**
  80195. * If you don't want to use the default VR button of the helper. (default: false)
  80196. */
  80197. useCustomVRButton?: boolean;
  80198. /**
  80199. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80200. */
  80201. customVRButton?: HTMLButtonElement;
  80202. /**
  80203. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80204. */
  80205. rayLength?: number;
  80206. /**
  80207. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80208. */
  80209. defaultHeight?: number;
  80210. /**
  80211. * If multiview should be used if availible (default: false)
  80212. */
  80213. useMultiview?: boolean;
  80214. }
  80215. /**
  80216. * This represents a WebVR camera.
  80217. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80218. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80219. */
  80220. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80221. private webVROptions;
  80222. /**
  80223. * @hidden
  80224. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80225. */
  80226. _vrDevice: any;
  80227. /**
  80228. * The rawPose of the vrDevice.
  80229. */
  80230. rawPose: Nullable<DevicePose>;
  80231. private _onVREnabled;
  80232. private _specsVersion;
  80233. private _attached;
  80234. private _frameData;
  80235. protected _descendants: Array<Node>;
  80236. private _deviceRoomPosition;
  80237. /** @hidden */
  80238. _deviceRoomRotationQuaternion: Quaternion;
  80239. private _standingMatrix;
  80240. /**
  80241. * Represents device position in babylon space.
  80242. */
  80243. devicePosition: Vector3;
  80244. /**
  80245. * Represents device rotation in babylon space.
  80246. */
  80247. deviceRotationQuaternion: Quaternion;
  80248. /**
  80249. * The scale of the device to be used when translating from device space to babylon space.
  80250. */
  80251. deviceScaleFactor: number;
  80252. private _deviceToWorld;
  80253. private _worldToDevice;
  80254. /**
  80255. * References to the webVR controllers for the vrDevice.
  80256. */
  80257. controllers: Array<WebVRController>;
  80258. /**
  80259. * Emits an event when a controller is attached.
  80260. */
  80261. onControllersAttachedObservable: Observable<WebVRController[]>;
  80262. /**
  80263. * Emits an event when a controller's mesh has been loaded;
  80264. */
  80265. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80266. /**
  80267. * Emits an event when the HMD's pose has been updated.
  80268. */
  80269. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80270. private _poseSet;
  80271. /**
  80272. * If the rig cameras be used as parent instead of this camera.
  80273. */
  80274. rigParenting: boolean;
  80275. private _lightOnControllers;
  80276. private _defaultHeight?;
  80277. /**
  80278. * Instantiates a WebVRFreeCamera.
  80279. * @param name The name of the WebVRFreeCamera
  80280. * @param position The starting anchor position for the camera
  80281. * @param scene The scene the camera belongs to
  80282. * @param webVROptions a set of customizable options for the webVRCamera
  80283. */
  80284. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80285. /**
  80286. * Gets the device distance from the ground in meters.
  80287. * @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.
  80288. */
  80289. deviceDistanceToRoomGround(): number;
  80290. /**
  80291. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80292. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80293. */
  80294. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80295. /**
  80296. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80297. * @returns A promise with a boolean set to if the standing matrix is supported.
  80298. */
  80299. useStandingMatrixAsync(): Promise<boolean>;
  80300. /**
  80301. * Disposes the camera
  80302. */
  80303. dispose(): void;
  80304. /**
  80305. * Gets a vrController by name.
  80306. * @param name The name of the controller to retreive
  80307. * @returns the controller matching the name specified or null if not found
  80308. */
  80309. getControllerByName(name: string): Nullable<WebVRController>;
  80310. private _leftController;
  80311. /**
  80312. * The controller corresponding to the users left hand.
  80313. */
  80314. readonly leftController: Nullable<WebVRController>;
  80315. private _rightController;
  80316. /**
  80317. * The controller corresponding to the users right hand.
  80318. */
  80319. readonly rightController: Nullable<WebVRController>;
  80320. /**
  80321. * Casts a ray forward from the vrCamera's gaze.
  80322. * @param length Length of the ray (default: 100)
  80323. * @returns the ray corresponding to the gaze
  80324. */
  80325. getForwardRay(length?: number): Ray;
  80326. /**
  80327. * @hidden
  80328. * Updates the camera based on device's frame data
  80329. */
  80330. _checkInputs(): void;
  80331. /**
  80332. * Updates the poseControlled values based on the input device pose.
  80333. * @param poseData Pose coming from the device
  80334. */
  80335. updateFromDevice(poseData: DevicePose): void;
  80336. private _htmlElementAttached;
  80337. private _detachIfAttached;
  80338. /**
  80339. * WebVR's attach control will start broadcasting frames to the device.
  80340. * Note that in certain browsers (chrome for example) this function must be called
  80341. * within a user-interaction callback. Example:
  80342. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80343. *
  80344. * @param element html element to attach the vrDevice to
  80345. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80346. */
  80347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80348. /**
  80349. * Detaches the camera from the html element and disables VR
  80350. *
  80351. * @param element html element to detach from
  80352. */
  80353. detachControl(element: HTMLElement): void;
  80354. /**
  80355. * @returns the name of this class
  80356. */
  80357. getClassName(): string;
  80358. /**
  80359. * Calls resetPose on the vrDisplay
  80360. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80361. */
  80362. resetToCurrentRotation(): void;
  80363. /**
  80364. * @hidden
  80365. * Updates the rig cameras (left and right eye)
  80366. */
  80367. _updateRigCameras(): void;
  80368. private _workingVector;
  80369. private _oneVector;
  80370. private _workingMatrix;
  80371. private updateCacheCalled;
  80372. private _correctPositionIfNotTrackPosition;
  80373. /**
  80374. * @hidden
  80375. * Updates the cached values of the camera
  80376. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80377. */
  80378. _updateCache(ignoreParentClass?: boolean): void;
  80379. /**
  80380. * @hidden
  80381. * Get current device position in babylon world
  80382. */
  80383. _computeDevicePosition(): void;
  80384. /**
  80385. * Updates the current device position and rotation in the babylon world
  80386. */
  80387. update(): void;
  80388. /**
  80389. * @hidden
  80390. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80391. * @returns an identity matrix
  80392. */
  80393. _getViewMatrix(): Matrix;
  80394. private _tmpMatrix;
  80395. /**
  80396. * This function is called by the two RIG cameras.
  80397. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80398. * @hidden
  80399. */
  80400. _getWebVRViewMatrix(): Matrix;
  80401. /** @hidden */
  80402. _getWebVRProjectionMatrix(): Matrix;
  80403. private _onGamepadConnectedObserver;
  80404. private _onGamepadDisconnectedObserver;
  80405. private _updateCacheWhenTrackingDisabledObserver;
  80406. /**
  80407. * Initializes the controllers and their meshes
  80408. */
  80409. initControllers(): void;
  80410. }
  80411. }
  80412. declare module BABYLON {
  80413. /**
  80414. * Size options for a post process
  80415. */
  80416. export type PostProcessOptions = {
  80417. width: number;
  80418. height: number;
  80419. };
  80420. /**
  80421. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80422. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80423. */
  80424. export class PostProcess {
  80425. /** Name of the PostProcess. */
  80426. name: string;
  80427. /**
  80428. * Gets or sets the unique id of the post process
  80429. */
  80430. uniqueId: number;
  80431. /**
  80432. * Width of the texture to apply the post process on
  80433. */
  80434. width: number;
  80435. /**
  80436. * Height of the texture to apply the post process on
  80437. */
  80438. height: number;
  80439. /**
  80440. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80441. * @hidden
  80442. */
  80443. _outputTexture: Nullable<InternalTexture>;
  80444. /**
  80445. * Sampling mode used by the shader
  80446. * See https://doc.babylonjs.com/classes/3.1/texture
  80447. */
  80448. renderTargetSamplingMode: number;
  80449. /**
  80450. * Clear color to use when screen clearing
  80451. */
  80452. clearColor: Color4;
  80453. /**
  80454. * If the buffer needs to be cleared before applying the post process. (default: true)
  80455. * Should be set to false if shader will overwrite all previous pixels.
  80456. */
  80457. autoClear: boolean;
  80458. /**
  80459. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80460. */
  80461. alphaMode: number;
  80462. /**
  80463. * Sets the setAlphaBlendConstants of the babylon engine
  80464. */
  80465. alphaConstants: Color4;
  80466. /**
  80467. * Animations to be used for the post processing
  80468. */
  80469. animations: Animation[];
  80470. /**
  80471. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80472. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80473. */
  80474. enablePixelPerfectMode: boolean;
  80475. /**
  80476. * Force the postprocess to be applied without taking in account viewport
  80477. */
  80478. forceFullscreenViewport: boolean;
  80479. /**
  80480. * List of inspectable custom properties (used by the Inspector)
  80481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80482. */
  80483. inspectableCustomProperties: IInspectable[];
  80484. /**
  80485. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80486. *
  80487. * | Value | Type | Description |
  80488. * | ----- | ----------------------------------- | ----------- |
  80489. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80490. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80491. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80492. *
  80493. */
  80494. scaleMode: number;
  80495. /**
  80496. * Force textures to be a power of two (default: false)
  80497. */
  80498. alwaysForcePOT: boolean;
  80499. private _samples;
  80500. /**
  80501. * Number of sample textures (default: 1)
  80502. */
  80503. samples: number;
  80504. /**
  80505. * Modify the scale of the post process to be the same as the viewport (default: false)
  80506. */
  80507. adaptScaleToCurrentViewport: boolean;
  80508. private _camera;
  80509. private _scene;
  80510. private _engine;
  80511. private _options;
  80512. private _reusable;
  80513. private _textureType;
  80514. /**
  80515. * Smart array of input and output textures for the post process.
  80516. * @hidden
  80517. */
  80518. _textures: SmartArray<InternalTexture>;
  80519. /**
  80520. * The index in _textures that corresponds to the output texture.
  80521. * @hidden
  80522. */
  80523. _currentRenderTextureInd: number;
  80524. private _effect;
  80525. private _samplers;
  80526. private _fragmentUrl;
  80527. private _vertexUrl;
  80528. private _parameters;
  80529. private _scaleRatio;
  80530. protected _indexParameters: any;
  80531. private _shareOutputWithPostProcess;
  80532. private _texelSize;
  80533. private _forcedOutputTexture;
  80534. /**
  80535. * Returns the fragment url or shader name used in the post process.
  80536. * @returns the fragment url or name in the shader store.
  80537. */
  80538. getEffectName(): string;
  80539. /**
  80540. * An event triggered when the postprocess is activated.
  80541. */
  80542. onActivateObservable: Observable<Camera>;
  80543. private _onActivateObserver;
  80544. /**
  80545. * A function that is added to the onActivateObservable
  80546. */
  80547. onActivate: Nullable<(camera: Camera) => void>;
  80548. /**
  80549. * An event triggered when the postprocess changes its size.
  80550. */
  80551. onSizeChangedObservable: Observable<PostProcess>;
  80552. private _onSizeChangedObserver;
  80553. /**
  80554. * A function that is added to the onSizeChangedObservable
  80555. */
  80556. onSizeChanged: (postProcess: PostProcess) => void;
  80557. /**
  80558. * An event triggered when the postprocess applies its effect.
  80559. */
  80560. onApplyObservable: Observable<Effect>;
  80561. private _onApplyObserver;
  80562. /**
  80563. * A function that is added to the onApplyObservable
  80564. */
  80565. onApply: (effect: Effect) => void;
  80566. /**
  80567. * An event triggered before rendering the postprocess
  80568. */
  80569. onBeforeRenderObservable: Observable<Effect>;
  80570. private _onBeforeRenderObserver;
  80571. /**
  80572. * A function that is added to the onBeforeRenderObservable
  80573. */
  80574. onBeforeRender: (effect: Effect) => void;
  80575. /**
  80576. * An event triggered after rendering the postprocess
  80577. */
  80578. onAfterRenderObservable: Observable<Effect>;
  80579. private _onAfterRenderObserver;
  80580. /**
  80581. * A function that is added to the onAfterRenderObservable
  80582. */
  80583. onAfterRender: (efect: Effect) => void;
  80584. /**
  80585. * 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
  80586. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80587. */
  80588. inputTexture: InternalTexture;
  80589. /**
  80590. * Gets the camera which post process is applied to.
  80591. * @returns The camera the post process is applied to.
  80592. */
  80593. getCamera(): Camera;
  80594. /**
  80595. * Gets the texel size of the postprocess.
  80596. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80597. */
  80598. readonly texelSize: Vector2;
  80599. /**
  80600. * Creates a new instance PostProcess
  80601. * @param name The name of the PostProcess.
  80602. * @param fragmentUrl The url of the fragment shader to be used.
  80603. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80604. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80605. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80606. * @param camera The camera to apply the render pass to.
  80607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80608. * @param engine The engine which the post process will be applied. (default: current engine)
  80609. * @param reusable If the post process can be reused on the same frame. (default: false)
  80610. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80611. * @param textureType Type of textures used when performing the post process. (default: 0)
  80612. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80613. * @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
  80614. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80615. */
  80616. constructor(
  80617. /** Name of the PostProcess. */
  80618. 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);
  80619. /**
  80620. * Gets a string idenfifying the name of the class
  80621. * @returns "PostProcess" string
  80622. */
  80623. getClassName(): string;
  80624. /**
  80625. * Gets the engine which this post process belongs to.
  80626. * @returns The engine the post process was enabled with.
  80627. */
  80628. getEngine(): Engine;
  80629. /**
  80630. * The effect that is created when initializing the post process.
  80631. * @returns The created effect corresponding the the postprocess.
  80632. */
  80633. getEffect(): Effect;
  80634. /**
  80635. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80636. * @param postProcess The post process to share the output with.
  80637. * @returns This post process.
  80638. */
  80639. shareOutputWith(postProcess: PostProcess): PostProcess;
  80640. /**
  80641. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80642. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80643. */
  80644. useOwnOutput(): void;
  80645. /**
  80646. * Updates the effect with the current post process compile time values and recompiles the shader.
  80647. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80648. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80649. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80650. * @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
  80651. * @param onCompiled Called when the shader has been compiled.
  80652. * @param onError Called if there is an error when compiling a shader.
  80653. */
  80654. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80655. /**
  80656. * The post process is reusable if it can be used multiple times within one frame.
  80657. * @returns If the post process is reusable
  80658. */
  80659. isReusable(): boolean;
  80660. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80661. markTextureDirty(): void;
  80662. /**
  80663. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80664. * 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.
  80665. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80666. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80667. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80668. * @returns The target texture that was bound to be written to.
  80669. */
  80670. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80671. /**
  80672. * If the post process is supported.
  80673. */
  80674. readonly isSupported: boolean;
  80675. /**
  80676. * The aspect ratio of the output texture.
  80677. */
  80678. readonly aspectRatio: number;
  80679. /**
  80680. * Get a value indicating if the post-process is ready to be used
  80681. * @returns true if the post-process is ready (shader is compiled)
  80682. */
  80683. isReady(): boolean;
  80684. /**
  80685. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80686. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80687. */
  80688. apply(): Nullable<Effect>;
  80689. private _disposeTextures;
  80690. /**
  80691. * Disposes the post process.
  80692. * @param camera The camera to dispose the post process on.
  80693. */
  80694. dispose(camera?: Camera): void;
  80695. }
  80696. }
  80697. declare module BABYLON {
  80698. /** @hidden */
  80699. export var kernelBlurVaryingDeclaration: {
  80700. name: string;
  80701. shader: string;
  80702. };
  80703. }
  80704. declare module BABYLON {
  80705. /** @hidden */
  80706. export var kernelBlurFragment: {
  80707. name: string;
  80708. shader: string;
  80709. };
  80710. }
  80711. declare module BABYLON {
  80712. /** @hidden */
  80713. export var kernelBlurFragment2: {
  80714. name: string;
  80715. shader: string;
  80716. };
  80717. }
  80718. declare module BABYLON {
  80719. /** @hidden */
  80720. export var kernelBlurPixelShader: {
  80721. name: string;
  80722. shader: string;
  80723. };
  80724. }
  80725. declare module BABYLON {
  80726. /** @hidden */
  80727. export var kernelBlurVertex: {
  80728. name: string;
  80729. shader: string;
  80730. };
  80731. }
  80732. declare module BABYLON {
  80733. /** @hidden */
  80734. export var kernelBlurVertexShader: {
  80735. name: string;
  80736. shader: string;
  80737. };
  80738. }
  80739. declare module BABYLON {
  80740. /**
  80741. * The Blur Post Process which blurs an image based on a kernel and direction.
  80742. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80743. */
  80744. export class BlurPostProcess extends PostProcess {
  80745. /** The direction in which to blur the image. */
  80746. direction: Vector2;
  80747. private blockCompilation;
  80748. protected _kernel: number;
  80749. protected _idealKernel: number;
  80750. protected _packedFloat: boolean;
  80751. private _staticDefines;
  80752. /**
  80753. * Sets the length in pixels of the blur sample region
  80754. */
  80755. /**
  80756. * Gets the length in pixels of the blur sample region
  80757. */
  80758. kernel: number;
  80759. /**
  80760. * Sets wether or not the blur needs to unpack/repack floats
  80761. */
  80762. /**
  80763. * Gets wether or not the blur is unpacking/repacking floats
  80764. */
  80765. packedFloat: boolean;
  80766. /**
  80767. * Creates a new instance BlurPostProcess
  80768. * @param name The name of the effect.
  80769. * @param direction The direction in which to blur the image.
  80770. * @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.
  80771. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80772. * @param camera The camera to apply the render pass to.
  80773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80774. * @param engine The engine which the post process will be applied. (default: current engine)
  80775. * @param reusable If the post process can be reused on the same frame. (default: false)
  80776. * @param textureType Type of textures used when performing the post process. (default: 0)
  80777. * @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)
  80778. */
  80779. constructor(name: string,
  80780. /** The direction in which to blur the image. */
  80781. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80782. /**
  80783. * Updates the effect with the current post process compile time values and recompiles the shader.
  80784. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80785. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80786. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80787. * @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
  80788. * @param onCompiled Called when the shader has been compiled.
  80789. * @param onError Called if there is an error when compiling a shader.
  80790. */
  80791. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80792. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80793. /**
  80794. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80795. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80796. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80797. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80798. * The gaps between physical kernels are compensated for in the weighting of the samples
  80799. * @param idealKernel Ideal blur kernel.
  80800. * @return Nearest best kernel.
  80801. */
  80802. protected _nearestBestKernel(idealKernel: number): number;
  80803. /**
  80804. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80805. * @param x The point on the Gaussian distribution to sample.
  80806. * @return the value of the Gaussian function at x.
  80807. */
  80808. protected _gaussianWeight(x: number): number;
  80809. /**
  80810. * Generates a string that can be used as a floating point number in GLSL.
  80811. * @param x Value to print.
  80812. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80813. * @return GLSL float string.
  80814. */
  80815. protected _glslFloat(x: number, decimalFigures?: number): string;
  80816. }
  80817. }
  80818. declare module BABYLON {
  80819. /**
  80820. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80821. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80822. * You can then easily use it as a reflectionTexture on a flat surface.
  80823. * In case the surface is not a plane, please consider relying on reflection probes.
  80824. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80825. */
  80826. export class MirrorTexture extends RenderTargetTexture {
  80827. private scene;
  80828. /**
  80829. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80830. * 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.
  80831. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80832. */
  80833. mirrorPlane: Plane;
  80834. /**
  80835. * Define the blur ratio used to blur the reflection if needed.
  80836. */
  80837. blurRatio: number;
  80838. /**
  80839. * Define the adaptive blur kernel used to blur the reflection if needed.
  80840. * This will autocompute the closest best match for the `blurKernel`
  80841. */
  80842. adaptiveBlurKernel: number;
  80843. /**
  80844. * Define the blur kernel used to blur the reflection if needed.
  80845. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80846. */
  80847. blurKernel: number;
  80848. /**
  80849. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80850. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80851. */
  80852. blurKernelX: number;
  80853. /**
  80854. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80855. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80856. */
  80857. blurKernelY: number;
  80858. private _autoComputeBlurKernel;
  80859. protected _onRatioRescale(): void;
  80860. private _updateGammaSpace;
  80861. private _imageProcessingConfigChangeObserver;
  80862. private _transformMatrix;
  80863. private _mirrorMatrix;
  80864. private _savedViewMatrix;
  80865. private _blurX;
  80866. private _blurY;
  80867. private _adaptiveBlurKernel;
  80868. private _blurKernelX;
  80869. private _blurKernelY;
  80870. private _blurRatio;
  80871. /**
  80872. * Instantiates a Mirror Texture.
  80873. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80874. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80875. * You can then easily use it as a reflectionTexture on a flat surface.
  80876. * In case the surface is not a plane, please consider relying on reflection probes.
  80877. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80878. * @param name
  80879. * @param size
  80880. * @param scene
  80881. * @param generateMipMaps
  80882. * @param type
  80883. * @param samplingMode
  80884. * @param generateDepthBuffer
  80885. */
  80886. constructor(name: string, size: number | {
  80887. width: number;
  80888. height: number;
  80889. } | {
  80890. ratio: number;
  80891. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80892. private _preparePostProcesses;
  80893. /**
  80894. * Clone the mirror texture.
  80895. * @returns the cloned texture
  80896. */
  80897. clone(): MirrorTexture;
  80898. /**
  80899. * Serialize the texture to a JSON representation you could use in Parse later on
  80900. * @returns the serialized JSON representation
  80901. */
  80902. serialize(): any;
  80903. /**
  80904. * Dispose the texture and release its associated resources.
  80905. */
  80906. dispose(): void;
  80907. }
  80908. }
  80909. declare module BABYLON {
  80910. /**
  80911. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80912. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80913. */
  80914. export class Texture extends BaseTexture {
  80915. /** @hidden */
  80916. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80917. /** @hidden */
  80918. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80919. /** @hidden */
  80920. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80921. /** nearest is mag = nearest and min = nearest and mip = linear */
  80922. static readonly NEAREST_SAMPLINGMODE: number;
  80923. /** nearest is mag = nearest and min = nearest and mip = linear */
  80924. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80925. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80926. static readonly BILINEAR_SAMPLINGMODE: number;
  80927. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80928. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80929. /** Trilinear is mag = linear and min = linear and mip = linear */
  80930. static readonly TRILINEAR_SAMPLINGMODE: number;
  80931. /** Trilinear is mag = linear and min = linear and mip = linear */
  80932. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80933. /** mag = nearest and min = nearest and mip = nearest */
  80934. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80935. /** mag = nearest and min = linear and mip = nearest */
  80936. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80937. /** mag = nearest and min = linear and mip = linear */
  80938. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80939. /** mag = nearest and min = linear and mip = none */
  80940. static readonly NEAREST_LINEAR: number;
  80941. /** mag = nearest and min = nearest and mip = none */
  80942. static readonly NEAREST_NEAREST: number;
  80943. /** mag = linear and min = nearest and mip = nearest */
  80944. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80945. /** mag = linear and min = nearest and mip = linear */
  80946. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80947. /** mag = linear and min = linear and mip = none */
  80948. static readonly LINEAR_LINEAR: number;
  80949. /** mag = linear and min = nearest and mip = none */
  80950. static readonly LINEAR_NEAREST: number;
  80951. /** Explicit coordinates mode */
  80952. static readonly EXPLICIT_MODE: number;
  80953. /** Spherical coordinates mode */
  80954. static readonly SPHERICAL_MODE: number;
  80955. /** Planar coordinates mode */
  80956. static readonly PLANAR_MODE: number;
  80957. /** Cubic coordinates mode */
  80958. static readonly CUBIC_MODE: number;
  80959. /** Projection coordinates mode */
  80960. static readonly PROJECTION_MODE: number;
  80961. /** Inverse Cubic coordinates mode */
  80962. static readonly SKYBOX_MODE: number;
  80963. /** Inverse Cubic coordinates mode */
  80964. static readonly INVCUBIC_MODE: number;
  80965. /** Equirectangular coordinates mode */
  80966. static readonly EQUIRECTANGULAR_MODE: number;
  80967. /** Equirectangular Fixed coordinates mode */
  80968. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80969. /** Equirectangular Fixed Mirrored coordinates mode */
  80970. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80971. /** Texture is not repeating outside of 0..1 UVs */
  80972. static readonly CLAMP_ADDRESSMODE: number;
  80973. /** Texture is repeating outside of 0..1 UVs */
  80974. static readonly WRAP_ADDRESSMODE: number;
  80975. /** Texture is repeating and mirrored */
  80976. static readonly MIRROR_ADDRESSMODE: number;
  80977. /**
  80978. * 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
  80979. */
  80980. static UseSerializedUrlIfAny: boolean;
  80981. /**
  80982. * Define the url of the texture.
  80983. */
  80984. url: Nullable<string>;
  80985. /**
  80986. * Define an offset on the texture to offset the u coordinates of the UVs
  80987. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80988. */
  80989. uOffset: number;
  80990. /**
  80991. * Define an offset on the texture to offset the v coordinates of the UVs
  80992. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80993. */
  80994. vOffset: number;
  80995. /**
  80996. * Define an offset on the texture to scale the u coordinates of the UVs
  80997. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80998. */
  80999. uScale: number;
  81000. /**
  81001. * Define an offset on the texture to scale the v coordinates of the UVs
  81002. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81003. */
  81004. vScale: number;
  81005. /**
  81006. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81007. * @see http://doc.babylonjs.com/how_to/more_materials
  81008. */
  81009. uAng: number;
  81010. /**
  81011. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81012. * @see http://doc.babylonjs.com/how_to/more_materials
  81013. */
  81014. vAng: number;
  81015. /**
  81016. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81017. * @see http://doc.babylonjs.com/how_to/more_materials
  81018. */
  81019. wAng: number;
  81020. /**
  81021. * Defines the center of rotation (U)
  81022. */
  81023. uRotationCenter: number;
  81024. /**
  81025. * Defines the center of rotation (V)
  81026. */
  81027. vRotationCenter: number;
  81028. /**
  81029. * Defines the center of rotation (W)
  81030. */
  81031. wRotationCenter: number;
  81032. /**
  81033. * Are mip maps generated for this texture or not.
  81034. */
  81035. readonly noMipmap: boolean;
  81036. /**
  81037. * List of inspectable custom properties (used by the Inspector)
  81038. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81039. */
  81040. inspectableCustomProperties: Nullable<IInspectable[]>;
  81041. private _noMipmap;
  81042. /** @hidden */
  81043. _invertY: boolean;
  81044. private _rowGenerationMatrix;
  81045. private _cachedTextureMatrix;
  81046. private _projectionModeMatrix;
  81047. private _t0;
  81048. private _t1;
  81049. private _t2;
  81050. private _cachedUOffset;
  81051. private _cachedVOffset;
  81052. private _cachedUScale;
  81053. private _cachedVScale;
  81054. private _cachedUAng;
  81055. private _cachedVAng;
  81056. private _cachedWAng;
  81057. private _cachedProjectionMatrixId;
  81058. private _cachedCoordinatesMode;
  81059. /** @hidden */
  81060. protected _initialSamplingMode: number;
  81061. /** @hidden */
  81062. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81063. private _deleteBuffer;
  81064. protected _format: Nullable<number>;
  81065. private _delayedOnLoad;
  81066. private _delayedOnError;
  81067. /**
  81068. * Observable triggered once the texture has been loaded.
  81069. */
  81070. onLoadObservable: Observable<Texture>;
  81071. protected _isBlocking: boolean;
  81072. /**
  81073. * Is the texture preventing material to render while loading.
  81074. * If false, a default texture will be used instead of the loading one during the preparation step.
  81075. */
  81076. isBlocking: boolean;
  81077. /**
  81078. * Get the current sampling mode associated with the texture.
  81079. */
  81080. readonly samplingMode: number;
  81081. /**
  81082. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81083. */
  81084. readonly invertY: boolean;
  81085. /**
  81086. * Instantiates a new texture.
  81087. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81088. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81089. * @param url define the url of the picture to load as a texture
  81090. * @param scene define the scene the texture will belong to
  81091. * @param noMipmap define if the texture will require mip maps or not
  81092. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81093. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81094. * @param onLoad define a callback triggered when the texture has been loaded
  81095. * @param onError define a callback triggered when an error occurred during the loading session
  81096. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81097. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81098. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81099. */
  81100. 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);
  81101. /**
  81102. * Update the url (and optional buffer) of this texture if url was null during construction.
  81103. * @param url the url of the texture
  81104. * @param buffer the buffer of the texture (defaults to null)
  81105. * @param onLoad callback called when the texture is loaded (defaults to null)
  81106. */
  81107. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81108. /**
  81109. * Finish the loading sequence of a texture flagged as delayed load.
  81110. * @hidden
  81111. */
  81112. delayLoad(): void;
  81113. private _prepareRowForTextureGeneration;
  81114. /**
  81115. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81116. * @returns the transform matrix of the texture.
  81117. */
  81118. getTextureMatrix(): Matrix;
  81119. /**
  81120. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81121. * @returns The reflection texture transform
  81122. */
  81123. getReflectionTextureMatrix(): Matrix;
  81124. /**
  81125. * Clones the texture.
  81126. * @returns the cloned texture
  81127. */
  81128. clone(): Texture;
  81129. /**
  81130. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81131. * @returns The JSON representation of the texture
  81132. */
  81133. serialize(): any;
  81134. /**
  81135. * Get the current class name of the texture useful for serialization or dynamic coding.
  81136. * @returns "Texture"
  81137. */
  81138. getClassName(): string;
  81139. /**
  81140. * Dispose the texture and release its associated resources.
  81141. */
  81142. dispose(): void;
  81143. /**
  81144. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81145. * @param parsedTexture Define the JSON representation of the texture
  81146. * @param scene Define the scene the parsed texture should be instantiated in
  81147. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81148. * @returns The parsed texture if successful
  81149. */
  81150. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81151. /**
  81152. * Creates a texture from its base 64 representation.
  81153. * @param data Define the base64 payload without the data: prefix
  81154. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81155. * @param scene Define the scene the texture should belong to
  81156. * @param noMipmap Forces the texture to not create mip map information if true
  81157. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81158. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81159. * @param onLoad define a callback triggered when the texture has been loaded
  81160. * @param onError define a callback triggered when an error occurred during the loading session
  81161. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81162. * @returns the created texture
  81163. */
  81164. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81165. /**
  81166. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81167. * @param data Define the base64 payload without the data: prefix
  81168. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81169. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81170. * @param scene Define the scene the texture should belong to
  81171. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81172. * @param noMipmap Forces the texture to not create mip map information if true
  81173. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81174. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81175. * @param onLoad define a callback triggered when the texture has been loaded
  81176. * @param onError define a callback triggered when an error occurred during the loading session
  81177. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81178. * @returns the created texture
  81179. */
  81180. 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;
  81181. }
  81182. }
  81183. declare module BABYLON {
  81184. /**
  81185. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81186. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81187. */
  81188. export class PostProcessManager {
  81189. private _scene;
  81190. private _indexBuffer;
  81191. private _vertexBuffers;
  81192. /**
  81193. * Creates a new instance PostProcess
  81194. * @param scene The scene that the post process is associated with.
  81195. */
  81196. constructor(scene: Scene);
  81197. private _prepareBuffers;
  81198. private _buildIndexBuffer;
  81199. /**
  81200. * Rebuilds the vertex buffers of the manager.
  81201. * @hidden
  81202. */
  81203. _rebuild(): void;
  81204. /**
  81205. * Prepares a frame to be run through a post process.
  81206. * @param sourceTexture The input texture to the post procesess. (default: null)
  81207. * @param postProcesses An array of post processes to be run. (default: null)
  81208. * @returns True if the post processes were able to be run.
  81209. * @hidden
  81210. */
  81211. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81212. /**
  81213. * Manually render a set of post processes to a texture.
  81214. * @param postProcesses An array of post processes to be run.
  81215. * @param targetTexture The target texture to render to.
  81216. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81217. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81218. * @param lodLevel defines which lod of the texture to render to
  81219. */
  81220. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81221. /**
  81222. * Finalize the result of the output of the postprocesses.
  81223. * @param doNotPresent If true the result will not be displayed to the screen.
  81224. * @param targetTexture The target texture to render to.
  81225. * @param faceIndex The index of the face to bind the target texture to.
  81226. * @param postProcesses The array of post processes to render.
  81227. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81228. * @hidden
  81229. */
  81230. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81231. /**
  81232. * Disposes of the post process manager.
  81233. */
  81234. dispose(): void;
  81235. }
  81236. }
  81237. declare module BABYLON {
  81238. interface AbstractScene {
  81239. /**
  81240. * The list of procedural textures added to the scene
  81241. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81242. */
  81243. proceduralTextures: Array<ProceduralTexture>;
  81244. }
  81245. /**
  81246. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81247. * in a given scene.
  81248. */
  81249. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81250. /**
  81251. * The component name helpfull to identify the component in the list of scene components.
  81252. */
  81253. readonly name: string;
  81254. /**
  81255. * The scene the component belongs to.
  81256. */
  81257. scene: Scene;
  81258. /**
  81259. * Creates a new instance of the component for the given scene
  81260. * @param scene Defines the scene to register the component in
  81261. */
  81262. constructor(scene: Scene);
  81263. /**
  81264. * Registers the component in a given scene
  81265. */
  81266. register(): void;
  81267. /**
  81268. * Rebuilds the elements related to this component in case of
  81269. * context lost for instance.
  81270. */
  81271. rebuild(): void;
  81272. /**
  81273. * Disposes the component and the associated ressources.
  81274. */
  81275. dispose(): void;
  81276. private _beforeClear;
  81277. }
  81278. }
  81279. declare module BABYLON {
  81280. interface Engine {
  81281. /**
  81282. * Creates a new render target cube texture
  81283. * @param size defines the size of the texture
  81284. * @param options defines the options used to create the texture
  81285. * @returns a new render target cube texture stored in an InternalTexture
  81286. */
  81287. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81288. }
  81289. }
  81290. declare module BABYLON {
  81291. /** @hidden */
  81292. export var proceduralVertexShader: {
  81293. name: string;
  81294. shader: string;
  81295. };
  81296. }
  81297. declare module BABYLON {
  81298. /**
  81299. * 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.
  81300. * This is the base class of any Procedural texture and contains most of the shareable code.
  81301. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81302. */
  81303. export class ProceduralTexture extends Texture {
  81304. isCube: boolean;
  81305. /**
  81306. * Define if the texture is enabled or not (disabled texture will not render)
  81307. */
  81308. isEnabled: boolean;
  81309. /**
  81310. * Define if the texture must be cleared before rendering (default is true)
  81311. */
  81312. autoClear: boolean;
  81313. /**
  81314. * Callback called when the texture is generated
  81315. */
  81316. onGenerated: () => void;
  81317. /**
  81318. * Event raised when the texture is generated
  81319. */
  81320. onGeneratedObservable: Observable<ProceduralTexture>;
  81321. /** @hidden */
  81322. _generateMipMaps: boolean;
  81323. /** @hidden **/
  81324. _effect: Effect;
  81325. /** @hidden */
  81326. _textures: {
  81327. [key: string]: Texture;
  81328. };
  81329. private _size;
  81330. private _currentRefreshId;
  81331. private _refreshRate;
  81332. private _vertexBuffers;
  81333. private _indexBuffer;
  81334. private _uniforms;
  81335. private _samplers;
  81336. private _fragment;
  81337. private _floats;
  81338. private _ints;
  81339. private _floatsArrays;
  81340. private _colors3;
  81341. private _colors4;
  81342. private _vectors2;
  81343. private _vectors3;
  81344. private _matrices;
  81345. private _fallbackTexture;
  81346. private _fallbackTextureUsed;
  81347. private _engine;
  81348. private _cachedDefines;
  81349. private _contentUpdateId;
  81350. private _contentData;
  81351. /**
  81352. * Instantiates a new procedural texture.
  81353. * 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.
  81354. * This is the base class of any Procedural texture and contains most of the shareable code.
  81355. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81356. * @param name Define the name of the texture
  81357. * @param size Define the size of the texture to create
  81358. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81359. * @param scene Define the scene the texture belongs to
  81360. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81361. * @param generateMipMaps Define if the texture should creates mip maps or not
  81362. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81363. */
  81364. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81365. /**
  81366. * The effect that is created when initializing the post process.
  81367. * @returns The created effect corresponding the the postprocess.
  81368. */
  81369. getEffect(): Effect;
  81370. /**
  81371. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81372. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81373. */
  81374. getContent(): Nullable<ArrayBufferView>;
  81375. private _createIndexBuffer;
  81376. /** @hidden */
  81377. _rebuild(): void;
  81378. /**
  81379. * Resets the texture in order to recreate its associated resources.
  81380. * This can be called in case of context loss
  81381. */
  81382. reset(): void;
  81383. protected _getDefines(): string;
  81384. /**
  81385. * Is the texture ready to be used ? (rendered at least once)
  81386. * @returns true if ready, otherwise, false.
  81387. */
  81388. isReady(): boolean;
  81389. /**
  81390. * Resets the refresh counter of the texture and start bak from scratch.
  81391. * Could be useful to regenerate the texture if it is setup to render only once.
  81392. */
  81393. resetRefreshCounter(): void;
  81394. /**
  81395. * Set the fragment shader to use in order to render the texture.
  81396. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81397. */
  81398. setFragment(fragment: any): void;
  81399. /**
  81400. * Define the refresh rate of the texture or the rendering frequency.
  81401. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81402. */
  81403. refreshRate: number;
  81404. /** @hidden */
  81405. _shouldRender(): boolean;
  81406. /**
  81407. * Get the size the texture is rendering at.
  81408. * @returns the size (texture is always squared)
  81409. */
  81410. getRenderSize(): number;
  81411. /**
  81412. * Resize the texture to new value.
  81413. * @param size Define the new size the texture should have
  81414. * @param generateMipMaps Define whether the new texture should create mip maps
  81415. */
  81416. resize(size: number, generateMipMaps: boolean): void;
  81417. private _checkUniform;
  81418. /**
  81419. * Set a texture in the shader program used to render.
  81420. * @param name Define the name of the uniform samplers as defined in the shader
  81421. * @param texture Define the texture to bind to this sampler
  81422. * @return the texture itself allowing "fluent" like uniform updates
  81423. */
  81424. setTexture(name: string, texture: Texture): ProceduralTexture;
  81425. /**
  81426. * Set a float in the shader.
  81427. * @param name Define the name of the uniform as defined in the shader
  81428. * @param value Define the value to give to the uniform
  81429. * @return the texture itself allowing "fluent" like uniform updates
  81430. */
  81431. setFloat(name: string, value: number): ProceduralTexture;
  81432. /**
  81433. * Set a int in the shader.
  81434. * @param name Define the name of the uniform as defined in the shader
  81435. * @param value Define the value to give to the uniform
  81436. * @return the texture itself allowing "fluent" like uniform updates
  81437. */
  81438. setInt(name: string, value: number): ProceduralTexture;
  81439. /**
  81440. * Set an array of floats in the shader.
  81441. * @param name Define the name of the uniform as defined in the shader
  81442. * @param value Define the value to give to the uniform
  81443. * @return the texture itself allowing "fluent" like uniform updates
  81444. */
  81445. setFloats(name: string, value: number[]): ProceduralTexture;
  81446. /**
  81447. * Set a vec3 in the shader from a Color3.
  81448. * @param name Define the name of the uniform as defined in the shader
  81449. * @param value Define the value to give to the uniform
  81450. * @return the texture itself allowing "fluent" like uniform updates
  81451. */
  81452. setColor3(name: string, value: Color3): ProceduralTexture;
  81453. /**
  81454. * Set a vec4 in the shader from a Color4.
  81455. * @param name Define the name of the uniform as defined in the shader
  81456. * @param value Define the value to give to the uniform
  81457. * @return the texture itself allowing "fluent" like uniform updates
  81458. */
  81459. setColor4(name: string, value: Color4): ProceduralTexture;
  81460. /**
  81461. * Set a vec2 in the shader from a Vector2.
  81462. * @param name Define the name of the uniform as defined in the shader
  81463. * @param value Define the value to give to the uniform
  81464. * @return the texture itself allowing "fluent" like uniform updates
  81465. */
  81466. setVector2(name: string, value: Vector2): ProceduralTexture;
  81467. /**
  81468. * Set a vec3 in the shader from a Vector3.
  81469. * @param name Define the name of the uniform as defined in the shader
  81470. * @param value Define the value to give to the uniform
  81471. * @return the texture itself allowing "fluent" like uniform updates
  81472. */
  81473. setVector3(name: string, value: Vector3): ProceduralTexture;
  81474. /**
  81475. * Set a mat4 in the shader from a MAtrix.
  81476. * @param name Define the name of the uniform as defined in the shader
  81477. * @param value Define the value to give to the uniform
  81478. * @return the texture itself allowing "fluent" like uniform updates
  81479. */
  81480. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81481. /**
  81482. * Render the texture to its associated render target.
  81483. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81484. */
  81485. render(useCameraPostProcess?: boolean): void;
  81486. /**
  81487. * Clone the texture.
  81488. * @returns the cloned texture
  81489. */
  81490. clone(): ProceduralTexture;
  81491. /**
  81492. * Dispose the texture and release its asoociated resources.
  81493. */
  81494. dispose(): void;
  81495. }
  81496. }
  81497. declare module BABYLON {
  81498. /**
  81499. * This represents the base class for particle system in Babylon.
  81500. * 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.
  81501. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81502. * @example https://doc.babylonjs.com/babylon101/particles
  81503. */
  81504. export class BaseParticleSystem {
  81505. /**
  81506. * Source color is added to the destination color without alpha affecting the result
  81507. */
  81508. static BLENDMODE_ONEONE: number;
  81509. /**
  81510. * Blend current color and particle color using particle’s alpha
  81511. */
  81512. static BLENDMODE_STANDARD: number;
  81513. /**
  81514. * Add current color and particle color multiplied by particle’s alpha
  81515. */
  81516. static BLENDMODE_ADD: number;
  81517. /**
  81518. * Multiply current color with particle color
  81519. */
  81520. static BLENDMODE_MULTIPLY: number;
  81521. /**
  81522. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81523. */
  81524. static BLENDMODE_MULTIPLYADD: number;
  81525. /**
  81526. * List of animations used by the particle system.
  81527. */
  81528. animations: Animation[];
  81529. /**
  81530. * The id of the Particle system.
  81531. */
  81532. id: string;
  81533. /**
  81534. * The friendly name of the Particle system.
  81535. */
  81536. name: string;
  81537. /**
  81538. * The rendering group used by the Particle system to chose when to render.
  81539. */
  81540. renderingGroupId: number;
  81541. /**
  81542. * The emitter represents the Mesh or position we are attaching the particle system to.
  81543. */
  81544. emitter: Nullable<AbstractMesh | Vector3>;
  81545. /**
  81546. * The maximum number of particles to emit per frame
  81547. */
  81548. emitRate: number;
  81549. /**
  81550. * If you want to launch only a few particles at once, that can be done, as well.
  81551. */
  81552. manualEmitCount: number;
  81553. /**
  81554. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81555. */
  81556. updateSpeed: number;
  81557. /**
  81558. * The amount of time the particle system is running (depends of the overall update speed).
  81559. */
  81560. targetStopDuration: number;
  81561. /**
  81562. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81563. */
  81564. disposeOnStop: boolean;
  81565. /**
  81566. * Minimum power of emitting particles.
  81567. */
  81568. minEmitPower: number;
  81569. /**
  81570. * Maximum power of emitting particles.
  81571. */
  81572. maxEmitPower: number;
  81573. /**
  81574. * Minimum life time of emitting particles.
  81575. */
  81576. minLifeTime: number;
  81577. /**
  81578. * Maximum life time of emitting particles.
  81579. */
  81580. maxLifeTime: number;
  81581. /**
  81582. * Minimum Size of emitting particles.
  81583. */
  81584. minSize: number;
  81585. /**
  81586. * Maximum Size of emitting particles.
  81587. */
  81588. maxSize: number;
  81589. /**
  81590. * Minimum scale of emitting particles on X axis.
  81591. */
  81592. minScaleX: number;
  81593. /**
  81594. * Maximum scale of emitting particles on X axis.
  81595. */
  81596. maxScaleX: number;
  81597. /**
  81598. * Minimum scale of emitting particles on Y axis.
  81599. */
  81600. minScaleY: number;
  81601. /**
  81602. * Maximum scale of emitting particles on Y axis.
  81603. */
  81604. maxScaleY: number;
  81605. /**
  81606. * Gets or sets the minimal initial rotation in radians.
  81607. */
  81608. minInitialRotation: number;
  81609. /**
  81610. * Gets or sets the maximal initial rotation in radians.
  81611. */
  81612. maxInitialRotation: number;
  81613. /**
  81614. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81615. */
  81616. minAngularSpeed: number;
  81617. /**
  81618. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81619. */
  81620. maxAngularSpeed: number;
  81621. /**
  81622. * The texture used to render each particle. (this can be a spritesheet)
  81623. */
  81624. particleTexture: Nullable<Texture>;
  81625. /**
  81626. * The layer mask we are rendering the particles through.
  81627. */
  81628. layerMask: number;
  81629. /**
  81630. * This can help using your own shader to render the particle system.
  81631. * The according effect will be created
  81632. */
  81633. customShader: any;
  81634. /**
  81635. * By default particle system starts as soon as they are created. This prevents the
  81636. * automatic start to happen and let you decide when to start emitting particles.
  81637. */
  81638. preventAutoStart: boolean;
  81639. private _noiseTexture;
  81640. /**
  81641. * Gets or sets a texture used to add random noise to particle positions
  81642. */
  81643. noiseTexture: Nullable<ProceduralTexture>;
  81644. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81645. noiseStrength: Vector3;
  81646. /**
  81647. * Callback triggered when the particle animation is ending.
  81648. */
  81649. onAnimationEnd: Nullable<() => void>;
  81650. /**
  81651. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81652. */
  81653. blendMode: number;
  81654. /**
  81655. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81656. * to override the particles.
  81657. */
  81658. forceDepthWrite: boolean;
  81659. /** 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 */
  81660. preWarmCycles: number;
  81661. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81662. preWarmStepOffset: number;
  81663. /**
  81664. * 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)
  81665. */
  81666. spriteCellChangeSpeed: number;
  81667. /**
  81668. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81669. */
  81670. startSpriteCellID: number;
  81671. /**
  81672. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81673. */
  81674. endSpriteCellID: number;
  81675. /**
  81676. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81677. */
  81678. spriteCellWidth: number;
  81679. /**
  81680. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81681. */
  81682. spriteCellHeight: number;
  81683. /**
  81684. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81685. */
  81686. spriteRandomStartCell: boolean;
  81687. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81688. translationPivot: Vector2;
  81689. /** @hidden */
  81690. protected _isAnimationSheetEnabled: boolean;
  81691. /**
  81692. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81693. */
  81694. beginAnimationOnStart: boolean;
  81695. /**
  81696. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81697. */
  81698. beginAnimationFrom: number;
  81699. /**
  81700. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81701. */
  81702. beginAnimationTo: number;
  81703. /**
  81704. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81705. */
  81706. beginAnimationLoop: boolean;
  81707. /**
  81708. * Gets or sets a world offset applied to all particles
  81709. */
  81710. worldOffset: Vector3;
  81711. /**
  81712. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81713. */
  81714. isAnimationSheetEnabled: boolean;
  81715. /**
  81716. * Get hosting scene
  81717. * @returns the scene
  81718. */
  81719. getScene(): Scene;
  81720. /**
  81721. * You can use gravity if you want to give an orientation to your particles.
  81722. */
  81723. gravity: Vector3;
  81724. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81725. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81726. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81727. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81728. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81729. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81730. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81731. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81732. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81733. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81734. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81735. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81736. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81737. /**
  81738. * Defines the delay in milliseconds before starting the system (0 by default)
  81739. */
  81740. startDelay: number;
  81741. /**
  81742. * Gets the current list of drag gradients.
  81743. * You must use addDragGradient and removeDragGradient to udpate this list
  81744. * @returns the list of drag gradients
  81745. */
  81746. getDragGradients(): Nullable<Array<FactorGradient>>;
  81747. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81748. limitVelocityDamping: number;
  81749. /**
  81750. * Gets the current list of limit velocity gradients.
  81751. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81752. * @returns the list of limit velocity gradients
  81753. */
  81754. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81755. /**
  81756. * Gets the current list of color gradients.
  81757. * You must use addColorGradient and removeColorGradient to udpate this list
  81758. * @returns the list of color gradients
  81759. */
  81760. getColorGradients(): Nullable<Array<ColorGradient>>;
  81761. /**
  81762. * Gets the current list of size gradients.
  81763. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81764. * @returns the list of size gradients
  81765. */
  81766. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81767. /**
  81768. * Gets the current list of color remap gradients.
  81769. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81770. * @returns the list of color remap gradients
  81771. */
  81772. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81773. /**
  81774. * Gets the current list of alpha remap gradients.
  81775. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81776. * @returns the list of alpha remap gradients
  81777. */
  81778. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81779. /**
  81780. * Gets the current list of life time gradients.
  81781. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81782. * @returns the list of life time gradients
  81783. */
  81784. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81785. /**
  81786. * Gets the current list of angular speed gradients.
  81787. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81788. * @returns the list of angular speed gradients
  81789. */
  81790. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81791. /**
  81792. * Gets the current list of velocity gradients.
  81793. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81794. * @returns the list of velocity gradients
  81795. */
  81796. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81797. /**
  81798. * Gets the current list of start size gradients.
  81799. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81800. * @returns the list of start size gradients
  81801. */
  81802. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81803. /**
  81804. * Gets the current list of emit rate gradients.
  81805. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81806. * @returns the list of emit rate gradients
  81807. */
  81808. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81809. /**
  81810. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81811. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81812. */
  81813. direction1: Vector3;
  81814. /**
  81815. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81816. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81817. */
  81818. direction2: Vector3;
  81819. /**
  81820. * 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.
  81821. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81822. */
  81823. minEmitBox: Vector3;
  81824. /**
  81825. * 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.
  81826. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81827. */
  81828. maxEmitBox: Vector3;
  81829. /**
  81830. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81831. */
  81832. color1: Color4;
  81833. /**
  81834. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81835. */
  81836. color2: Color4;
  81837. /**
  81838. * Color the particle will have at the end of its lifetime
  81839. */
  81840. colorDead: Color4;
  81841. /**
  81842. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81843. */
  81844. textureMask: Color4;
  81845. /**
  81846. * The particle emitter type defines the emitter used by the particle system.
  81847. * It can be for example box, sphere, or cone...
  81848. */
  81849. particleEmitterType: IParticleEmitterType;
  81850. /** @hidden */
  81851. _isSubEmitter: boolean;
  81852. /**
  81853. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81854. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81855. */
  81856. billboardMode: number;
  81857. protected _isBillboardBased: boolean;
  81858. /**
  81859. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81860. */
  81861. isBillboardBased: boolean;
  81862. /**
  81863. * The scene the particle system belongs to.
  81864. */
  81865. protected _scene: Scene;
  81866. /**
  81867. * Local cache of defines for image processing.
  81868. */
  81869. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81870. /**
  81871. * Default configuration related to image processing available in the standard Material.
  81872. */
  81873. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81874. /**
  81875. * Gets the image processing configuration used either in this material.
  81876. */
  81877. /**
  81878. * Sets the Default image processing configuration used either in the this material.
  81879. *
  81880. * If sets to null, the scene one is in use.
  81881. */
  81882. imageProcessingConfiguration: ImageProcessingConfiguration;
  81883. /**
  81884. * Attaches a new image processing configuration to the Standard Material.
  81885. * @param configuration
  81886. */
  81887. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81888. /** @hidden */
  81889. protected _reset(): void;
  81890. /** @hidden */
  81891. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81892. /**
  81893. * Instantiates a particle system.
  81894. * 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.
  81895. * @param name The name of the particle system
  81896. */
  81897. constructor(name: string);
  81898. /**
  81899. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81900. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81901. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81902. * @returns the emitter
  81903. */
  81904. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81905. /**
  81906. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81907. * @param radius The radius of the hemisphere to emit from
  81908. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81909. * @returns the emitter
  81910. */
  81911. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81912. /**
  81913. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81914. * @param radius The radius of the sphere to emit from
  81915. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81916. * @returns the emitter
  81917. */
  81918. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81919. /**
  81920. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81921. * @param radius The radius of the sphere to emit from
  81922. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81923. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81924. * @returns the emitter
  81925. */
  81926. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81927. /**
  81928. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81929. * @param radius The radius of the emission cylinder
  81930. * @param height The height of the emission cylinder
  81931. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81932. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81933. * @returns the emitter
  81934. */
  81935. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  81936. /**
  81937. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81938. * @param radius The radius of the cylinder to emit from
  81939. * @param height The height of the emission cylinder
  81940. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81941. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81942. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81943. * @returns the emitter
  81944. */
  81945. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  81946. /**
  81947. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81948. * @param radius The radius of the cone to emit from
  81949. * @param angle The base angle of the cone
  81950. * @returns the emitter
  81951. */
  81952. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  81953. /**
  81954. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81957. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81958. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81959. * @returns the emitter
  81960. */
  81961. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81962. }
  81963. }
  81964. declare module BABYLON {
  81965. /**
  81966. * Type of sub emitter
  81967. */
  81968. export enum SubEmitterType {
  81969. /**
  81970. * Attached to the particle over it's lifetime
  81971. */
  81972. ATTACHED = 0,
  81973. /**
  81974. * Created when the particle dies
  81975. */
  81976. END = 1
  81977. }
  81978. /**
  81979. * Sub emitter class used to emit particles from an existing particle
  81980. */
  81981. export class SubEmitter {
  81982. /**
  81983. * the particle system to be used by the sub emitter
  81984. */
  81985. particleSystem: ParticleSystem;
  81986. /**
  81987. * Type of the submitter (Default: END)
  81988. */
  81989. type: SubEmitterType;
  81990. /**
  81991. * 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)
  81992. * Note: This only is supported when using an emitter of type Mesh
  81993. */
  81994. inheritDirection: boolean;
  81995. /**
  81996. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  81997. */
  81998. inheritedVelocityAmount: number;
  81999. /**
  82000. * Creates a sub emitter
  82001. * @param particleSystem the particle system to be used by the sub emitter
  82002. */
  82003. constructor(
  82004. /**
  82005. * the particle system to be used by the sub emitter
  82006. */
  82007. particleSystem: ParticleSystem);
  82008. /**
  82009. * Clones the sub emitter
  82010. * @returns the cloned sub emitter
  82011. */
  82012. clone(): SubEmitter;
  82013. /**
  82014. * Serialize current object to a JSON object
  82015. * @returns the serialized object
  82016. */
  82017. serialize(): any;
  82018. /** @hidden */
  82019. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82020. /**
  82021. * Creates a new SubEmitter from a serialized JSON version
  82022. * @param serializationObject defines the JSON object to read from
  82023. * @param scene defines the hosting scene
  82024. * @param rootUrl defines the rootUrl for data loading
  82025. * @returns a new SubEmitter
  82026. */
  82027. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82028. /** Release associated resources */
  82029. dispose(): void;
  82030. }
  82031. }
  82032. declare module BABYLON {
  82033. /** @hidden */
  82034. export var imageProcessingDeclaration: {
  82035. name: string;
  82036. shader: string;
  82037. };
  82038. }
  82039. declare module BABYLON {
  82040. /** @hidden */
  82041. export var imageProcessingFunctions: {
  82042. name: string;
  82043. shader: string;
  82044. };
  82045. }
  82046. declare module BABYLON {
  82047. /** @hidden */
  82048. export var particlesPixelShader: {
  82049. name: string;
  82050. shader: string;
  82051. };
  82052. }
  82053. declare module BABYLON {
  82054. /** @hidden */
  82055. export var particlesVertexShader: {
  82056. name: string;
  82057. shader: string;
  82058. };
  82059. }
  82060. declare module BABYLON {
  82061. /**
  82062. * This represents a particle system in Babylon.
  82063. * 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.
  82064. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82065. * @example https://doc.babylonjs.com/babylon101/particles
  82066. */
  82067. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82068. /**
  82069. * Billboard mode will only apply to Y axis
  82070. */
  82071. static readonly BILLBOARDMODE_Y: number;
  82072. /**
  82073. * Billboard mode will apply to all axes
  82074. */
  82075. static readonly BILLBOARDMODE_ALL: number;
  82076. /**
  82077. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82078. */
  82079. static readonly BILLBOARDMODE_STRETCHED: number;
  82080. /**
  82081. * This function can be defined to provide custom update for active particles.
  82082. * This function will be called instead of regular update (age, position, color, etc.).
  82083. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82084. */
  82085. updateFunction: (particles: Particle[]) => void;
  82086. private _emitterWorldMatrix;
  82087. /**
  82088. * This function can be defined to specify initial direction for every new particle.
  82089. * It by default use the emitterType defined function
  82090. */
  82091. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82092. /**
  82093. * This function can be defined to specify initial position for every new particle.
  82094. * It by default use the emitterType defined function
  82095. */
  82096. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82097. /**
  82098. * @hidden
  82099. */
  82100. _inheritedVelocityOffset: Vector3;
  82101. /**
  82102. * An event triggered when the system is disposed
  82103. */
  82104. onDisposeObservable: Observable<ParticleSystem>;
  82105. private _onDisposeObserver;
  82106. /**
  82107. * Sets a callback that will be triggered when the system is disposed
  82108. */
  82109. onDispose: () => void;
  82110. private _particles;
  82111. private _epsilon;
  82112. private _capacity;
  82113. private _stockParticles;
  82114. private _newPartsExcess;
  82115. private _vertexData;
  82116. private _vertexBuffer;
  82117. private _vertexBuffers;
  82118. private _spriteBuffer;
  82119. private _indexBuffer;
  82120. private _effect;
  82121. private _customEffect;
  82122. private _cachedDefines;
  82123. private _scaledColorStep;
  82124. private _colorDiff;
  82125. private _scaledDirection;
  82126. private _scaledGravity;
  82127. private _currentRenderId;
  82128. private _alive;
  82129. private _useInstancing;
  82130. private _started;
  82131. private _stopped;
  82132. private _actualFrame;
  82133. private _scaledUpdateSpeed;
  82134. private _vertexBufferSize;
  82135. /** @hidden */
  82136. _currentEmitRateGradient: Nullable<FactorGradient>;
  82137. /** @hidden */
  82138. _currentEmitRate1: number;
  82139. /** @hidden */
  82140. _currentEmitRate2: number;
  82141. /** @hidden */
  82142. _currentStartSizeGradient: Nullable<FactorGradient>;
  82143. /** @hidden */
  82144. _currentStartSize1: number;
  82145. /** @hidden */
  82146. _currentStartSize2: number;
  82147. private readonly _rawTextureWidth;
  82148. private _rampGradientsTexture;
  82149. private _useRampGradients;
  82150. /** Gets or sets a boolean indicating that ramp gradients must be used
  82151. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82152. */
  82153. useRampGradients: boolean;
  82154. /**
  82155. * 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.
  82156. * 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: [])
  82157. */
  82158. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82159. private _subEmitters;
  82160. /**
  82161. * @hidden
  82162. * If the particle systems emitter should be disposed when the particle system is disposed
  82163. */
  82164. _disposeEmitterOnDispose: boolean;
  82165. /**
  82166. * The current active Sub-systems, this property is used by the root particle system only.
  82167. */
  82168. activeSubSystems: Array<ParticleSystem>;
  82169. private _rootParticleSystem;
  82170. /**
  82171. * Gets the current list of active particles
  82172. */
  82173. readonly particles: Particle[];
  82174. /**
  82175. * Returns the string "ParticleSystem"
  82176. * @returns a string containing the class name
  82177. */
  82178. getClassName(): string;
  82179. /**
  82180. * Instantiates a particle system.
  82181. * 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.
  82182. * @param name The name of the particle system
  82183. * @param capacity The max number of particles alive at the same time
  82184. * @param scene The scene the particle system belongs to
  82185. * @param customEffect a custom effect used to change the way particles are rendered by default
  82186. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82187. * @param epsilon Offset used to render the particles
  82188. */
  82189. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82190. private _addFactorGradient;
  82191. private _removeFactorGradient;
  82192. /**
  82193. * Adds a new life time gradient
  82194. * @param gradient defines the gradient to use (between 0 and 1)
  82195. * @param factor defines the life time factor to affect to the specified gradient
  82196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82197. * @returns the current particle system
  82198. */
  82199. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82200. /**
  82201. * Remove a specific life time gradient
  82202. * @param gradient defines the gradient to remove
  82203. * @returns the current particle system
  82204. */
  82205. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82206. /**
  82207. * Adds a new size gradient
  82208. * @param gradient defines the gradient to use (between 0 and 1)
  82209. * @param factor defines the size factor to affect to the specified gradient
  82210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82211. * @returns the current particle system
  82212. */
  82213. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82214. /**
  82215. * Remove a specific size gradient
  82216. * @param gradient defines the gradient to remove
  82217. * @returns the current particle system
  82218. */
  82219. removeSizeGradient(gradient: number): IParticleSystem;
  82220. /**
  82221. * Adds a new color remap gradient
  82222. * @param gradient defines the gradient to use (between 0 and 1)
  82223. * @param min defines the color remap minimal range
  82224. * @param max defines the color remap maximal range
  82225. * @returns the current particle system
  82226. */
  82227. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82228. /**
  82229. * Remove a specific color remap gradient
  82230. * @param gradient defines the gradient to remove
  82231. * @returns the current particle system
  82232. */
  82233. removeColorRemapGradient(gradient: number): IParticleSystem;
  82234. /**
  82235. * Adds a new alpha remap gradient
  82236. * @param gradient defines the gradient to use (between 0 and 1)
  82237. * @param min defines the alpha remap minimal range
  82238. * @param max defines the alpha remap maximal range
  82239. * @returns the current particle system
  82240. */
  82241. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82242. /**
  82243. * Remove a specific alpha remap gradient
  82244. * @param gradient defines the gradient to remove
  82245. * @returns the current particle system
  82246. */
  82247. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82248. /**
  82249. * Adds a new angular speed gradient
  82250. * @param gradient defines the gradient to use (between 0 and 1)
  82251. * @param factor defines the angular speed to affect to the specified gradient
  82252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82253. * @returns the current particle system
  82254. */
  82255. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82256. /**
  82257. * Remove a specific angular speed gradient
  82258. * @param gradient defines the gradient to remove
  82259. * @returns the current particle system
  82260. */
  82261. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82262. /**
  82263. * Adds a new velocity gradient
  82264. * @param gradient defines the gradient to use (between 0 and 1)
  82265. * @param factor defines the velocity to affect to the specified gradient
  82266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82267. * @returns the current particle system
  82268. */
  82269. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82270. /**
  82271. * Remove a specific velocity gradient
  82272. * @param gradient defines the gradient to remove
  82273. * @returns the current particle system
  82274. */
  82275. removeVelocityGradient(gradient: number): IParticleSystem;
  82276. /**
  82277. * Adds a new limit velocity gradient
  82278. * @param gradient defines the gradient to use (between 0 and 1)
  82279. * @param factor defines the limit velocity value to affect to the specified gradient
  82280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82281. * @returns the current particle system
  82282. */
  82283. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82284. /**
  82285. * Remove a specific limit velocity gradient
  82286. * @param gradient defines the gradient to remove
  82287. * @returns the current particle system
  82288. */
  82289. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82290. /**
  82291. * Adds a new drag gradient
  82292. * @param gradient defines the gradient to use (between 0 and 1)
  82293. * @param factor defines the drag value to affect to the specified gradient
  82294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82295. * @returns the current particle system
  82296. */
  82297. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82298. /**
  82299. * Remove a specific drag gradient
  82300. * @param gradient defines the gradient to remove
  82301. * @returns the current particle system
  82302. */
  82303. removeDragGradient(gradient: number): IParticleSystem;
  82304. /**
  82305. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82306. * @param gradient defines the gradient to use (between 0 and 1)
  82307. * @param factor defines the emit rate value to affect to the specified gradient
  82308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82309. * @returns the current particle system
  82310. */
  82311. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82312. /**
  82313. * Remove a specific emit rate gradient
  82314. * @param gradient defines the gradient to remove
  82315. * @returns the current particle system
  82316. */
  82317. removeEmitRateGradient(gradient: number): IParticleSystem;
  82318. /**
  82319. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82320. * @param gradient defines the gradient to use (between 0 and 1)
  82321. * @param factor defines the start size value to affect to the specified gradient
  82322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82323. * @returns the current particle system
  82324. */
  82325. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82326. /**
  82327. * Remove a specific start size gradient
  82328. * @param gradient defines the gradient to remove
  82329. * @returns the current particle system
  82330. */
  82331. removeStartSizeGradient(gradient: number): IParticleSystem;
  82332. private _createRampGradientTexture;
  82333. /**
  82334. * Gets the current list of ramp gradients.
  82335. * You must use addRampGradient and removeRampGradient to udpate this list
  82336. * @returns the list of ramp gradients
  82337. */
  82338. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82339. /**
  82340. * Adds a new ramp gradient used to remap particle colors
  82341. * @param gradient defines the gradient to use (between 0 and 1)
  82342. * @param color defines the color to affect to the specified gradient
  82343. * @returns the current particle system
  82344. */
  82345. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82346. /**
  82347. * Remove a specific ramp gradient
  82348. * @param gradient defines the gradient to remove
  82349. * @returns the current particle system
  82350. */
  82351. removeRampGradient(gradient: number): ParticleSystem;
  82352. /**
  82353. * Adds a new color gradient
  82354. * @param gradient defines the gradient to use (between 0 and 1)
  82355. * @param color1 defines the color to affect to the specified gradient
  82356. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82357. * @returns this particle system
  82358. */
  82359. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82360. /**
  82361. * Remove a specific color gradient
  82362. * @param gradient defines the gradient to remove
  82363. * @returns this particle system
  82364. */
  82365. removeColorGradient(gradient: number): IParticleSystem;
  82366. private _fetchR;
  82367. protected _reset(): void;
  82368. private _resetEffect;
  82369. private _createVertexBuffers;
  82370. private _createIndexBuffer;
  82371. /**
  82372. * Gets the maximum number of particles active at the same time.
  82373. * @returns The max number of active particles.
  82374. */
  82375. getCapacity(): number;
  82376. /**
  82377. * Gets whether there are still active particles in the system.
  82378. * @returns True if it is alive, otherwise false.
  82379. */
  82380. isAlive(): boolean;
  82381. /**
  82382. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82383. * @returns True if it has been started, otherwise false.
  82384. */
  82385. isStarted(): boolean;
  82386. private _prepareSubEmitterInternalArray;
  82387. /**
  82388. * Starts the particle system and begins to emit
  82389. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82390. */
  82391. start(delay?: number): void;
  82392. /**
  82393. * Stops the particle system.
  82394. * @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.
  82395. */
  82396. stop(stopSubEmitters?: boolean): void;
  82397. /**
  82398. * Remove all active particles
  82399. */
  82400. reset(): void;
  82401. /**
  82402. * @hidden (for internal use only)
  82403. */
  82404. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82405. /**
  82406. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82407. * Its lifetime will start back at 0.
  82408. */
  82409. recycleParticle: (particle: Particle) => void;
  82410. private _stopSubEmitters;
  82411. private _createParticle;
  82412. private _removeFromRoot;
  82413. private _emitFromParticle;
  82414. private _update;
  82415. /** @hidden */
  82416. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82417. /** @hidden */
  82418. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82419. /** @hidden */
  82420. private _getEffect;
  82421. /**
  82422. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82423. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82424. */
  82425. animate(preWarmOnly?: boolean): void;
  82426. private _appendParticleVertices;
  82427. /**
  82428. * Rebuilds the particle system.
  82429. */
  82430. rebuild(): void;
  82431. /**
  82432. * Is this system ready to be used/rendered
  82433. * @return true if the system is ready
  82434. */
  82435. isReady(): boolean;
  82436. private _render;
  82437. /**
  82438. * Renders the particle system in its current state.
  82439. * @returns the current number of particles
  82440. */
  82441. render(): number;
  82442. /**
  82443. * Disposes the particle system and free the associated resources
  82444. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82445. */
  82446. dispose(disposeTexture?: boolean): void;
  82447. /**
  82448. * Clones the particle system.
  82449. * @param name The name of the cloned object
  82450. * @param newEmitter The new emitter to use
  82451. * @returns the cloned particle system
  82452. */
  82453. clone(name: string, newEmitter: any): ParticleSystem;
  82454. /**
  82455. * Serializes the particle system to a JSON object.
  82456. * @returns the JSON object
  82457. */
  82458. serialize(): any;
  82459. /** @hidden */
  82460. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82461. /** @hidden */
  82462. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82463. /**
  82464. * Parses a JSON object to create a particle system.
  82465. * @param parsedParticleSystem The JSON object to parse
  82466. * @param scene The scene to create the particle system in
  82467. * @param rootUrl The root url to use to load external dependencies like texture
  82468. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82469. * @returns the Parsed particle system
  82470. */
  82471. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82472. }
  82473. }
  82474. declare module BABYLON {
  82475. /**
  82476. * A particle represents one of the element emitted by a particle system.
  82477. * This is mainly define by its coordinates, direction, velocity and age.
  82478. */
  82479. export class Particle {
  82480. /**
  82481. * The particle system the particle belongs to.
  82482. */
  82483. particleSystem: ParticleSystem;
  82484. private static _Count;
  82485. /**
  82486. * Unique ID of the particle
  82487. */
  82488. id: number;
  82489. /**
  82490. * The world position of the particle in the scene.
  82491. */
  82492. position: Vector3;
  82493. /**
  82494. * The world direction of the particle in the scene.
  82495. */
  82496. direction: Vector3;
  82497. /**
  82498. * The color of the particle.
  82499. */
  82500. color: Color4;
  82501. /**
  82502. * The color change of the particle per step.
  82503. */
  82504. colorStep: Color4;
  82505. /**
  82506. * Defines how long will the life of the particle be.
  82507. */
  82508. lifeTime: number;
  82509. /**
  82510. * The current age of the particle.
  82511. */
  82512. age: number;
  82513. /**
  82514. * The current size of the particle.
  82515. */
  82516. size: number;
  82517. /**
  82518. * The current scale of the particle.
  82519. */
  82520. scale: Vector2;
  82521. /**
  82522. * The current angle of the particle.
  82523. */
  82524. angle: number;
  82525. /**
  82526. * Defines how fast is the angle changing.
  82527. */
  82528. angularSpeed: number;
  82529. /**
  82530. * Defines the cell index used by the particle to be rendered from a sprite.
  82531. */
  82532. cellIndex: number;
  82533. /**
  82534. * The information required to support color remapping
  82535. */
  82536. remapData: Vector4;
  82537. /** @hidden */
  82538. _randomCellOffset?: number;
  82539. /** @hidden */
  82540. _initialDirection: Nullable<Vector3>;
  82541. /** @hidden */
  82542. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82543. /** @hidden */
  82544. _initialStartSpriteCellID: number;
  82545. /** @hidden */
  82546. _initialEndSpriteCellID: number;
  82547. /** @hidden */
  82548. _currentColorGradient: Nullable<ColorGradient>;
  82549. /** @hidden */
  82550. _currentColor1: Color4;
  82551. /** @hidden */
  82552. _currentColor2: Color4;
  82553. /** @hidden */
  82554. _currentSizeGradient: Nullable<FactorGradient>;
  82555. /** @hidden */
  82556. _currentSize1: number;
  82557. /** @hidden */
  82558. _currentSize2: number;
  82559. /** @hidden */
  82560. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82561. /** @hidden */
  82562. _currentAngularSpeed1: number;
  82563. /** @hidden */
  82564. _currentAngularSpeed2: number;
  82565. /** @hidden */
  82566. _currentVelocityGradient: Nullable<FactorGradient>;
  82567. /** @hidden */
  82568. _currentVelocity1: number;
  82569. /** @hidden */
  82570. _currentVelocity2: number;
  82571. /** @hidden */
  82572. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82573. /** @hidden */
  82574. _currentLimitVelocity1: number;
  82575. /** @hidden */
  82576. _currentLimitVelocity2: number;
  82577. /** @hidden */
  82578. _currentDragGradient: Nullable<FactorGradient>;
  82579. /** @hidden */
  82580. _currentDrag1: number;
  82581. /** @hidden */
  82582. _currentDrag2: number;
  82583. /** @hidden */
  82584. _randomNoiseCoordinates1: Vector3;
  82585. /** @hidden */
  82586. _randomNoiseCoordinates2: Vector3;
  82587. /**
  82588. * Creates a new instance Particle
  82589. * @param particleSystem the particle system the particle belongs to
  82590. */
  82591. constructor(
  82592. /**
  82593. * The particle system the particle belongs to.
  82594. */
  82595. particleSystem: ParticleSystem);
  82596. private updateCellInfoFromSystem;
  82597. /**
  82598. * Defines how the sprite cell index is updated for the particle
  82599. */
  82600. updateCellIndex(): void;
  82601. /** @hidden */
  82602. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82603. /** @hidden */
  82604. _inheritParticleInfoToSubEmitters(): void;
  82605. /** @hidden */
  82606. _reset(): void;
  82607. /**
  82608. * Copy the properties of particle to another one.
  82609. * @param other the particle to copy the information to.
  82610. */
  82611. copyTo(other: Particle): void;
  82612. }
  82613. }
  82614. declare module BABYLON {
  82615. /**
  82616. * Particle emitter represents a volume emitting particles.
  82617. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82618. */
  82619. export interface IParticleEmitterType {
  82620. /**
  82621. * Called by the particle System when the direction is computed for the created particle.
  82622. * @param worldMatrix is the world matrix of the particle system
  82623. * @param directionToUpdate is the direction vector to update with the result
  82624. * @param particle is the particle we are computed the direction for
  82625. */
  82626. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82627. /**
  82628. * Called by the particle System when the position is computed for the created particle.
  82629. * @param worldMatrix is the world matrix of the particle system
  82630. * @param positionToUpdate is the position vector to update with the result
  82631. * @param particle is the particle we are computed the position for
  82632. */
  82633. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82634. /**
  82635. * Clones the current emitter and returns a copy of it
  82636. * @returns the new emitter
  82637. */
  82638. clone(): IParticleEmitterType;
  82639. /**
  82640. * Called by the GPUParticleSystem to setup the update shader
  82641. * @param effect defines the update shader
  82642. */
  82643. applyToShader(effect: Effect): void;
  82644. /**
  82645. * Returns a string to use to update the GPU particles update shader
  82646. * @returns the effect defines string
  82647. */
  82648. getEffectDefines(): string;
  82649. /**
  82650. * Returns a string representing the class name
  82651. * @returns a string containing the class name
  82652. */
  82653. getClassName(): string;
  82654. /**
  82655. * Serializes the particle system to a JSON object.
  82656. * @returns the JSON object
  82657. */
  82658. serialize(): any;
  82659. /**
  82660. * Parse properties from a JSON object
  82661. * @param serializationObject defines the JSON object
  82662. */
  82663. parse(serializationObject: any): void;
  82664. }
  82665. }
  82666. declare module BABYLON {
  82667. /**
  82668. * Particle emitter emitting particles from the inside of a box.
  82669. * It emits the particles randomly between 2 given directions.
  82670. */
  82671. export class BoxParticleEmitter implements IParticleEmitterType {
  82672. /**
  82673. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82674. */
  82675. direction1: Vector3;
  82676. /**
  82677. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82678. */
  82679. direction2: Vector3;
  82680. /**
  82681. * 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.
  82682. */
  82683. minEmitBox: Vector3;
  82684. /**
  82685. * 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.
  82686. */
  82687. maxEmitBox: Vector3;
  82688. /**
  82689. * Creates a new instance BoxParticleEmitter
  82690. */
  82691. constructor();
  82692. /**
  82693. * Called by the particle System when the direction is computed for the created particle.
  82694. * @param worldMatrix is the world matrix of the particle system
  82695. * @param directionToUpdate is the direction vector to update with the result
  82696. * @param particle is the particle we are computed the direction for
  82697. */
  82698. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82699. /**
  82700. * Called by the particle System when the position is computed for the created particle.
  82701. * @param worldMatrix is the world matrix of the particle system
  82702. * @param positionToUpdate is the position vector to update with the result
  82703. * @param particle is the particle we are computed the position for
  82704. */
  82705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82706. /**
  82707. * Clones the current emitter and returns a copy of it
  82708. * @returns the new emitter
  82709. */
  82710. clone(): BoxParticleEmitter;
  82711. /**
  82712. * Called by the GPUParticleSystem to setup the update shader
  82713. * @param effect defines the update shader
  82714. */
  82715. applyToShader(effect: Effect): void;
  82716. /**
  82717. * Returns a string to use to update the GPU particles update shader
  82718. * @returns a string containng the defines string
  82719. */
  82720. getEffectDefines(): string;
  82721. /**
  82722. * Returns the string "BoxParticleEmitter"
  82723. * @returns a string containing the class name
  82724. */
  82725. getClassName(): string;
  82726. /**
  82727. * Serializes the particle system to a JSON object.
  82728. * @returns the JSON object
  82729. */
  82730. serialize(): any;
  82731. /**
  82732. * Parse properties from a JSON object
  82733. * @param serializationObject defines the JSON object
  82734. */
  82735. parse(serializationObject: any): void;
  82736. }
  82737. }
  82738. declare module BABYLON {
  82739. /**
  82740. * Particle emitter emitting particles from the inside of a cone.
  82741. * It emits the particles alongside the cone volume from the base to the particle.
  82742. * The emission direction might be randomized.
  82743. */
  82744. export class ConeParticleEmitter implements IParticleEmitterType {
  82745. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82746. directionRandomizer: number;
  82747. private _radius;
  82748. private _angle;
  82749. private _height;
  82750. /**
  82751. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82752. */
  82753. radiusRange: number;
  82754. /**
  82755. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82756. */
  82757. heightRange: number;
  82758. /**
  82759. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82760. */
  82761. emitFromSpawnPointOnly: boolean;
  82762. /**
  82763. * Gets or sets the radius of the emission cone
  82764. */
  82765. radius: number;
  82766. /**
  82767. * Gets or sets the angle of the emission cone
  82768. */
  82769. angle: number;
  82770. private _buildHeight;
  82771. /**
  82772. * Creates a new instance ConeParticleEmitter
  82773. * @param radius the radius of the emission cone (1 by default)
  82774. * @param angle the cone base angle (PI by default)
  82775. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82776. */
  82777. constructor(radius?: number, angle?: number,
  82778. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82779. directionRandomizer?: number);
  82780. /**
  82781. * Called by the particle System when the direction is computed for the created particle.
  82782. * @param worldMatrix is the world matrix of the particle system
  82783. * @param directionToUpdate is the direction vector to update with the result
  82784. * @param particle is the particle we are computed the direction for
  82785. */
  82786. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82787. /**
  82788. * Called by the particle System when the position is computed for the created particle.
  82789. * @param worldMatrix is the world matrix of the particle system
  82790. * @param positionToUpdate is the position vector to update with the result
  82791. * @param particle is the particle we are computed the position for
  82792. */
  82793. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82794. /**
  82795. * Clones the current emitter and returns a copy of it
  82796. * @returns the new emitter
  82797. */
  82798. clone(): ConeParticleEmitter;
  82799. /**
  82800. * Called by the GPUParticleSystem to setup the update shader
  82801. * @param effect defines the update shader
  82802. */
  82803. applyToShader(effect: Effect): void;
  82804. /**
  82805. * Returns a string to use to update the GPU particles update shader
  82806. * @returns a string containng the defines string
  82807. */
  82808. getEffectDefines(): string;
  82809. /**
  82810. * Returns the string "ConeParticleEmitter"
  82811. * @returns a string containing the class name
  82812. */
  82813. getClassName(): string;
  82814. /**
  82815. * Serializes the particle system to a JSON object.
  82816. * @returns the JSON object
  82817. */
  82818. serialize(): any;
  82819. /**
  82820. * Parse properties from a JSON object
  82821. * @param serializationObject defines the JSON object
  82822. */
  82823. parse(serializationObject: any): void;
  82824. }
  82825. }
  82826. declare module BABYLON {
  82827. /**
  82828. * Particle emitter emitting particles from the inside of a cylinder.
  82829. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82830. */
  82831. export class CylinderParticleEmitter implements IParticleEmitterType {
  82832. /**
  82833. * The radius of the emission cylinder.
  82834. */
  82835. radius: number;
  82836. /**
  82837. * The height of the emission cylinder.
  82838. */
  82839. height: number;
  82840. /**
  82841. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82842. */
  82843. radiusRange: number;
  82844. /**
  82845. * How much to randomize the particle direction [0-1].
  82846. */
  82847. directionRandomizer: number;
  82848. /**
  82849. * Creates a new instance CylinderParticleEmitter
  82850. * @param radius the radius of the emission cylinder (1 by default)
  82851. * @param height the height of the emission cylinder (1 by default)
  82852. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82853. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82854. */
  82855. constructor(
  82856. /**
  82857. * The radius of the emission cylinder.
  82858. */
  82859. radius?: number,
  82860. /**
  82861. * The height of the emission cylinder.
  82862. */
  82863. height?: number,
  82864. /**
  82865. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82866. */
  82867. radiusRange?: number,
  82868. /**
  82869. * How much to randomize the particle direction [0-1].
  82870. */
  82871. directionRandomizer?: number);
  82872. /**
  82873. * Called by the particle System when the direction is computed for the created particle.
  82874. * @param worldMatrix is the world matrix of the particle system
  82875. * @param directionToUpdate is the direction vector to update with the result
  82876. * @param particle is the particle we are computed the direction for
  82877. */
  82878. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82879. /**
  82880. * Called by the particle System when the position is computed for the created particle.
  82881. * @param worldMatrix is the world matrix of the particle system
  82882. * @param positionToUpdate is the position vector to update with the result
  82883. * @param particle is the particle we are computed the position for
  82884. */
  82885. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82886. /**
  82887. * Clones the current emitter and returns a copy of it
  82888. * @returns the new emitter
  82889. */
  82890. clone(): CylinderParticleEmitter;
  82891. /**
  82892. * Called by the GPUParticleSystem to setup the update shader
  82893. * @param effect defines the update shader
  82894. */
  82895. applyToShader(effect: Effect): void;
  82896. /**
  82897. * Returns a string to use to update the GPU particles update shader
  82898. * @returns a string containng the defines string
  82899. */
  82900. getEffectDefines(): string;
  82901. /**
  82902. * Returns the string "CylinderParticleEmitter"
  82903. * @returns a string containing the class name
  82904. */
  82905. getClassName(): string;
  82906. /**
  82907. * Serializes the particle system to a JSON object.
  82908. * @returns the JSON object
  82909. */
  82910. serialize(): any;
  82911. /**
  82912. * Parse properties from a JSON object
  82913. * @param serializationObject defines the JSON object
  82914. */
  82915. parse(serializationObject: any): void;
  82916. }
  82917. /**
  82918. * Particle emitter emitting particles from the inside of a cylinder.
  82919. * It emits the particles randomly between two vectors.
  82920. */
  82921. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82922. /**
  82923. * The min limit of the emission direction.
  82924. */
  82925. direction1: Vector3;
  82926. /**
  82927. * The max limit of the emission direction.
  82928. */
  82929. direction2: Vector3;
  82930. /**
  82931. * Creates a new instance CylinderDirectedParticleEmitter
  82932. * @param radius the radius of the emission cylinder (1 by default)
  82933. * @param height the height of the emission cylinder (1 by default)
  82934. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82935. * @param direction1 the min limit of the emission direction (up vector by default)
  82936. * @param direction2 the max limit of the emission direction (up vector by default)
  82937. */
  82938. constructor(radius?: number, height?: number, radiusRange?: number,
  82939. /**
  82940. * The min limit of the emission direction.
  82941. */
  82942. direction1?: Vector3,
  82943. /**
  82944. * The max limit of the emission direction.
  82945. */
  82946. direction2?: Vector3);
  82947. /**
  82948. * Called by the particle System when the direction is computed for the created particle.
  82949. * @param worldMatrix is the world matrix of the particle system
  82950. * @param directionToUpdate is the direction vector to update with the result
  82951. * @param particle is the particle we are computed the direction for
  82952. */
  82953. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82954. /**
  82955. * Clones the current emitter and returns a copy of it
  82956. * @returns the new emitter
  82957. */
  82958. clone(): CylinderDirectedParticleEmitter;
  82959. /**
  82960. * Called by the GPUParticleSystem to setup the update shader
  82961. * @param effect defines the update shader
  82962. */
  82963. applyToShader(effect: Effect): void;
  82964. /**
  82965. * Returns a string to use to update the GPU particles update shader
  82966. * @returns a string containng the defines string
  82967. */
  82968. getEffectDefines(): string;
  82969. /**
  82970. * Returns the string "CylinderDirectedParticleEmitter"
  82971. * @returns a string containing the class name
  82972. */
  82973. getClassName(): string;
  82974. /**
  82975. * Serializes the particle system to a JSON object.
  82976. * @returns the JSON object
  82977. */
  82978. serialize(): any;
  82979. /**
  82980. * Parse properties from a JSON object
  82981. * @param serializationObject defines the JSON object
  82982. */
  82983. parse(serializationObject: any): void;
  82984. }
  82985. }
  82986. declare module BABYLON {
  82987. /**
  82988. * Particle emitter emitting particles from the inside of a hemisphere.
  82989. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  82990. */
  82991. export class HemisphericParticleEmitter implements IParticleEmitterType {
  82992. /**
  82993. * The radius of the emission hemisphere.
  82994. */
  82995. radius: number;
  82996. /**
  82997. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82998. */
  82999. radiusRange: number;
  83000. /**
  83001. * How much to randomize the particle direction [0-1].
  83002. */
  83003. directionRandomizer: number;
  83004. /**
  83005. * Creates a new instance HemisphericParticleEmitter
  83006. * @param radius the radius of the emission hemisphere (1 by default)
  83007. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83008. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83009. */
  83010. constructor(
  83011. /**
  83012. * The radius of the emission hemisphere.
  83013. */
  83014. radius?: number,
  83015. /**
  83016. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83017. */
  83018. radiusRange?: number,
  83019. /**
  83020. * How much to randomize the particle direction [0-1].
  83021. */
  83022. directionRandomizer?: number);
  83023. /**
  83024. * Called by the particle System when the direction is computed for the created particle.
  83025. * @param worldMatrix is the world matrix of the particle system
  83026. * @param directionToUpdate is the direction vector to update with the result
  83027. * @param particle is the particle we are computed the direction for
  83028. */
  83029. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83030. /**
  83031. * Called by the particle System when the position is computed for the created particle.
  83032. * @param worldMatrix is the world matrix of the particle system
  83033. * @param positionToUpdate is the position vector to update with the result
  83034. * @param particle is the particle we are computed the position for
  83035. */
  83036. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83037. /**
  83038. * Clones the current emitter and returns a copy of it
  83039. * @returns the new emitter
  83040. */
  83041. clone(): HemisphericParticleEmitter;
  83042. /**
  83043. * Called by the GPUParticleSystem to setup the update shader
  83044. * @param effect defines the update shader
  83045. */
  83046. applyToShader(effect: Effect): void;
  83047. /**
  83048. * Returns a string to use to update the GPU particles update shader
  83049. * @returns a string containng the defines string
  83050. */
  83051. getEffectDefines(): string;
  83052. /**
  83053. * Returns the string "HemisphericParticleEmitter"
  83054. * @returns a string containing the class name
  83055. */
  83056. getClassName(): string;
  83057. /**
  83058. * Serializes the particle system to a JSON object.
  83059. * @returns the JSON object
  83060. */
  83061. serialize(): any;
  83062. /**
  83063. * Parse properties from a JSON object
  83064. * @param serializationObject defines the JSON object
  83065. */
  83066. parse(serializationObject: any): void;
  83067. }
  83068. }
  83069. declare module BABYLON {
  83070. /**
  83071. * Particle emitter emitting particles from a point.
  83072. * It emits the particles randomly between 2 given directions.
  83073. */
  83074. export class PointParticleEmitter implements IParticleEmitterType {
  83075. /**
  83076. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83077. */
  83078. direction1: Vector3;
  83079. /**
  83080. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83081. */
  83082. direction2: Vector3;
  83083. /**
  83084. * Creates a new instance PointParticleEmitter
  83085. */
  83086. constructor();
  83087. /**
  83088. * Called by the particle System when the direction is computed for the created particle.
  83089. * @param worldMatrix is the world matrix of the particle system
  83090. * @param directionToUpdate is the direction vector to update with the result
  83091. * @param particle is the particle we are computed the direction for
  83092. */
  83093. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83094. /**
  83095. * Called by the particle System when the position is computed for the created particle.
  83096. * @param worldMatrix is the world matrix of the particle system
  83097. * @param positionToUpdate is the position vector to update with the result
  83098. * @param particle is the particle we are computed the position for
  83099. */
  83100. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83101. /**
  83102. * Clones the current emitter and returns a copy of it
  83103. * @returns the new emitter
  83104. */
  83105. clone(): PointParticleEmitter;
  83106. /**
  83107. * Called by the GPUParticleSystem to setup the update shader
  83108. * @param effect defines the update shader
  83109. */
  83110. applyToShader(effect: Effect): void;
  83111. /**
  83112. * Returns a string to use to update the GPU particles update shader
  83113. * @returns a string containng the defines string
  83114. */
  83115. getEffectDefines(): string;
  83116. /**
  83117. * Returns the string "PointParticleEmitter"
  83118. * @returns a string containing the class name
  83119. */
  83120. getClassName(): string;
  83121. /**
  83122. * Serializes the particle system to a JSON object.
  83123. * @returns the JSON object
  83124. */
  83125. serialize(): any;
  83126. /**
  83127. * Parse properties from a JSON object
  83128. * @param serializationObject defines the JSON object
  83129. */
  83130. parse(serializationObject: any): void;
  83131. }
  83132. }
  83133. declare module BABYLON {
  83134. /**
  83135. * Particle emitter emitting particles from the inside of a sphere.
  83136. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83137. */
  83138. export class SphereParticleEmitter implements IParticleEmitterType {
  83139. /**
  83140. * The radius of the emission sphere.
  83141. */
  83142. radius: number;
  83143. /**
  83144. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83145. */
  83146. radiusRange: number;
  83147. /**
  83148. * How much to randomize the particle direction [0-1].
  83149. */
  83150. directionRandomizer: number;
  83151. /**
  83152. * Creates a new instance SphereParticleEmitter
  83153. * @param radius the radius of the emission sphere (1 by default)
  83154. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83155. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83156. */
  83157. constructor(
  83158. /**
  83159. * The radius of the emission sphere.
  83160. */
  83161. radius?: number,
  83162. /**
  83163. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83164. */
  83165. radiusRange?: number,
  83166. /**
  83167. * How much to randomize the particle direction [0-1].
  83168. */
  83169. directionRandomizer?: number);
  83170. /**
  83171. * Called by the particle System when the direction is computed for the created particle.
  83172. * @param worldMatrix is the world matrix of the particle system
  83173. * @param directionToUpdate is the direction vector to update with the result
  83174. * @param particle is the particle we are computed the direction for
  83175. */
  83176. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83177. /**
  83178. * Called by the particle System when the position is computed for the created particle.
  83179. * @param worldMatrix is the world matrix of the particle system
  83180. * @param positionToUpdate is the position vector to update with the result
  83181. * @param particle is the particle we are computed the position for
  83182. */
  83183. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83184. /**
  83185. * Clones the current emitter and returns a copy of it
  83186. * @returns the new emitter
  83187. */
  83188. clone(): SphereParticleEmitter;
  83189. /**
  83190. * Called by the GPUParticleSystem to setup the update shader
  83191. * @param effect defines the update shader
  83192. */
  83193. applyToShader(effect: Effect): void;
  83194. /**
  83195. * Returns a string to use to update the GPU particles update shader
  83196. * @returns a string containng the defines string
  83197. */
  83198. getEffectDefines(): string;
  83199. /**
  83200. * Returns the string "SphereParticleEmitter"
  83201. * @returns a string containing the class name
  83202. */
  83203. getClassName(): string;
  83204. /**
  83205. * Serializes the particle system to a JSON object.
  83206. * @returns the JSON object
  83207. */
  83208. serialize(): any;
  83209. /**
  83210. * Parse properties from a JSON object
  83211. * @param serializationObject defines the JSON object
  83212. */
  83213. parse(serializationObject: any): void;
  83214. }
  83215. /**
  83216. * Particle emitter emitting particles from the inside of a sphere.
  83217. * It emits the particles randomly between two vectors.
  83218. */
  83219. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83220. /**
  83221. * The min limit of the emission direction.
  83222. */
  83223. direction1: Vector3;
  83224. /**
  83225. * The max limit of the emission direction.
  83226. */
  83227. direction2: Vector3;
  83228. /**
  83229. * Creates a new instance SphereDirectedParticleEmitter
  83230. * @param radius the radius of the emission sphere (1 by default)
  83231. * @param direction1 the min limit of the emission direction (up vector by default)
  83232. * @param direction2 the max limit of the emission direction (up vector by default)
  83233. */
  83234. constructor(radius?: number,
  83235. /**
  83236. * The min limit of the emission direction.
  83237. */
  83238. direction1?: Vector3,
  83239. /**
  83240. * The max limit of the emission direction.
  83241. */
  83242. direction2?: Vector3);
  83243. /**
  83244. * Called by the particle System when the direction is computed for the created particle.
  83245. * @param worldMatrix is the world matrix of the particle system
  83246. * @param directionToUpdate is the direction vector to update with the result
  83247. * @param particle is the particle we are computed the direction for
  83248. */
  83249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83250. /**
  83251. * Clones the current emitter and returns a copy of it
  83252. * @returns the new emitter
  83253. */
  83254. clone(): SphereDirectedParticleEmitter;
  83255. /**
  83256. * Called by the GPUParticleSystem to setup the update shader
  83257. * @param effect defines the update shader
  83258. */
  83259. applyToShader(effect: Effect): void;
  83260. /**
  83261. * Returns a string to use to update the GPU particles update shader
  83262. * @returns a string containng the defines string
  83263. */
  83264. getEffectDefines(): string;
  83265. /**
  83266. * Returns the string "SphereDirectedParticleEmitter"
  83267. * @returns a string containing the class name
  83268. */
  83269. getClassName(): string;
  83270. /**
  83271. * Serializes the particle system to a JSON object.
  83272. * @returns the JSON object
  83273. */
  83274. serialize(): any;
  83275. /**
  83276. * Parse properties from a JSON object
  83277. * @param serializationObject defines the JSON object
  83278. */
  83279. parse(serializationObject: any): void;
  83280. }
  83281. }
  83282. declare module BABYLON {
  83283. /**
  83284. * Interface representing a particle system in Babylon.js.
  83285. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83286. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83287. */
  83288. export interface IParticleSystem {
  83289. /**
  83290. * List of animations used by the particle system.
  83291. */
  83292. animations: Animation[];
  83293. /**
  83294. * The id of the Particle system.
  83295. */
  83296. id: string;
  83297. /**
  83298. * The name of the Particle system.
  83299. */
  83300. name: string;
  83301. /**
  83302. * The emitter represents the Mesh or position we are attaching the particle system to.
  83303. */
  83304. emitter: Nullable<AbstractMesh | Vector3>;
  83305. /**
  83306. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83307. */
  83308. isBillboardBased: boolean;
  83309. /**
  83310. * The rendering group used by the Particle system to chose when to render.
  83311. */
  83312. renderingGroupId: number;
  83313. /**
  83314. * The layer mask we are rendering the particles through.
  83315. */
  83316. layerMask: number;
  83317. /**
  83318. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83319. */
  83320. updateSpeed: number;
  83321. /**
  83322. * The amount of time the particle system is running (depends of the overall update speed).
  83323. */
  83324. targetStopDuration: number;
  83325. /**
  83326. * The texture used to render each particle. (this can be a spritesheet)
  83327. */
  83328. particleTexture: Nullable<Texture>;
  83329. /**
  83330. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83331. */
  83332. blendMode: number;
  83333. /**
  83334. * Minimum life time of emitting particles.
  83335. */
  83336. minLifeTime: number;
  83337. /**
  83338. * Maximum life time of emitting particles.
  83339. */
  83340. maxLifeTime: number;
  83341. /**
  83342. * Minimum Size of emitting particles.
  83343. */
  83344. minSize: number;
  83345. /**
  83346. * Maximum Size of emitting particles.
  83347. */
  83348. maxSize: number;
  83349. /**
  83350. * Minimum scale of emitting particles on X axis.
  83351. */
  83352. minScaleX: number;
  83353. /**
  83354. * Maximum scale of emitting particles on X axis.
  83355. */
  83356. maxScaleX: number;
  83357. /**
  83358. * Minimum scale of emitting particles on Y axis.
  83359. */
  83360. minScaleY: number;
  83361. /**
  83362. * Maximum scale of emitting particles on Y axis.
  83363. */
  83364. maxScaleY: number;
  83365. /**
  83366. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83367. */
  83368. color1: Color4;
  83369. /**
  83370. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83371. */
  83372. color2: Color4;
  83373. /**
  83374. * Color the particle will have at the end of its lifetime.
  83375. */
  83376. colorDead: Color4;
  83377. /**
  83378. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83379. */
  83380. emitRate: number;
  83381. /**
  83382. * You can use gravity if you want to give an orientation to your particles.
  83383. */
  83384. gravity: Vector3;
  83385. /**
  83386. * Minimum power of emitting particles.
  83387. */
  83388. minEmitPower: number;
  83389. /**
  83390. * Maximum power of emitting particles.
  83391. */
  83392. maxEmitPower: number;
  83393. /**
  83394. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83395. */
  83396. minAngularSpeed: number;
  83397. /**
  83398. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83399. */
  83400. maxAngularSpeed: number;
  83401. /**
  83402. * Gets or sets the minimal initial rotation in radians.
  83403. */
  83404. minInitialRotation: number;
  83405. /**
  83406. * Gets or sets the maximal initial rotation in radians.
  83407. */
  83408. maxInitialRotation: number;
  83409. /**
  83410. * The particle emitter type defines the emitter used by the particle system.
  83411. * It can be for example box, sphere, or cone...
  83412. */
  83413. particleEmitterType: Nullable<IParticleEmitterType>;
  83414. /**
  83415. * Defines the delay in milliseconds before starting the system (0 by default)
  83416. */
  83417. startDelay: number;
  83418. /**
  83419. * 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
  83420. */
  83421. preWarmCycles: number;
  83422. /**
  83423. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83424. */
  83425. preWarmStepOffset: number;
  83426. /**
  83427. * 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)
  83428. */
  83429. spriteCellChangeSpeed: number;
  83430. /**
  83431. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83432. */
  83433. startSpriteCellID: number;
  83434. /**
  83435. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83436. */
  83437. endSpriteCellID: number;
  83438. /**
  83439. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83440. */
  83441. spriteCellWidth: number;
  83442. /**
  83443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83444. */
  83445. spriteCellHeight: number;
  83446. /**
  83447. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83448. */
  83449. spriteRandomStartCell: boolean;
  83450. /**
  83451. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83452. */
  83453. isAnimationSheetEnabled: boolean;
  83454. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83455. translationPivot: Vector2;
  83456. /**
  83457. * Gets or sets a texture used to add random noise to particle positions
  83458. */
  83459. noiseTexture: Nullable<BaseTexture>;
  83460. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83461. noiseStrength: Vector3;
  83462. /**
  83463. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83464. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83465. */
  83466. billboardMode: number;
  83467. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83468. limitVelocityDamping: number;
  83469. /**
  83470. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83471. */
  83472. beginAnimationOnStart: boolean;
  83473. /**
  83474. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83475. */
  83476. beginAnimationFrom: number;
  83477. /**
  83478. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83479. */
  83480. beginAnimationTo: number;
  83481. /**
  83482. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83483. */
  83484. beginAnimationLoop: boolean;
  83485. /**
  83486. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83487. */
  83488. disposeOnStop: boolean;
  83489. /**
  83490. * Gets the maximum number of particles active at the same time.
  83491. * @returns The max number of active particles.
  83492. */
  83493. getCapacity(): number;
  83494. /**
  83495. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83496. * @returns True if it has been started, otherwise false.
  83497. */
  83498. isStarted(): boolean;
  83499. /**
  83500. * Animates the particle system for this frame.
  83501. */
  83502. animate(): void;
  83503. /**
  83504. * Renders the particle system in its current state.
  83505. * @returns the current number of particles
  83506. */
  83507. render(): number;
  83508. /**
  83509. * Dispose the particle system and frees its associated resources.
  83510. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83511. */
  83512. dispose(disposeTexture?: boolean): void;
  83513. /**
  83514. * Clones the particle system.
  83515. * @param name The name of the cloned object
  83516. * @param newEmitter The new emitter to use
  83517. * @returns the cloned particle system
  83518. */
  83519. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83520. /**
  83521. * Serializes the particle system to a JSON object.
  83522. * @returns the JSON object
  83523. */
  83524. serialize(): any;
  83525. /**
  83526. * Rebuild the particle system
  83527. */
  83528. rebuild(): void;
  83529. /**
  83530. * Starts the particle system and begins to emit
  83531. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83532. */
  83533. start(delay?: number): void;
  83534. /**
  83535. * Stops the particle system.
  83536. */
  83537. stop(): void;
  83538. /**
  83539. * Remove all active particles
  83540. */
  83541. reset(): void;
  83542. /**
  83543. * Is this system ready to be used/rendered
  83544. * @return true if the system is ready
  83545. */
  83546. isReady(): boolean;
  83547. /**
  83548. * Adds a new color gradient
  83549. * @param gradient defines the gradient to use (between 0 and 1)
  83550. * @param color1 defines the color to affect to the specified gradient
  83551. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83552. * @returns the current particle system
  83553. */
  83554. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83555. /**
  83556. * Remove a specific color gradient
  83557. * @param gradient defines the gradient to remove
  83558. * @returns the current particle system
  83559. */
  83560. removeColorGradient(gradient: number): IParticleSystem;
  83561. /**
  83562. * Adds a new size gradient
  83563. * @param gradient defines the gradient to use (between 0 and 1)
  83564. * @param factor defines the size factor to affect to the specified gradient
  83565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83566. * @returns the current particle system
  83567. */
  83568. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83569. /**
  83570. * Remove a specific size gradient
  83571. * @param gradient defines the gradient to remove
  83572. * @returns the current particle system
  83573. */
  83574. removeSizeGradient(gradient: number): IParticleSystem;
  83575. /**
  83576. * Gets the current list of color gradients.
  83577. * You must use addColorGradient and removeColorGradient to udpate this list
  83578. * @returns the list of color gradients
  83579. */
  83580. getColorGradients(): Nullable<Array<ColorGradient>>;
  83581. /**
  83582. * Gets the current list of size gradients.
  83583. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83584. * @returns the list of size gradients
  83585. */
  83586. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83587. /**
  83588. * Gets the current list of angular speed gradients.
  83589. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83590. * @returns the list of angular speed gradients
  83591. */
  83592. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83593. /**
  83594. * Adds a new angular speed gradient
  83595. * @param gradient defines the gradient to use (between 0 and 1)
  83596. * @param factor defines the angular speed to affect to the specified gradient
  83597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83598. * @returns the current particle system
  83599. */
  83600. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83601. /**
  83602. * Remove a specific angular speed gradient
  83603. * @param gradient defines the gradient to remove
  83604. * @returns the current particle system
  83605. */
  83606. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83607. /**
  83608. * Gets the current list of velocity gradients.
  83609. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83610. * @returns the list of velocity gradients
  83611. */
  83612. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83613. /**
  83614. * Adds a new velocity gradient
  83615. * @param gradient defines the gradient to use (between 0 and 1)
  83616. * @param factor defines the velocity to affect to the specified gradient
  83617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83618. * @returns the current particle system
  83619. */
  83620. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83621. /**
  83622. * Remove a specific velocity gradient
  83623. * @param gradient defines the gradient to remove
  83624. * @returns the current particle system
  83625. */
  83626. removeVelocityGradient(gradient: number): IParticleSystem;
  83627. /**
  83628. * Gets the current list of limit velocity gradients.
  83629. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83630. * @returns the list of limit velocity gradients
  83631. */
  83632. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83633. /**
  83634. * Adds a new limit velocity gradient
  83635. * @param gradient defines the gradient to use (between 0 and 1)
  83636. * @param factor defines the limit velocity to affect to the specified gradient
  83637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83638. * @returns the current particle system
  83639. */
  83640. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83641. /**
  83642. * Remove a specific limit velocity gradient
  83643. * @param gradient defines the gradient to remove
  83644. * @returns the current particle system
  83645. */
  83646. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83647. /**
  83648. * Adds a new drag gradient
  83649. * @param gradient defines the gradient to use (between 0 and 1)
  83650. * @param factor defines the drag to affect to the specified gradient
  83651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83652. * @returns the current particle system
  83653. */
  83654. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83655. /**
  83656. * Remove a specific drag gradient
  83657. * @param gradient defines the gradient to remove
  83658. * @returns the current particle system
  83659. */
  83660. removeDragGradient(gradient: number): IParticleSystem;
  83661. /**
  83662. * Gets the current list of drag gradients.
  83663. * You must use addDragGradient and removeDragGradient to udpate this list
  83664. * @returns the list of drag gradients
  83665. */
  83666. getDragGradients(): Nullable<Array<FactorGradient>>;
  83667. /**
  83668. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83669. * @param gradient defines the gradient to use (between 0 and 1)
  83670. * @param factor defines the emit rate to affect to the specified gradient
  83671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83672. * @returns the current particle system
  83673. */
  83674. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83675. /**
  83676. * Remove a specific emit rate gradient
  83677. * @param gradient defines the gradient to remove
  83678. * @returns the current particle system
  83679. */
  83680. removeEmitRateGradient(gradient: number): IParticleSystem;
  83681. /**
  83682. * Gets the current list of emit rate gradients.
  83683. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83684. * @returns the list of emit rate gradients
  83685. */
  83686. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83687. /**
  83688. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83689. * @param gradient defines the gradient to use (between 0 and 1)
  83690. * @param factor defines the start size to affect to the specified gradient
  83691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83692. * @returns the current particle system
  83693. */
  83694. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83695. /**
  83696. * Remove a specific start size gradient
  83697. * @param gradient defines the gradient to remove
  83698. * @returns the current particle system
  83699. */
  83700. removeStartSizeGradient(gradient: number): IParticleSystem;
  83701. /**
  83702. * Gets the current list of start size gradients.
  83703. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83704. * @returns the list of start size gradients
  83705. */
  83706. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83707. /**
  83708. * Adds a new life time gradient
  83709. * @param gradient defines the gradient to use (between 0 and 1)
  83710. * @param factor defines the life time factor to affect to the specified gradient
  83711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83712. * @returns the current particle system
  83713. */
  83714. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83715. /**
  83716. * Remove a specific life time gradient
  83717. * @param gradient defines the gradient to remove
  83718. * @returns the current particle system
  83719. */
  83720. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83721. /**
  83722. * Gets the current list of life time gradients.
  83723. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83724. * @returns the list of life time gradients
  83725. */
  83726. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83727. /**
  83728. * Gets the current list of color gradients.
  83729. * You must use addColorGradient and removeColorGradient to udpate this list
  83730. * @returns the list of color gradients
  83731. */
  83732. getColorGradients(): Nullable<Array<ColorGradient>>;
  83733. /**
  83734. * Adds a new ramp gradient used to remap particle colors
  83735. * @param gradient defines the gradient to use (between 0 and 1)
  83736. * @param color defines the color to affect to the specified gradient
  83737. * @returns the current particle system
  83738. */
  83739. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83740. /**
  83741. * Gets the current list of ramp gradients.
  83742. * You must use addRampGradient and removeRampGradient to udpate this list
  83743. * @returns the list of ramp gradients
  83744. */
  83745. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83746. /** Gets or sets a boolean indicating that ramp gradients must be used
  83747. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83748. */
  83749. useRampGradients: boolean;
  83750. /**
  83751. * Adds a new color remap gradient
  83752. * @param gradient defines the gradient to use (between 0 and 1)
  83753. * @param min defines the color remap minimal range
  83754. * @param max defines the color remap maximal range
  83755. * @returns the current particle system
  83756. */
  83757. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83758. /**
  83759. * Gets the current list of color remap gradients.
  83760. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83761. * @returns the list of color remap gradients
  83762. */
  83763. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83764. /**
  83765. * Adds a new alpha remap gradient
  83766. * @param gradient defines the gradient to use (between 0 and 1)
  83767. * @param min defines the alpha remap minimal range
  83768. * @param max defines the alpha remap maximal range
  83769. * @returns the current particle system
  83770. */
  83771. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83772. /**
  83773. * Gets the current list of alpha remap gradients.
  83774. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83775. * @returns the list of alpha remap gradients
  83776. */
  83777. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83778. /**
  83779. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83780. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83781. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83782. * @returns the emitter
  83783. */
  83784. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83785. /**
  83786. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83787. * @param radius The radius of the hemisphere to emit from
  83788. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83789. * @returns the emitter
  83790. */
  83791. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83792. /**
  83793. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83794. * @param radius The radius of the sphere to emit from
  83795. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83796. * @returns the emitter
  83797. */
  83798. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83799. /**
  83800. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83801. * @param radius The radius of the sphere to emit from
  83802. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83803. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83804. * @returns the emitter
  83805. */
  83806. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83807. /**
  83808. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83809. * @param radius The radius of the emission cylinder
  83810. * @param height The height of the emission cylinder
  83811. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83812. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83813. * @returns the emitter
  83814. */
  83815. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83816. /**
  83817. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83818. * @param radius The radius of the cylinder to emit from
  83819. * @param height The height of the emission cylinder
  83820. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83823. * @returns the emitter
  83824. */
  83825. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83826. /**
  83827. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83828. * @param radius The radius of the cone to emit from
  83829. * @param angle The base angle of the cone
  83830. * @returns the emitter
  83831. */
  83832. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83833. /**
  83834. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83835. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83836. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83837. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83838. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83839. * @returns the emitter
  83840. */
  83841. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83842. /**
  83843. * Get hosting scene
  83844. * @returns the scene
  83845. */
  83846. getScene(): Scene;
  83847. }
  83848. }
  83849. declare module BABYLON {
  83850. /** @hidden */
  83851. export var linePixelShader: {
  83852. name: string;
  83853. shader: string;
  83854. };
  83855. }
  83856. declare module BABYLON {
  83857. /** @hidden */
  83858. export var lineVertexShader: {
  83859. name: string;
  83860. shader: string;
  83861. };
  83862. }
  83863. declare module BABYLON {
  83864. interface AbstractMesh {
  83865. /**
  83866. * Gets the edgesRenderer associated with the mesh
  83867. */
  83868. edgesRenderer: Nullable<EdgesRenderer>;
  83869. }
  83870. interface LinesMesh {
  83871. /**
  83872. * Enables the edge rendering mode on the mesh.
  83873. * This mode makes the mesh edges visible
  83874. * @param epsilon defines the maximal distance between two angles to detect a face
  83875. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83876. * @returns the currentAbstractMesh
  83877. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83878. */
  83879. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83880. }
  83881. interface InstancedLinesMesh {
  83882. /**
  83883. * Enables the edge rendering mode on the mesh.
  83884. * This mode makes the mesh edges visible
  83885. * @param epsilon defines the maximal distance between two angles to detect a face
  83886. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83887. * @returns the current InstancedLinesMesh
  83888. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83889. */
  83890. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83891. }
  83892. /**
  83893. * Defines the minimum contract an Edges renderer should follow.
  83894. */
  83895. export interface IEdgesRenderer extends IDisposable {
  83896. /**
  83897. * Gets or sets a boolean indicating if the edgesRenderer is active
  83898. */
  83899. isEnabled: boolean;
  83900. /**
  83901. * Renders the edges of the attached mesh,
  83902. */
  83903. render(): void;
  83904. /**
  83905. * Checks wether or not the edges renderer is ready to render.
  83906. * @return true if ready, otherwise false.
  83907. */
  83908. isReady(): boolean;
  83909. }
  83910. /**
  83911. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83912. */
  83913. export class EdgesRenderer implements IEdgesRenderer {
  83914. /**
  83915. * Define the size of the edges with an orthographic camera
  83916. */
  83917. edgesWidthScalerForOrthographic: number;
  83918. /**
  83919. * Define the size of the edges with a perspective camera
  83920. */
  83921. edgesWidthScalerForPerspective: number;
  83922. protected _source: AbstractMesh;
  83923. protected _linesPositions: number[];
  83924. protected _linesNormals: number[];
  83925. protected _linesIndices: number[];
  83926. protected _epsilon: number;
  83927. protected _indicesCount: number;
  83928. protected _lineShader: ShaderMaterial;
  83929. protected _ib: DataBuffer;
  83930. protected _buffers: {
  83931. [key: string]: Nullable<VertexBuffer>;
  83932. };
  83933. protected _checkVerticesInsteadOfIndices: boolean;
  83934. private _meshRebuildObserver;
  83935. private _meshDisposeObserver;
  83936. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83937. isEnabled: boolean;
  83938. /**
  83939. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83940. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83941. * @param source Mesh used to create edges
  83942. * @param epsilon sum of angles in adjacency to check for edge
  83943. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83944. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83945. */
  83946. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83947. protected _prepareRessources(): void;
  83948. /** @hidden */
  83949. _rebuild(): void;
  83950. /**
  83951. * Releases the required resources for the edges renderer
  83952. */
  83953. dispose(): void;
  83954. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83955. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83956. /**
  83957. * Checks if the pair of p0 and p1 is en edge
  83958. * @param faceIndex
  83959. * @param edge
  83960. * @param faceNormals
  83961. * @param p0
  83962. * @param p1
  83963. * @private
  83964. */
  83965. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83966. /**
  83967. * push line into the position, normal and index buffer
  83968. * @protected
  83969. */
  83970. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83971. /**
  83972. * Generates lines edges from adjacencjes
  83973. * @private
  83974. */
  83975. _generateEdgesLines(): void;
  83976. /**
  83977. * Checks wether or not the edges renderer is ready to render.
  83978. * @return true if ready, otherwise false.
  83979. */
  83980. isReady(): boolean;
  83981. /**
  83982. * Renders the edges of the attached mesh,
  83983. */
  83984. render(): void;
  83985. }
  83986. /**
  83987. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83988. */
  83989. export class LineEdgesRenderer extends EdgesRenderer {
  83990. /**
  83991. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83992. * @param source LineMesh used to generate edges
  83993. * @param epsilon not important (specified angle for edge detection)
  83994. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83995. */
  83996. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83997. /**
  83998. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83999. */
  84000. _generateEdgesLines(): void;
  84001. }
  84002. }
  84003. declare module BABYLON {
  84004. /**
  84005. * This represents the object necessary to create a rendering group.
  84006. * This is exclusively used and created by the rendering manager.
  84007. * To modify the behavior, you use the available helpers in your scene or meshes.
  84008. * @hidden
  84009. */
  84010. export class RenderingGroup {
  84011. index: number;
  84012. private static _zeroVector;
  84013. private _scene;
  84014. private _opaqueSubMeshes;
  84015. private _transparentSubMeshes;
  84016. private _alphaTestSubMeshes;
  84017. private _depthOnlySubMeshes;
  84018. private _particleSystems;
  84019. private _spriteManagers;
  84020. private _opaqueSortCompareFn;
  84021. private _alphaTestSortCompareFn;
  84022. private _transparentSortCompareFn;
  84023. private _renderOpaque;
  84024. private _renderAlphaTest;
  84025. private _renderTransparent;
  84026. /** @hidden */
  84027. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84028. onBeforeTransparentRendering: () => void;
  84029. /**
  84030. * Set the opaque sort comparison function.
  84031. * If null the sub meshes will be render in the order they were created
  84032. */
  84033. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84034. /**
  84035. * Set the alpha test sort comparison function.
  84036. * If null the sub meshes will be render in the order they were created
  84037. */
  84038. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84039. /**
  84040. * Set the transparent sort comparison function.
  84041. * If null the sub meshes will be render in the order they were created
  84042. */
  84043. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84044. /**
  84045. * Creates a new rendering group.
  84046. * @param index The rendering group index
  84047. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84048. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84049. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84050. */
  84051. 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>);
  84052. /**
  84053. * Render all the sub meshes contained in the group.
  84054. * @param customRenderFunction Used to override the default render behaviour of the group.
  84055. * @returns true if rendered some submeshes.
  84056. */
  84057. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84058. /**
  84059. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84060. * @param subMeshes The submeshes to render
  84061. */
  84062. private renderOpaqueSorted;
  84063. /**
  84064. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84065. * @param subMeshes The submeshes to render
  84066. */
  84067. private renderAlphaTestSorted;
  84068. /**
  84069. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84070. * @param subMeshes The submeshes to render
  84071. */
  84072. private renderTransparentSorted;
  84073. /**
  84074. * Renders the submeshes in a specified order.
  84075. * @param subMeshes The submeshes to sort before render
  84076. * @param sortCompareFn The comparison function use to sort
  84077. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84078. * @param transparent Specifies to activate blending if true
  84079. */
  84080. private static renderSorted;
  84081. /**
  84082. * Renders the submeshes in the order they were dispatched (no sort applied).
  84083. * @param subMeshes The submeshes to render
  84084. */
  84085. private static renderUnsorted;
  84086. /**
  84087. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84088. * are rendered back to front if in the same alpha index.
  84089. *
  84090. * @param a The first submesh
  84091. * @param b The second submesh
  84092. * @returns The result of the comparison
  84093. */
  84094. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84095. /**
  84096. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84097. * are rendered back to front.
  84098. *
  84099. * @param a The first submesh
  84100. * @param b The second submesh
  84101. * @returns The result of the comparison
  84102. */
  84103. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84104. /**
  84105. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84106. * are rendered front to back (prevent overdraw).
  84107. *
  84108. * @param a The first submesh
  84109. * @param b The second submesh
  84110. * @returns The result of the comparison
  84111. */
  84112. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84113. /**
  84114. * Resets the different lists of submeshes to prepare a new frame.
  84115. */
  84116. prepare(): void;
  84117. dispose(): void;
  84118. /**
  84119. * Inserts the submesh in its correct queue depending on its material.
  84120. * @param subMesh The submesh to dispatch
  84121. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84122. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84123. */
  84124. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84125. dispatchSprites(spriteManager: ISpriteManager): void;
  84126. dispatchParticles(particleSystem: IParticleSystem): void;
  84127. private _renderParticles;
  84128. private _renderSprites;
  84129. }
  84130. }
  84131. declare module BABYLON {
  84132. /**
  84133. * Interface describing the different options available in the rendering manager
  84134. * regarding Auto Clear between groups.
  84135. */
  84136. export interface IRenderingManagerAutoClearSetup {
  84137. /**
  84138. * Defines whether or not autoclear is enable.
  84139. */
  84140. autoClear: boolean;
  84141. /**
  84142. * Defines whether or not to autoclear the depth buffer.
  84143. */
  84144. depth: boolean;
  84145. /**
  84146. * Defines whether or not to autoclear the stencil buffer.
  84147. */
  84148. stencil: boolean;
  84149. }
  84150. /**
  84151. * This class is used by the onRenderingGroupObservable
  84152. */
  84153. export class RenderingGroupInfo {
  84154. /**
  84155. * The Scene that being rendered
  84156. */
  84157. scene: Scene;
  84158. /**
  84159. * The camera currently used for the rendering pass
  84160. */
  84161. camera: Nullable<Camera>;
  84162. /**
  84163. * The ID of the renderingGroup being processed
  84164. */
  84165. renderingGroupId: number;
  84166. }
  84167. /**
  84168. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84169. * It is enable to manage the different groups as well as the different necessary sort functions.
  84170. * This should not be used directly aside of the few static configurations
  84171. */
  84172. export class RenderingManager {
  84173. /**
  84174. * The max id used for rendering groups (not included)
  84175. */
  84176. static MAX_RENDERINGGROUPS: number;
  84177. /**
  84178. * The min id used for rendering groups (included)
  84179. */
  84180. static MIN_RENDERINGGROUPS: number;
  84181. /**
  84182. * Used to globally prevent autoclearing scenes.
  84183. */
  84184. static AUTOCLEAR: boolean;
  84185. /**
  84186. * @hidden
  84187. */
  84188. _useSceneAutoClearSetup: boolean;
  84189. private _scene;
  84190. private _renderingGroups;
  84191. private _depthStencilBufferAlreadyCleaned;
  84192. private _autoClearDepthStencil;
  84193. private _customOpaqueSortCompareFn;
  84194. private _customAlphaTestSortCompareFn;
  84195. private _customTransparentSortCompareFn;
  84196. private _renderingGroupInfo;
  84197. /**
  84198. * Instantiates a new rendering group for a particular scene
  84199. * @param scene Defines the scene the groups belongs to
  84200. */
  84201. constructor(scene: Scene);
  84202. private _clearDepthStencilBuffer;
  84203. /**
  84204. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84205. * @hidden
  84206. */
  84207. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84208. /**
  84209. * Resets the different information of the group to prepare a new frame
  84210. * @hidden
  84211. */
  84212. reset(): void;
  84213. /**
  84214. * Dispose and release the group and its associated resources.
  84215. * @hidden
  84216. */
  84217. dispose(): void;
  84218. /**
  84219. * Clear the info related to rendering groups preventing retention points during dispose.
  84220. */
  84221. freeRenderingGroups(): void;
  84222. private _prepareRenderingGroup;
  84223. /**
  84224. * Add a sprite manager to the rendering manager in order to render it this frame.
  84225. * @param spriteManager Define the sprite manager to render
  84226. */
  84227. dispatchSprites(spriteManager: ISpriteManager): void;
  84228. /**
  84229. * Add a particle system to the rendering manager in order to render it this frame.
  84230. * @param particleSystem Define the particle system to render
  84231. */
  84232. dispatchParticles(particleSystem: IParticleSystem): void;
  84233. /**
  84234. * Add a submesh to the manager in order to render it this frame
  84235. * @param subMesh The submesh to dispatch
  84236. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84237. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84238. */
  84239. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84240. /**
  84241. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84242. * This allowed control for front to back rendering or reversly depending of the special needs.
  84243. *
  84244. * @param renderingGroupId The rendering group id corresponding to its index
  84245. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84246. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84247. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84248. */
  84249. 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;
  84250. /**
  84251. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84252. *
  84253. * @param renderingGroupId The rendering group id corresponding to its index
  84254. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84255. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84256. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84257. */
  84258. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84259. /**
  84260. * Gets the current auto clear configuration for one rendering group of the rendering
  84261. * manager.
  84262. * @param index the rendering group index to get the information for
  84263. * @returns The auto clear setup for the requested rendering group
  84264. */
  84265. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84266. }
  84267. }
  84268. declare module BABYLON {
  84269. /**
  84270. * This Helps creating a texture that will be created from a camera in your scene.
  84271. * It is basically a dynamic texture that could be used to create special effects for instance.
  84272. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84273. */
  84274. export class RenderTargetTexture extends Texture {
  84275. isCube: boolean;
  84276. /**
  84277. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84278. */
  84279. static readonly REFRESHRATE_RENDER_ONCE: number;
  84280. /**
  84281. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84282. */
  84283. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84284. /**
  84285. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84286. * the central point of your effect and can save a lot of performances.
  84287. */
  84288. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84289. /**
  84290. * Use this predicate to dynamically define the list of mesh you want to render.
  84291. * If set, the renderList property will be overwritten.
  84292. */
  84293. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84294. private _renderList;
  84295. /**
  84296. * Use this list to define the list of mesh you want to render.
  84297. */
  84298. renderList: Nullable<Array<AbstractMesh>>;
  84299. private _hookArray;
  84300. /**
  84301. * Define if particles should be rendered in your texture.
  84302. */
  84303. renderParticles: boolean;
  84304. /**
  84305. * Define if sprites should be rendered in your texture.
  84306. */
  84307. renderSprites: boolean;
  84308. /**
  84309. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84310. */
  84311. coordinatesMode: number;
  84312. /**
  84313. * Define the camera used to render the texture.
  84314. */
  84315. activeCamera: Nullable<Camera>;
  84316. /**
  84317. * Override the render function of the texture with your own one.
  84318. */
  84319. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84320. /**
  84321. * Define if camera post processes should be use while rendering the texture.
  84322. */
  84323. useCameraPostProcesses: boolean;
  84324. /**
  84325. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84326. */
  84327. ignoreCameraViewport: boolean;
  84328. private _postProcessManager;
  84329. private _postProcesses;
  84330. private _resizeObserver;
  84331. /**
  84332. * An event triggered when the texture is unbind.
  84333. */
  84334. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84335. /**
  84336. * An event triggered when the texture is unbind.
  84337. */
  84338. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84339. private _onAfterUnbindObserver;
  84340. /**
  84341. * Set a after unbind callback in the texture.
  84342. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84343. */
  84344. onAfterUnbind: () => void;
  84345. /**
  84346. * An event triggered before rendering the texture
  84347. */
  84348. onBeforeRenderObservable: Observable<number>;
  84349. private _onBeforeRenderObserver;
  84350. /**
  84351. * Set a before render callback in the texture.
  84352. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84353. */
  84354. onBeforeRender: (faceIndex: number) => void;
  84355. /**
  84356. * An event triggered after rendering the texture
  84357. */
  84358. onAfterRenderObservable: Observable<number>;
  84359. private _onAfterRenderObserver;
  84360. /**
  84361. * Set a after render callback in the texture.
  84362. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84363. */
  84364. onAfterRender: (faceIndex: number) => void;
  84365. /**
  84366. * An event triggered after the texture clear
  84367. */
  84368. onClearObservable: Observable<Engine>;
  84369. private _onClearObserver;
  84370. /**
  84371. * Set a clear callback in the texture.
  84372. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84373. */
  84374. onClear: (Engine: Engine) => void;
  84375. /**
  84376. * Define the clear color of the Render Target if it should be different from the scene.
  84377. */
  84378. clearColor: Color4;
  84379. protected _size: number | {
  84380. width: number;
  84381. height: number;
  84382. };
  84383. protected _initialSizeParameter: number | {
  84384. width: number;
  84385. height: number;
  84386. } | {
  84387. ratio: number;
  84388. };
  84389. protected _sizeRatio: Nullable<number>;
  84390. /** @hidden */
  84391. _generateMipMaps: boolean;
  84392. protected _renderingManager: RenderingManager;
  84393. /** @hidden */
  84394. _waitingRenderList: string[];
  84395. protected _doNotChangeAspectRatio: boolean;
  84396. protected _currentRefreshId: number;
  84397. protected _refreshRate: number;
  84398. protected _textureMatrix: Matrix;
  84399. protected _samples: number;
  84400. protected _renderTargetOptions: RenderTargetCreationOptions;
  84401. /**
  84402. * Gets render target creation options that were used.
  84403. */
  84404. readonly renderTargetOptions: RenderTargetCreationOptions;
  84405. protected _engine: Engine;
  84406. protected _onRatioRescale(): void;
  84407. /**
  84408. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84409. * It must define where the camera used to render the texture is set
  84410. */
  84411. boundingBoxPosition: Vector3;
  84412. private _boundingBoxSize;
  84413. /**
  84414. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84415. * When defined, the cubemap will switch to local mode
  84416. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84417. * @example https://www.babylonjs-playground.com/#RNASML
  84418. */
  84419. boundingBoxSize: Vector3;
  84420. /**
  84421. * In case the RTT has been created with a depth texture, get the associated
  84422. * depth texture.
  84423. * Otherwise, return null.
  84424. */
  84425. depthStencilTexture: Nullable<InternalTexture>;
  84426. /**
  84427. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84428. * or used a shadow, depth texture...
  84429. * @param name The friendly name of the texture
  84430. * @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)
  84431. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84432. * @param generateMipMaps True if mip maps need to be generated after render.
  84433. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84434. * @param type The type of the buffer in the RTT (int, half float, float...)
  84435. * @param isCube True if a cube texture needs to be created
  84436. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84437. * @param generateDepthBuffer True to generate a depth buffer
  84438. * @param generateStencilBuffer True to generate a stencil buffer
  84439. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84440. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84441. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84442. */
  84443. constructor(name: string, size: number | {
  84444. width: number;
  84445. height: number;
  84446. } | {
  84447. ratio: number;
  84448. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84449. /**
  84450. * Creates a depth stencil texture.
  84451. * This is only available in WebGL 2 or with the depth texture extension available.
  84452. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84453. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84454. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84455. */
  84456. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84457. private _processSizeParameter;
  84458. /**
  84459. * Define the number of samples to use in case of MSAA.
  84460. * It defaults to one meaning no MSAA has been enabled.
  84461. */
  84462. samples: number;
  84463. /**
  84464. * Resets the refresh counter of the texture and start bak from scratch.
  84465. * Could be useful to regenerate the texture if it is setup to render only once.
  84466. */
  84467. resetRefreshCounter(): void;
  84468. /**
  84469. * Define the refresh rate of the texture or the rendering frequency.
  84470. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84471. */
  84472. refreshRate: number;
  84473. /**
  84474. * Adds a post process to the render target rendering passes.
  84475. * @param postProcess define the post process to add
  84476. */
  84477. addPostProcess(postProcess: PostProcess): void;
  84478. /**
  84479. * Clear all the post processes attached to the render target
  84480. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84481. */
  84482. clearPostProcesses(dispose?: boolean): void;
  84483. /**
  84484. * Remove one of the post process from the list of attached post processes to the texture
  84485. * @param postProcess define the post process to remove from the list
  84486. */
  84487. removePostProcess(postProcess: PostProcess): void;
  84488. /** @hidden */
  84489. _shouldRender(): boolean;
  84490. /**
  84491. * Gets the actual render size of the texture.
  84492. * @returns the width of the render size
  84493. */
  84494. getRenderSize(): number;
  84495. /**
  84496. * Gets the actual render width of the texture.
  84497. * @returns the width of the render size
  84498. */
  84499. getRenderWidth(): number;
  84500. /**
  84501. * Gets the actual render height of the texture.
  84502. * @returns the height of the render size
  84503. */
  84504. getRenderHeight(): number;
  84505. /**
  84506. * Get if the texture can be rescaled or not.
  84507. */
  84508. readonly canRescale: boolean;
  84509. /**
  84510. * Resize the texture using a ratio.
  84511. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84512. */
  84513. scale(ratio: number): void;
  84514. /**
  84515. * Get the texture reflection matrix used to rotate/transform the reflection.
  84516. * @returns the reflection matrix
  84517. */
  84518. getReflectionTextureMatrix(): Matrix;
  84519. /**
  84520. * Resize the texture to a new desired size.
  84521. * Be carrefull as it will recreate all the data in the new texture.
  84522. * @param size Define the new size. It can be:
  84523. * - a number for squared texture,
  84524. * - an object containing { width: number, height: number }
  84525. * - or an object containing a ratio { ratio: number }
  84526. */
  84527. resize(size: number | {
  84528. width: number;
  84529. height: number;
  84530. } | {
  84531. ratio: number;
  84532. }): void;
  84533. /**
  84534. * Renders all the objects from the render list into the texture.
  84535. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84536. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84537. */
  84538. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84539. private _bestReflectionRenderTargetDimension;
  84540. /**
  84541. * @hidden
  84542. * @param faceIndex face index to bind to if this is a cubetexture
  84543. */
  84544. _bindFrameBuffer(faceIndex?: number): void;
  84545. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84546. private renderToTarget;
  84547. /**
  84548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84549. * This allowed control for front to back rendering or reversly depending of the special needs.
  84550. *
  84551. * @param renderingGroupId The rendering group id corresponding to its index
  84552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84555. */
  84556. 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;
  84557. /**
  84558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84559. *
  84560. * @param renderingGroupId The rendering group id corresponding to its index
  84561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84562. */
  84563. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84564. /**
  84565. * Clones the texture.
  84566. * @returns the cloned texture
  84567. */
  84568. clone(): RenderTargetTexture;
  84569. /**
  84570. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84571. * @returns The JSON representation of the texture
  84572. */
  84573. serialize(): any;
  84574. /**
  84575. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84576. */
  84577. disposeFramebufferObjects(): void;
  84578. /**
  84579. * Dispose the texture and release its associated resources.
  84580. */
  84581. dispose(): void;
  84582. /** @hidden */
  84583. _rebuild(): void;
  84584. /**
  84585. * Clear the info related to rendering groups preventing retention point in material dispose.
  84586. */
  84587. freeRenderingGroups(): void;
  84588. /**
  84589. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84590. * @returns the view count
  84591. */
  84592. getViewCount(): number;
  84593. }
  84594. }
  84595. declare module BABYLON {
  84596. /**
  84597. * Base class for the main features of a material in Babylon.js
  84598. */
  84599. export class Material implements IAnimatable {
  84600. /**
  84601. * Returns the triangle fill mode
  84602. */
  84603. static readonly TriangleFillMode: number;
  84604. /**
  84605. * Returns the wireframe mode
  84606. */
  84607. static readonly WireFrameFillMode: number;
  84608. /**
  84609. * Returns the point fill mode
  84610. */
  84611. static readonly PointFillMode: number;
  84612. /**
  84613. * Returns the point list draw mode
  84614. */
  84615. static readonly PointListDrawMode: number;
  84616. /**
  84617. * Returns the line list draw mode
  84618. */
  84619. static readonly LineListDrawMode: number;
  84620. /**
  84621. * Returns the line loop draw mode
  84622. */
  84623. static readonly LineLoopDrawMode: number;
  84624. /**
  84625. * Returns the line strip draw mode
  84626. */
  84627. static readonly LineStripDrawMode: number;
  84628. /**
  84629. * Returns the triangle strip draw mode
  84630. */
  84631. static readonly TriangleStripDrawMode: number;
  84632. /**
  84633. * Returns the triangle fan draw mode
  84634. */
  84635. static readonly TriangleFanDrawMode: number;
  84636. /**
  84637. * Stores the clock-wise side orientation
  84638. */
  84639. static readonly ClockWiseSideOrientation: number;
  84640. /**
  84641. * Stores the counter clock-wise side orientation
  84642. */
  84643. static readonly CounterClockWiseSideOrientation: number;
  84644. /**
  84645. * The dirty texture flag value
  84646. */
  84647. static readonly TextureDirtyFlag: number;
  84648. /**
  84649. * The dirty light flag value
  84650. */
  84651. static readonly LightDirtyFlag: number;
  84652. /**
  84653. * The dirty fresnel flag value
  84654. */
  84655. static readonly FresnelDirtyFlag: number;
  84656. /**
  84657. * The dirty attribute flag value
  84658. */
  84659. static readonly AttributesDirtyFlag: number;
  84660. /**
  84661. * The dirty misc flag value
  84662. */
  84663. static readonly MiscDirtyFlag: number;
  84664. /**
  84665. * The all dirty flag value
  84666. */
  84667. static readonly AllDirtyFlag: number;
  84668. /**
  84669. * The ID of the material
  84670. */
  84671. id: string;
  84672. /**
  84673. * Gets or sets the unique id of the material
  84674. */
  84675. uniqueId: number;
  84676. /**
  84677. * The name of the material
  84678. */
  84679. name: string;
  84680. /**
  84681. * Gets or sets user defined metadata
  84682. */
  84683. metadata: any;
  84684. /**
  84685. * For internal use only. Please do not use.
  84686. */
  84687. reservedDataStore: any;
  84688. /**
  84689. * Specifies if the ready state should be checked on each call
  84690. */
  84691. checkReadyOnEveryCall: boolean;
  84692. /**
  84693. * Specifies if the ready state should be checked once
  84694. */
  84695. checkReadyOnlyOnce: boolean;
  84696. /**
  84697. * The state of the material
  84698. */
  84699. state: string;
  84700. /**
  84701. * The alpha value of the material
  84702. */
  84703. protected _alpha: number;
  84704. /**
  84705. * List of inspectable custom properties (used by the Inspector)
  84706. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84707. */
  84708. inspectableCustomProperties: IInspectable[];
  84709. /**
  84710. * Sets the alpha value of the material
  84711. */
  84712. /**
  84713. * Gets the alpha value of the material
  84714. */
  84715. alpha: number;
  84716. /**
  84717. * Specifies if back face culling is enabled
  84718. */
  84719. protected _backFaceCulling: boolean;
  84720. /**
  84721. * Sets the back-face culling state
  84722. */
  84723. /**
  84724. * Gets the back-face culling state
  84725. */
  84726. backFaceCulling: boolean;
  84727. /**
  84728. * Stores the value for side orientation
  84729. */
  84730. sideOrientation: number;
  84731. /**
  84732. * Callback triggered when the material is compiled
  84733. */
  84734. onCompiled: Nullable<(effect: Effect) => void>;
  84735. /**
  84736. * Callback triggered when an error occurs
  84737. */
  84738. onError: Nullable<(effect: Effect, errors: string) => void>;
  84739. /**
  84740. * Callback triggered to get the render target textures
  84741. */
  84742. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84743. /**
  84744. * Gets a boolean indicating that current material needs to register RTT
  84745. */
  84746. readonly hasRenderTargetTextures: boolean;
  84747. /**
  84748. * Specifies if the material should be serialized
  84749. */
  84750. doNotSerialize: boolean;
  84751. /**
  84752. * @hidden
  84753. */
  84754. _storeEffectOnSubMeshes: boolean;
  84755. /**
  84756. * Stores the animations for the material
  84757. */
  84758. animations: Nullable<Array<Animation>>;
  84759. /**
  84760. * An event triggered when the material is disposed
  84761. */
  84762. onDisposeObservable: Observable<Material>;
  84763. /**
  84764. * An observer which watches for dispose events
  84765. */
  84766. private _onDisposeObserver;
  84767. private _onUnBindObservable;
  84768. /**
  84769. * Called during a dispose event
  84770. */
  84771. onDispose: () => void;
  84772. private _onBindObservable;
  84773. /**
  84774. * An event triggered when the material is bound
  84775. */
  84776. readonly onBindObservable: Observable<AbstractMesh>;
  84777. /**
  84778. * An observer which watches for bind events
  84779. */
  84780. private _onBindObserver;
  84781. /**
  84782. * Called during a bind event
  84783. */
  84784. onBind: (Mesh: AbstractMesh) => void;
  84785. /**
  84786. * An event triggered when the material is unbound
  84787. */
  84788. readonly onUnBindObservable: Observable<Material>;
  84789. /**
  84790. * Stores the value of the alpha mode
  84791. */
  84792. private _alphaMode;
  84793. /**
  84794. * Sets the value of the alpha mode.
  84795. *
  84796. * | Value | Type | Description |
  84797. * | --- | --- | --- |
  84798. * | 0 | ALPHA_DISABLE | |
  84799. * | 1 | ALPHA_ADD | |
  84800. * | 2 | ALPHA_COMBINE | |
  84801. * | 3 | ALPHA_SUBTRACT | |
  84802. * | 4 | ALPHA_MULTIPLY | |
  84803. * | 5 | ALPHA_MAXIMIZED | |
  84804. * | 6 | ALPHA_ONEONE | |
  84805. * | 7 | ALPHA_PREMULTIPLIED | |
  84806. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84807. * | 9 | ALPHA_INTERPOLATE | |
  84808. * | 10 | ALPHA_SCREENMODE | |
  84809. *
  84810. */
  84811. /**
  84812. * Gets the value of the alpha mode
  84813. */
  84814. alphaMode: number;
  84815. /**
  84816. * Stores the state of the need depth pre-pass value
  84817. */
  84818. private _needDepthPrePass;
  84819. /**
  84820. * Sets the need depth pre-pass value
  84821. */
  84822. /**
  84823. * Gets the depth pre-pass value
  84824. */
  84825. needDepthPrePass: boolean;
  84826. /**
  84827. * Specifies if depth writing should be disabled
  84828. */
  84829. disableDepthWrite: boolean;
  84830. /**
  84831. * Specifies if depth writing should be forced
  84832. */
  84833. forceDepthWrite: boolean;
  84834. /**
  84835. * Specifies if there should be a separate pass for culling
  84836. */
  84837. separateCullingPass: boolean;
  84838. /**
  84839. * Stores the state specifing if fog should be enabled
  84840. */
  84841. private _fogEnabled;
  84842. /**
  84843. * Sets the state for enabling fog
  84844. */
  84845. /**
  84846. * Gets the value of the fog enabled state
  84847. */
  84848. fogEnabled: boolean;
  84849. /**
  84850. * Stores the size of points
  84851. */
  84852. pointSize: number;
  84853. /**
  84854. * Stores the z offset value
  84855. */
  84856. zOffset: number;
  84857. /**
  84858. * Gets a value specifying if wireframe mode is enabled
  84859. */
  84860. /**
  84861. * Sets the state of wireframe mode
  84862. */
  84863. wireframe: boolean;
  84864. /**
  84865. * Gets the value specifying if point clouds are enabled
  84866. */
  84867. /**
  84868. * Sets the state of point cloud mode
  84869. */
  84870. pointsCloud: boolean;
  84871. /**
  84872. * Gets the material fill mode
  84873. */
  84874. /**
  84875. * Sets the material fill mode
  84876. */
  84877. fillMode: number;
  84878. /**
  84879. * @hidden
  84880. * Stores the effects for the material
  84881. */
  84882. _effect: Nullable<Effect>;
  84883. /**
  84884. * @hidden
  84885. * Specifies if the material was previously ready
  84886. */
  84887. _wasPreviouslyReady: boolean;
  84888. /**
  84889. * Specifies if uniform buffers should be used
  84890. */
  84891. private _useUBO;
  84892. /**
  84893. * Stores a reference to the scene
  84894. */
  84895. private _scene;
  84896. /**
  84897. * Stores the fill mode state
  84898. */
  84899. private _fillMode;
  84900. /**
  84901. * Specifies if the depth write state should be cached
  84902. */
  84903. private _cachedDepthWriteState;
  84904. /**
  84905. * Stores the uniform buffer
  84906. */
  84907. protected _uniformBuffer: UniformBuffer;
  84908. /** @hidden */
  84909. _indexInSceneMaterialArray: number;
  84910. /** @hidden */
  84911. meshMap: Nullable<{
  84912. [id: string]: AbstractMesh | undefined;
  84913. }>;
  84914. /**
  84915. * Creates a material instance
  84916. * @param name defines the name of the material
  84917. * @param scene defines the scene to reference
  84918. * @param doNotAdd specifies if the material should be added to the scene
  84919. */
  84920. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84921. /**
  84922. * Returns a string representation of the current material
  84923. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84924. * @returns a string with material information
  84925. */
  84926. toString(fullDetails?: boolean): string;
  84927. /**
  84928. * Gets the class name of the material
  84929. * @returns a string with the class name of the material
  84930. */
  84931. getClassName(): string;
  84932. /**
  84933. * Specifies if updates for the material been locked
  84934. */
  84935. readonly isFrozen: boolean;
  84936. /**
  84937. * Locks updates for the material
  84938. */
  84939. freeze(): void;
  84940. /**
  84941. * Unlocks updates for the material
  84942. */
  84943. unfreeze(): void;
  84944. /**
  84945. * Specifies if the material is ready to be used
  84946. * @param mesh defines the mesh to check
  84947. * @param useInstances specifies if instances should be used
  84948. * @returns a boolean indicating if the material is ready to be used
  84949. */
  84950. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84951. /**
  84952. * Specifies that the submesh is ready to be used
  84953. * @param mesh defines the mesh to check
  84954. * @param subMesh defines which submesh to check
  84955. * @param useInstances specifies that instances should be used
  84956. * @returns a boolean indicating that the submesh is ready or not
  84957. */
  84958. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84959. /**
  84960. * Returns the material effect
  84961. * @returns the effect associated with the material
  84962. */
  84963. getEffect(): Nullable<Effect>;
  84964. /**
  84965. * Returns the current scene
  84966. * @returns a Scene
  84967. */
  84968. getScene(): Scene;
  84969. /**
  84970. * Specifies if the material will require alpha blending
  84971. * @returns a boolean specifying if alpha blending is needed
  84972. */
  84973. needAlphaBlending(): boolean;
  84974. /**
  84975. * Specifies if the mesh will require alpha blending
  84976. * @param mesh defines the mesh to check
  84977. * @returns a boolean specifying if alpha blending is needed for the mesh
  84978. */
  84979. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84980. /**
  84981. * Specifies if this material should be rendered in alpha test mode
  84982. * @returns a boolean specifying if an alpha test is needed.
  84983. */
  84984. needAlphaTesting(): boolean;
  84985. /**
  84986. * Gets the texture used for the alpha test
  84987. * @returns the texture to use for alpha testing
  84988. */
  84989. getAlphaTestTexture(): Nullable<BaseTexture>;
  84990. /**
  84991. * Marks the material to indicate that it needs to be re-calculated
  84992. */
  84993. markDirty(): void;
  84994. /** @hidden */
  84995. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84996. /**
  84997. * Binds the material to the mesh
  84998. * @param world defines the world transformation matrix
  84999. * @param mesh defines the mesh to bind the material to
  85000. */
  85001. bind(world: Matrix, mesh?: Mesh): void;
  85002. /**
  85003. * Binds the submesh to the material
  85004. * @param world defines the world transformation matrix
  85005. * @param mesh defines the mesh containing the submesh
  85006. * @param subMesh defines the submesh to bind the material to
  85007. */
  85008. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85009. /**
  85010. * Binds the world matrix to the material
  85011. * @param world defines the world transformation matrix
  85012. */
  85013. bindOnlyWorldMatrix(world: Matrix): void;
  85014. /**
  85015. * Binds the scene's uniform buffer to the effect.
  85016. * @param effect defines the effect to bind to the scene uniform buffer
  85017. * @param sceneUbo defines the uniform buffer storing scene data
  85018. */
  85019. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85020. /**
  85021. * Binds the view matrix to the effect
  85022. * @param effect defines the effect to bind the view matrix to
  85023. */
  85024. bindView(effect: Effect): void;
  85025. /**
  85026. * Binds the view projection matrix to the effect
  85027. * @param effect defines the effect to bind the view projection matrix to
  85028. */
  85029. bindViewProjection(effect: Effect): void;
  85030. /**
  85031. * Specifies if material alpha testing should be turned on for the mesh
  85032. * @param mesh defines the mesh to check
  85033. */
  85034. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85035. /**
  85036. * Processes to execute after binding the material to a mesh
  85037. * @param mesh defines the rendered mesh
  85038. */
  85039. protected _afterBind(mesh?: Mesh): void;
  85040. /**
  85041. * Unbinds the material from the mesh
  85042. */
  85043. unbind(): void;
  85044. /**
  85045. * Gets the active textures from the material
  85046. * @returns an array of textures
  85047. */
  85048. getActiveTextures(): BaseTexture[];
  85049. /**
  85050. * Specifies if the material uses a texture
  85051. * @param texture defines the texture to check against the material
  85052. * @returns a boolean specifying if the material uses the texture
  85053. */
  85054. hasTexture(texture: BaseTexture): boolean;
  85055. /**
  85056. * Makes a duplicate of the material, and gives it a new name
  85057. * @param name defines the new name for the duplicated material
  85058. * @returns the cloned material
  85059. */
  85060. clone(name: string): Nullable<Material>;
  85061. /**
  85062. * Gets the meshes bound to the material
  85063. * @returns an array of meshes bound to the material
  85064. */
  85065. getBindedMeshes(): AbstractMesh[];
  85066. /**
  85067. * Force shader compilation
  85068. * @param mesh defines the mesh associated with this material
  85069. * @param onCompiled defines a function to execute once the material is compiled
  85070. * @param options defines the options to configure the compilation
  85071. */
  85072. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85073. clipPlane: boolean;
  85074. }>): void;
  85075. /**
  85076. * Force shader compilation
  85077. * @param mesh defines the mesh that will use this material
  85078. * @param options defines additional options for compiling the shaders
  85079. * @returns a promise that resolves when the compilation completes
  85080. */
  85081. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85082. clipPlane: boolean;
  85083. }>): Promise<void>;
  85084. private static readonly _AllDirtyCallBack;
  85085. private static readonly _ImageProcessingDirtyCallBack;
  85086. private static readonly _TextureDirtyCallBack;
  85087. private static readonly _FresnelDirtyCallBack;
  85088. private static readonly _MiscDirtyCallBack;
  85089. private static readonly _LightsDirtyCallBack;
  85090. private static readonly _AttributeDirtyCallBack;
  85091. private static _FresnelAndMiscDirtyCallBack;
  85092. private static _TextureAndMiscDirtyCallBack;
  85093. private static readonly _DirtyCallbackArray;
  85094. private static readonly _RunDirtyCallBacks;
  85095. /**
  85096. * Marks a define in the material to indicate that it needs to be re-computed
  85097. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85098. */
  85099. markAsDirty(flag: number): void;
  85100. /**
  85101. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85102. * @param func defines a function which checks material defines against the submeshes
  85103. */
  85104. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85105. /**
  85106. * Indicates that we need to re-calculated for all submeshes
  85107. */
  85108. protected _markAllSubMeshesAsAllDirty(): void;
  85109. /**
  85110. * Indicates that image processing needs to be re-calculated for all submeshes
  85111. */
  85112. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85113. /**
  85114. * Indicates that textures need to be re-calculated for all submeshes
  85115. */
  85116. protected _markAllSubMeshesAsTexturesDirty(): void;
  85117. /**
  85118. * Indicates that fresnel needs to be re-calculated for all submeshes
  85119. */
  85120. protected _markAllSubMeshesAsFresnelDirty(): void;
  85121. /**
  85122. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85123. */
  85124. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85125. /**
  85126. * Indicates that lights need to be re-calculated for all submeshes
  85127. */
  85128. protected _markAllSubMeshesAsLightsDirty(): void;
  85129. /**
  85130. * Indicates that attributes need to be re-calculated for all submeshes
  85131. */
  85132. protected _markAllSubMeshesAsAttributesDirty(): void;
  85133. /**
  85134. * Indicates that misc needs to be re-calculated for all submeshes
  85135. */
  85136. protected _markAllSubMeshesAsMiscDirty(): void;
  85137. /**
  85138. * Indicates that textures and misc need to be re-calculated for all submeshes
  85139. */
  85140. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85141. /**
  85142. * Disposes the material
  85143. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85144. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85145. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85146. */
  85147. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85148. /** @hidden */
  85149. private releaseVertexArrayObject;
  85150. /**
  85151. * Serializes this material
  85152. * @returns the serialized material object
  85153. */
  85154. serialize(): any;
  85155. /**
  85156. * Creates a material from parsed material data
  85157. * @param parsedMaterial defines parsed material data
  85158. * @param scene defines the hosting scene
  85159. * @param rootUrl defines the root URL to use to load textures
  85160. * @returns a new material
  85161. */
  85162. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85163. }
  85164. }
  85165. declare module BABYLON {
  85166. /**
  85167. * Base class for submeshes
  85168. */
  85169. export class BaseSubMesh {
  85170. /** @hidden */
  85171. _materialDefines: Nullable<MaterialDefines>;
  85172. /** @hidden */
  85173. _materialEffect: Nullable<Effect>;
  85174. /**
  85175. * Gets associated effect
  85176. */
  85177. readonly effect: Nullable<Effect>;
  85178. /**
  85179. * Sets associated effect (effect used to render this submesh)
  85180. * @param effect defines the effect to associate with
  85181. * @param defines defines the set of defines used to compile this effect
  85182. */
  85183. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85184. }
  85185. /**
  85186. * Defines a subdivision inside a mesh
  85187. */
  85188. export class SubMesh extends BaseSubMesh implements ICullable {
  85189. /** the material index to use */
  85190. materialIndex: number;
  85191. /** vertex index start */
  85192. verticesStart: number;
  85193. /** vertices count */
  85194. verticesCount: number;
  85195. /** index start */
  85196. indexStart: number;
  85197. /** indices count */
  85198. indexCount: number;
  85199. /** @hidden */
  85200. _linesIndexCount: number;
  85201. private _mesh;
  85202. private _renderingMesh;
  85203. private _boundingInfo;
  85204. private _linesIndexBuffer;
  85205. /** @hidden */
  85206. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85207. /** @hidden */
  85208. _trianglePlanes: Plane[];
  85209. /** @hidden */
  85210. _lastColliderTransformMatrix: Nullable<Matrix>;
  85211. /** @hidden */
  85212. _renderId: number;
  85213. /** @hidden */
  85214. _alphaIndex: number;
  85215. /** @hidden */
  85216. _distanceToCamera: number;
  85217. /** @hidden */
  85218. _id: number;
  85219. private _currentMaterial;
  85220. /**
  85221. * Add a new submesh to a mesh
  85222. * @param materialIndex defines the material index to use
  85223. * @param verticesStart defines vertex index start
  85224. * @param verticesCount defines vertices count
  85225. * @param indexStart defines index start
  85226. * @param indexCount defines indices count
  85227. * @param mesh defines the parent mesh
  85228. * @param renderingMesh defines an optional rendering mesh
  85229. * @param createBoundingBox defines if bounding box should be created for this submesh
  85230. * @returns the new submesh
  85231. */
  85232. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85233. /**
  85234. * Creates a new submesh
  85235. * @param materialIndex defines the material index to use
  85236. * @param verticesStart defines vertex index start
  85237. * @param verticesCount defines vertices count
  85238. * @param indexStart defines index start
  85239. * @param indexCount defines indices count
  85240. * @param mesh defines the parent mesh
  85241. * @param renderingMesh defines an optional rendering mesh
  85242. * @param createBoundingBox defines if bounding box should be created for this submesh
  85243. */
  85244. constructor(
  85245. /** the material index to use */
  85246. materialIndex: number,
  85247. /** vertex index start */
  85248. verticesStart: number,
  85249. /** vertices count */
  85250. verticesCount: number,
  85251. /** index start */
  85252. indexStart: number,
  85253. /** indices count */
  85254. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85255. /**
  85256. * Returns true if this submesh covers the entire parent mesh
  85257. * @ignorenaming
  85258. */
  85259. readonly IsGlobal: boolean;
  85260. /**
  85261. * Returns the submesh BoudingInfo object
  85262. * @returns current bounding info (or mesh's one if the submesh is global)
  85263. */
  85264. getBoundingInfo(): BoundingInfo;
  85265. /**
  85266. * Sets the submesh BoundingInfo
  85267. * @param boundingInfo defines the new bounding info to use
  85268. * @returns the SubMesh
  85269. */
  85270. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85271. /**
  85272. * Returns the mesh of the current submesh
  85273. * @return the parent mesh
  85274. */
  85275. getMesh(): AbstractMesh;
  85276. /**
  85277. * Returns the rendering mesh of the submesh
  85278. * @returns the rendering mesh (could be different from parent mesh)
  85279. */
  85280. getRenderingMesh(): Mesh;
  85281. /**
  85282. * Returns the submesh material
  85283. * @returns null or the current material
  85284. */
  85285. getMaterial(): Nullable<Material>;
  85286. /**
  85287. * Sets a new updated BoundingInfo object to the submesh
  85288. * @param data defines an optional position array to use to determine the bounding info
  85289. * @returns the SubMesh
  85290. */
  85291. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85292. /** @hidden */
  85293. _checkCollision(collider: Collider): boolean;
  85294. /**
  85295. * Updates the submesh BoundingInfo
  85296. * @param world defines the world matrix to use to update the bounding info
  85297. * @returns the submesh
  85298. */
  85299. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85300. /**
  85301. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85302. * @param frustumPlanes defines the frustum planes
  85303. * @returns true if the submesh is intersecting with the frustum
  85304. */
  85305. isInFrustum(frustumPlanes: Plane[]): boolean;
  85306. /**
  85307. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85308. * @param frustumPlanes defines the frustum planes
  85309. * @returns true if the submesh is inside the frustum
  85310. */
  85311. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85312. /**
  85313. * Renders the submesh
  85314. * @param enableAlphaMode defines if alpha needs to be used
  85315. * @returns the submesh
  85316. */
  85317. render(enableAlphaMode: boolean): SubMesh;
  85318. /**
  85319. * @hidden
  85320. */
  85321. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85322. /**
  85323. * Checks if the submesh intersects with a ray
  85324. * @param ray defines the ray to test
  85325. * @returns true is the passed ray intersects the submesh bounding box
  85326. */
  85327. canIntersects(ray: Ray): boolean;
  85328. /**
  85329. * Intersects current submesh with a ray
  85330. * @param ray defines the ray to test
  85331. * @param positions defines mesh's positions array
  85332. * @param indices defines mesh's indices array
  85333. * @param fastCheck defines if only bounding info should be used
  85334. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85335. * @returns intersection info or null if no intersection
  85336. */
  85337. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85338. /** @hidden */
  85339. private _intersectLines;
  85340. /** @hidden */
  85341. private _intersectUnIndexedLines;
  85342. /** @hidden */
  85343. private _intersectTriangles;
  85344. /** @hidden */
  85345. private _intersectUnIndexedTriangles;
  85346. /** @hidden */
  85347. _rebuild(): void;
  85348. /**
  85349. * Creates a new submesh from the passed mesh
  85350. * @param newMesh defines the new hosting mesh
  85351. * @param newRenderingMesh defines an optional rendering mesh
  85352. * @returns the new submesh
  85353. */
  85354. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85355. /**
  85356. * Release associated resources
  85357. */
  85358. dispose(): void;
  85359. /**
  85360. * Gets the class name
  85361. * @returns the string "SubMesh".
  85362. */
  85363. getClassName(): string;
  85364. /**
  85365. * Creates a new submesh from indices data
  85366. * @param materialIndex the index of the main mesh material
  85367. * @param startIndex the index where to start the copy in the mesh indices array
  85368. * @param indexCount the number of indices to copy then from the startIndex
  85369. * @param mesh the main mesh to create the submesh from
  85370. * @param renderingMesh the optional rendering mesh
  85371. * @returns a new submesh
  85372. */
  85373. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85374. }
  85375. }
  85376. declare module BABYLON {
  85377. /**
  85378. * Class used to store geometry data (vertex buffers + index buffer)
  85379. */
  85380. export class Geometry implements IGetSetVerticesData {
  85381. /**
  85382. * Gets or sets the ID of the geometry
  85383. */
  85384. id: string;
  85385. /**
  85386. * Gets or sets the unique ID of the geometry
  85387. */
  85388. uniqueId: number;
  85389. /**
  85390. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85391. */
  85392. delayLoadState: number;
  85393. /**
  85394. * Gets the file containing the data to load when running in delay load state
  85395. */
  85396. delayLoadingFile: Nullable<string>;
  85397. /**
  85398. * Callback called when the geometry is updated
  85399. */
  85400. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85401. private _scene;
  85402. private _engine;
  85403. private _meshes;
  85404. private _totalVertices;
  85405. /** @hidden */
  85406. _indices: IndicesArray;
  85407. /** @hidden */
  85408. _vertexBuffers: {
  85409. [key: string]: VertexBuffer;
  85410. };
  85411. private _isDisposed;
  85412. private _extend;
  85413. private _boundingBias;
  85414. /** @hidden */
  85415. _delayInfo: Array<string>;
  85416. private _indexBuffer;
  85417. private _indexBufferIsUpdatable;
  85418. /** @hidden */
  85419. _boundingInfo: Nullable<BoundingInfo>;
  85420. /** @hidden */
  85421. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85422. /** @hidden */
  85423. _softwareSkinningFrameId: number;
  85424. private _vertexArrayObjects;
  85425. private _updatable;
  85426. /** @hidden */
  85427. _positions: Nullable<Vector3[]>;
  85428. /**
  85429. * 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
  85430. */
  85431. /**
  85432. * 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
  85433. */
  85434. boundingBias: Vector2;
  85435. /**
  85436. * Static function used to attach a new empty geometry to a mesh
  85437. * @param mesh defines the mesh to attach the geometry to
  85438. * @returns the new Geometry
  85439. */
  85440. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85441. /**
  85442. * Creates a new geometry
  85443. * @param id defines the unique ID
  85444. * @param scene defines the hosting scene
  85445. * @param vertexData defines the VertexData used to get geometry data
  85446. * @param updatable defines if geometry must be updatable (false by default)
  85447. * @param mesh defines the mesh that will be associated with the geometry
  85448. */
  85449. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85450. /**
  85451. * Gets the current extend of the geometry
  85452. */
  85453. readonly extend: {
  85454. minimum: Vector3;
  85455. maximum: Vector3;
  85456. };
  85457. /**
  85458. * Gets the hosting scene
  85459. * @returns the hosting Scene
  85460. */
  85461. getScene(): Scene;
  85462. /**
  85463. * Gets the hosting engine
  85464. * @returns the hosting Engine
  85465. */
  85466. getEngine(): Engine;
  85467. /**
  85468. * Defines if the geometry is ready to use
  85469. * @returns true if the geometry is ready to be used
  85470. */
  85471. isReady(): boolean;
  85472. /**
  85473. * Gets a value indicating that the geometry should not be serialized
  85474. */
  85475. readonly doNotSerialize: boolean;
  85476. /** @hidden */
  85477. _rebuild(): void;
  85478. /**
  85479. * Affects all geometry data in one call
  85480. * @param vertexData defines the geometry data
  85481. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85482. */
  85483. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85484. /**
  85485. * Set specific vertex data
  85486. * @param kind defines the data kind (Position, normal, etc...)
  85487. * @param data defines the vertex data to use
  85488. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85489. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85490. */
  85491. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85492. /**
  85493. * Removes a specific vertex data
  85494. * @param kind defines the data kind (Position, normal, etc...)
  85495. */
  85496. removeVerticesData(kind: string): void;
  85497. /**
  85498. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85499. * @param buffer defines the vertex buffer to use
  85500. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85501. */
  85502. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85503. /**
  85504. * Update a specific vertex buffer
  85505. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85506. * It will do nothing if the buffer is not updatable
  85507. * @param kind defines the data kind (Position, normal, etc...)
  85508. * @param data defines the data to use
  85509. * @param offset defines the offset in the target buffer where to store the data
  85510. * @param useBytes set to true if the offset is in bytes
  85511. */
  85512. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85513. /**
  85514. * Update a specific vertex buffer
  85515. * This function will create a new buffer if the current one is not updatable
  85516. * @param kind defines the data kind (Position, normal, etc...)
  85517. * @param data defines the data to use
  85518. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85519. */
  85520. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85521. private _updateBoundingInfo;
  85522. /** @hidden */
  85523. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85524. /**
  85525. * Gets total number of vertices
  85526. * @returns the total number of vertices
  85527. */
  85528. getTotalVertices(): number;
  85529. /**
  85530. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85531. * @param kind defines the data kind (Position, normal, etc...)
  85532. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85533. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85534. * @returns a float array containing vertex data
  85535. */
  85536. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85537. /**
  85538. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85539. * @param kind defines the data kind (Position, normal, etc...)
  85540. * @returns true if the vertex buffer with the specified kind is updatable
  85541. */
  85542. isVertexBufferUpdatable(kind: string): boolean;
  85543. /**
  85544. * Gets a specific vertex buffer
  85545. * @param kind defines the data kind (Position, normal, etc...)
  85546. * @returns a VertexBuffer
  85547. */
  85548. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85549. /**
  85550. * Returns all vertex buffers
  85551. * @return an object holding all vertex buffers indexed by kind
  85552. */
  85553. getVertexBuffers(): Nullable<{
  85554. [key: string]: VertexBuffer;
  85555. }>;
  85556. /**
  85557. * Gets a boolean indicating if specific vertex buffer is present
  85558. * @param kind defines the data kind (Position, normal, etc...)
  85559. * @returns true if data is present
  85560. */
  85561. isVerticesDataPresent(kind: string): boolean;
  85562. /**
  85563. * Gets a list of all attached data kinds (Position, normal, etc...)
  85564. * @returns a list of string containing all kinds
  85565. */
  85566. getVerticesDataKinds(): string[];
  85567. /**
  85568. * Update index buffer
  85569. * @param indices defines the indices to store in the index buffer
  85570. * @param offset defines the offset in the target buffer where to store the data
  85571. * @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)
  85572. */
  85573. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85574. /**
  85575. * Creates a new index buffer
  85576. * @param indices defines the indices to store in the index buffer
  85577. * @param totalVertices defines the total number of vertices (could be null)
  85578. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85579. */
  85580. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85581. /**
  85582. * Return the total number of indices
  85583. * @returns the total number of indices
  85584. */
  85585. getTotalIndices(): number;
  85586. /**
  85587. * Gets the index buffer array
  85588. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85589. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85590. * @returns the index buffer array
  85591. */
  85592. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85593. /**
  85594. * Gets the index buffer
  85595. * @return the index buffer
  85596. */
  85597. getIndexBuffer(): Nullable<DataBuffer>;
  85598. /** @hidden */
  85599. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85600. /**
  85601. * Release the associated resources for a specific mesh
  85602. * @param mesh defines the source mesh
  85603. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85604. */
  85605. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85606. /**
  85607. * Apply current geometry to a given mesh
  85608. * @param mesh defines the mesh to apply geometry to
  85609. */
  85610. applyToMesh(mesh: Mesh): void;
  85611. private _updateExtend;
  85612. private _applyToMesh;
  85613. private notifyUpdate;
  85614. /**
  85615. * Load the geometry if it was flagged as delay loaded
  85616. * @param scene defines the hosting scene
  85617. * @param onLoaded defines a callback called when the geometry is loaded
  85618. */
  85619. load(scene: Scene, onLoaded?: () => void): void;
  85620. private _queueLoad;
  85621. /**
  85622. * Invert the geometry to move from a right handed system to a left handed one.
  85623. */
  85624. toLeftHanded(): void;
  85625. /** @hidden */
  85626. _resetPointsArrayCache(): void;
  85627. /** @hidden */
  85628. _generatePointsArray(): boolean;
  85629. /**
  85630. * Gets a value indicating if the geometry is disposed
  85631. * @returns true if the geometry was disposed
  85632. */
  85633. isDisposed(): boolean;
  85634. private _disposeVertexArrayObjects;
  85635. /**
  85636. * Free all associated resources
  85637. */
  85638. dispose(): void;
  85639. /**
  85640. * Clone the current geometry into a new geometry
  85641. * @param id defines the unique ID of the new geometry
  85642. * @returns a new geometry object
  85643. */
  85644. copy(id: string): Geometry;
  85645. /**
  85646. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85647. * @return a JSON representation of the current geometry data (without the vertices data)
  85648. */
  85649. serialize(): any;
  85650. private toNumberArray;
  85651. /**
  85652. * Serialize all vertices data into a JSON oject
  85653. * @returns a JSON representation of the current geometry data
  85654. */
  85655. serializeVerticeData(): any;
  85656. /**
  85657. * Extracts a clone of a mesh geometry
  85658. * @param mesh defines the source mesh
  85659. * @param id defines the unique ID of the new geometry object
  85660. * @returns the new geometry object
  85661. */
  85662. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85663. /**
  85664. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85665. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85666. * Be aware Math.random() could cause collisions, but:
  85667. * "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"
  85668. * @returns a string containing a new GUID
  85669. */
  85670. static RandomId(): string;
  85671. /** @hidden */
  85672. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85673. private static _CleanMatricesWeights;
  85674. /**
  85675. * Create a new geometry from persisted data (Using .babylon file format)
  85676. * @param parsedVertexData defines the persisted data
  85677. * @param scene defines the hosting scene
  85678. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85679. * @returns the new geometry object
  85680. */
  85681. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85682. }
  85683. }
  85684. declare module BABYLON {
  85685. /**
  85686. * Define an interface for all classes that will get and set the data on vertices
  85687. */
  85688. export interface IGetSetVerticesData {
  85689. /**
  85690. * Gets a boolean indicating if specific vertex data is present
  85691. * @param kind defines the vertex data kind to use
  85692. * @returns true is data kind is present
  85693. */
  85694. isVerticesDataPresent(kind: string): boolean;
  85695. /**
  85696. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85697. * @param kind defines the data kind (Position, normal, etc...)
  85698. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85699. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85700. * @returns a float array containing vertex data
  85701. */
  85702. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85703. /**
  85704. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85705. * @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.
  85706. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85707. * @returns the indices array or an empty array if the mesh has no geometry
  85708. */
  85709. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85710. /**
  85711. * Set specific vertex data
  85712. * @param kind defines the data kind (Position, normal, etc...)
  85713. * @param data defines the vertex data to use
  85714. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85715. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85716. */
  85717. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85718. /**
  85719. * Update a specific associated vertex buffer
  85720. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85721. * - VertexBuffer.PositionKind
  85722. * - VertexBuffer.UVKind
  85723. * - VertexBuffer.UV2Kind
  85724. * - VertexBuffer.UV3Kind
  85725. * - VertexBuffer.UV4Kind
  85726. * - VertexBuffer.UV5Kind
  85727. * - VertexBuffer.UV6Kind
  85728. * - VertexBuffer.ColorKind
  85729. * - VertexBuffer.MatricesIndicesKind
  85730. * - VertexBuffer.MatricesIndicesExtraKind
  85731. * - VertexBuffer.MatricesWeightsKind
  85732. * - VertexBuffer.MatricesWeightsExtraKind
  85733. * @param data defines the data source
  85734. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85735. * @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)
  85736. */
  85737. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85738. /**
  85739. * Creates a new index buffer
  85740. * @param indices defines the indices to store in the index buffer
  85741. * @param totalVertices defines the total number of vertices (could be null)
  85742. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85743. */
  85744. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85745. }
  85746. /**
  85747. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85748. */
  85749. export class VertexData {
  85750. /**
  85751. * Mesh side orientation : usually the external or front surface
  85752. */
  85753. static readonly FRONTSIDE: number;
  85754. /**
  85755. * Mesh side orientation : usually the internal or back surface
  85756. */
  85757. static readonly BACKSIDE: number;
  85758. /**
  85759. * Mesh side orientation : both internal and external or front and back surfaces
  85760. */
  85761. static readonly DOUBLESIDE: number;
  85762. /**
  85763. * Mesh side orientation : by default, `FRONTSIDE`
  85764. */
  85765. static readonly DEFAULTSIDE: number;
  85766. /**
  85767. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85768. */
  85769. positions: Nullable<FloatArray>;
  85770. /**
  85771. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85772. */
  85773. normals: Nullable<FloatArray>;
  85774. /**
  85775. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85776. */
  85777. tangents: Nullable<FloatArray>;
  85778. /**
  85779. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85780. */
  85781. uvs: Nullable<FloatArray>;
  85782. /**
  85783. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85784. */
  85785. uvs2: Nullable<FloatArray>;
  85786. /**
  85787. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85788. */
  85789. uvs3: Nullable<FloatArray>;
  85790. /**
  85791. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85792. */
  85793. uvs4: Nullable<FloatArray>;
  85794. /**
  85795. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85796. */
  85797. uvs5: Nullable<FloatArray>;
  85798. /**
  85799. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85800. */
  85801. uvs6: Nullable<FloatArray>;
  85802. /**
  85803. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85804. */
  85805. colors: Nullable<FloatArray>;
  85806. /**
  85807. * 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).
  85808. */
  85809. matricesIndices: Nullable<FloatArray>;
  85810. /**
  85811. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85812. */
  85813. matricesWeights: Nullable<FloatArray>;
  85814. /**
  85815. * An array extending the number of possible indices
  85816. */
  85817. matricesIndicesExtra: Nullable<FloatArray>;
  85818. /**
  85819. * An array extending the number of possible weights when the number of indices is extended
  85820. */
  85821. matricesWeightsExtra: Nullable<FloatArray>;
  85822. /**
  85823. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85824. */
  85825. indices: Nullable<IndicesArray>;
  85826. /**
  85827. * Uses the passed data array to set the set the values for the specified kind of data
  85828. * @param data a linear array of floating numbers
  85829. * @param kind the type of data that is being set, eg positions, colors etc
  85830. */
  85831. set(data: FloatArray, kind: string): void;
  85832. /**
  85833. * Associates the vertexData to the passed Mesh.
  85834. * Sets it as updatable or not (default `false`)
  85835. * @param mesh the mesh the vertexData is applied to
  85836. * @param updatable when used and having the value true allows new data to update the vertexData
  85837. * @returns the VertexData
  85838. */
  85839. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85840. /**
  85841. * Associates the vertexData to the passed Geometry.
  85842. * Sets it as updatable or not (default `false`)
  85843. * @param geometry the geometry the vertexData is applied to
  85844. * @param updatable when used and having the value true allows new data to update the vertexData
  85845. * @returns VertexData
  85846. */
  85847. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85848. /**
  85849. * Updates the associated mesh
  85850. * @param mesh the mesh to be updated
  85851. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85852. * @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
  85853. * @returns VertexData
  85854. */
  85855. updateMesh(mesh: Mesh): VertexData;
  85856. /**
  85857. * Updates the associated geometry
  85858. * @param geometry the geometry to be updated
  85859. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85860. * @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
  85861. * @returns VertexData.
  85862. */
  85863. updateGeometry(geometry: Geometry): VertexData;
  85864. private _applyTo;
  85865. private _update;
  85866. /**
  85867. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85868. * @param matrix the transforming matrix
  85869. * @returns the VertexData
  85870. */
  85871. transform(matrix: Matrix): VertexData;
  85872. /**
  85873. * Merges the passed VertexData into the current one
  85874. * @param other the VertexData to be merged into the current one
  85875. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85876. * @returns the modified VertexData
  85877. */
  85878. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85879. private _mergeElement;
  85880. private _validate;
  85881. /**
  85882. * Serializes the VertexData
  85883. * @returns a serialized object
  85884. */
  85885. serialize(): any;
  85886. /**
  85887. * Extracts the vertexData from a mesh
  85888. * @param mesh the mesh from which to extract the VertexData
  85889. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85890. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85891. * @returns the object VertexData associated to the passed mesh
  85892. */
  85893. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85894. /**
  85895. * Extracts the vertexData from the geometry
  85896. * @param geometry the geometry from which to extract the VertexData
  85897. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85898. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85899. * @returns the object VertexData associated to the passed mesh
  85900. */
  85901. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85902. private static _ExtractFrom;
  85903. /**
  85904. * Creates the VertexData for a Ribbon
  85905. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85906. * * pathArray array of paths, each of which an array of successive Vector3
  85907. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85908. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85909. * * 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
  85910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85911. * * 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)
  85912. * * 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)
  85913. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85914. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85915. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85916. * @returns the VertexData of the ribbon
  85917. */
  85918. static CreateRibbon(options: {
  85919. pathArray: Vector3[][];
  85920. closeArray?: boolean;
  85921. closePath?: boolean;
  85922. offset?: number;
  85923. sideOrientation?: number;
  85924. frontUVs?: Vector4;
  85925. backUVs?: Vector4;
  85926. invertUV?: boolean;
  85927. uvs?: Vector2[];
  85928. colors?: Color4[];
  85929. }): VertexData;
  85930. /**
  85931. * Creates the VertexData for a box
  85932. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85933. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85934. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85935. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85936. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85937. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85938. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85940. * * 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)
  85941. * * 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)
  85942. * @returns the VertexData of the box
  85943. */
  85944. static CreateBox(options: {
  85945. size?: number;
  85946. width?: number;
  85947. height?: number;
  85948. depth?: number;
  85949. faceUV?: Vector4[];
  85950. faceColors?: Color4[];
  85951. sideOrientation?: number;
  85952. frontUVs?: Vector4;
  85953. backUVs?: Vector4;
  85954. }): VertexData;
  85955. /**
  85956. * Creates the VertexData for a tiled box
  85957. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85958. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85959. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85960. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85962. * @returns the VertexData of the box
  85963. */
  85964. static CreateTiledBox(options: {
  85965. pattern?: number;
  85966. width?: number;
  85967. height?: number;
  85968. depth?: number;
  85969. tileSize?: number;
  85970. tileWidth?: number;
  85971. tileHeight?: number;
  85972. alignHorizontal?: number;
  85973. alignVertical?: number;
  85974. faceUV?: Vector4[];
  85975. faceColors?: Color4[];
  85976. sideOrientation?: number;
  85977. }): VertexData;
  85978. /**
  85979. * Creates the VertexData for a tiled plane
  85980. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85981. * * pattern a limited pattern arrangement depending on the number
  85982. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85983. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85984. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85985. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85986. * * 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)
  85987. * * 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)
  85988. * @returns the VertexData of the tiled plane
  85989. */
  85990. static CreateTiledPlane(options: {
  85991. pattern?: number;
  85992. tileSize?: number;
  85993. tileWidth?: number;
  85994. tileHeight?: number;
  85995. size?: number;
  85996. width?: number;
  85997. height?: number;
  85998. alignHorizontal?: number;
  85999. alignVertical?: number;
  86000. sideOrientation?: number;
  86001. frontUVs?: Vector4;
  86002. backUVs?: Vector4;
  86003. }): VertexData;
  86004. /**
  86005. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86006. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86007. * * segments sets the number of horizontal strips optional, default 32
  86008. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86009. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86010. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86011. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86012. * * 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
  86013. * * 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
  86014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86015. * * 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)
  86016. * * 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)
  86017. * @returns the VertexData of the ellipsoid
  86018. */
  86019. static CreateSphere(options: {
  86020. segments?: number;
  86021. diameter?: number;
  86022. diameterX?: number;
  86023. diameterY?: number;
  86024. diameterZ?: number;
  86025. arc?: number;
  86026. slice?: number;
  86027. sideOrientation?: number;
  86028. frontUVs?: Vector4;
  86029. backUVs?: Vector4;
  86030. }): VertexData;
  86031. /**
  86032. * Creates the VertexData for a cylinder, cone or prism
  86033. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86034. * * height sets the height (y direction) of the cylinder, optional, default 2
  86035. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86036. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86037. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86038. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86039. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86040. * * 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
  86041. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86042. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86043. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86044. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86046. * * 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)
  86047. * * 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)
  86048. * @returns the VertexData of the cylinder, cone or prism
  86049. */
  86050. static CreateCylinder(options: {
  86051. height?: number;
  86052. diameterTop?: number;
  86053. diameterBottom?: number;
  86054. diameter?: number;
  86055. tessellation?: number;
  86056. subdivisions?: number;
  86057. arc?: number;
  86058. faceColors?: Color4[];
  86059. faceUV?: Vector4[];
  86060. hasRings?: boolean;
  86061. enclose?: boolean;
  86062. sideOrientation?: number;
  86063. frontUVs?: Vector4;
  86064. backUVs?: Vector4;
  86065. }): VertexData;
  86066. /**
  86067. * Creates the VertexData for a torus
  86068. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86069. * * diameter the diameter of the torus, optional default 1
  86070. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86071. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86072. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86073. * * 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)
  86074. * * 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)
  86075. * @returns the VertexData of the torus
  86076. */
  86077. static CreateTorus(options: {
  86078. diameter?: number;
  86079. thickness?: number;
  86080. tessellation?: number;
  86081. sideOrientation?: number;
  86082. frontUVs?: Vector4;
  86083. backUVs?: Vector4;
  86084. }): VertexData;
  86085. /**
  86086. * Creates the VertexData of the LineSystem
  86087. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86088. * - lines an array of lines, each line being an array of successive Vector3
  86089. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86090. * @returns the VertexData of the LineSystem
  86091. */
  86092. static CreateLineSystem(options: {
  86093. lines: Vector3[][];
  86094. colors?: Nullable<Color4[][]>;
  86095. }): VertexData;
  86096. /**
  86097. * Create the VertexData for a DashedLines
  86098. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86099. * - points an array successive Vector3
  86100. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86101. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86102. * - dashNb the intended total number of dashes, optional, default 200
  86103. * @returns the VertexData for the DashedLines
  86104. */
  86105. static CreateDashedLines(options: {
  86106. points: Vector3[];
  86107. dashSize?: number;
  86108. gapSize?: number;
  86109. dashNb?: number;
  86110. }): VertexData;
  86111. /**
  86112. * Creates the VertexData for a Ground
  86113. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86114. * - width the width (x direction) of the ground, optional, default 1
  86115. * - height the height (z direction) of the ground, optional, default 1
  86116. * - subdivisions the number of subdivisions per side, optional, default 1
  86117. * @returns the VertexData of the Ground
  86118. */
  86119. static CreateGround(options: {
  86120. width?: number;
  86121. height?: number;
  86122. subdivisions?: number;
  86123. subdivisionsX?: number;
  86124. subdivisionsY?: number;
  86125. }): VertexData;
  86126. /**
  86127. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86128. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86129. * * xmin the ground minimum X coordinate, optional, default -1
  86130. * * zmin the ground minimum Z coordinate, optional, default -1
  86131. * * xmax the ground maximum X coordinate, optional, default 1
  86132. * * zmax the ground maximum Z coordinate, optional, default 1
  86133. * * 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}
  86134. * * 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}
  86135. * @returns the VertexData of the TiledGround
  86136. */
  86137. static CreateTiledGround(options: {
  86138. xmin: number;
  86139. zmin: number;
  86140. xmax: number;
  86141. zmax: number;
  86142. subdivisions?: {
  86143. w: number;
  86144. h: number;
  86145. };
  86146. precision?: {
  86147. w: number;
  86148. h: number;
  86149. };
  86150. }): VertexData;
  86151. /**
  86152. * Creates the VertexData of the Ground designed from a heightmap
  86153. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86154. * * width the width (x direction) of the ground
  86155. * * height the height (z direction) of the ground
  86156. * * subdivisions the number of subdivisions per side
  86157. * * minHeight the minimum altitude on the ground, optional, default 0
  86158. * * maxHeight the maximum altitude on the ground, optional default 1
  86159. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86160. * * buffer the array holding the image color data
  86161. * * bufferWidth the width of image
  86162. * * bufferHeight the height of image
  86163. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86164. * @returns the VertexData of the Ground designed from a heightmap
  86165. */
  86166. static CreateGroundFromHeightMap(options: {
  86167. width: number;
  86168. height: number;
  86169. subdivisions: number;
  86170. minHeight: number;
  86171. maxHeight: number;
  86172. colorFilter: Color3;
  86173. buffer: Uint8Array;
  86174. bufferWidth: number;
  86175. bufferHeight: number;
  86176. alphaFilter: number;
  86177. }): VertexData;
  86178. /**
  86179. * Creates the VertexData for a Plane
  86180. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86181. * * size sets the width and height of the plane to the value of size, optional default 1
  86182. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86183. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86185. * * 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)
  86186. * * 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)
  86187. * @returns the VertexData of the box
  86188. */
  86189. static CreatePlane(options: {
  86190. size?: number;
  86191. width?: number;
  86192. height?: number;
  86193. sideOrientation?: number;
  86194. frontUVs?: Vector4;
  86195. backUVs?: Vector4;
  86196. }): VertexData;
  86197. /**
  86198. * Creates the VertexData of the Disc or regular Polygon
  86199. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86200. * * radius the radius of the disc, optional default 0.5
  86201. * * tessellation the number of polygon sides, optional, default 64
  86202. * * 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
  86203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86204. * * 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)
  86205. * * 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)
  86206. * @returns the VertexData of the box
  86207. */
  86208. static CreateDisc(options: {
  86209. radius?: number;
  86210. tessellation?: number;
  86211. arc?: number;
  86212. sideOrientation?: number;
  86213. frontUVs?: Vector4;
  86214. backUVs?: Vector4;
  86215. }): VertexData;
  86216. /**
  86217. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86218. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86219. * @param polygon a mesh built from polygonTriangulation.build()
  86220. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86221. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86222. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86223. * @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)
  86224. * @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)
  86225. * @returns the VertexData of the Polygon
  86226. */
  86227. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86228. /**
  86229. * Creates the VertexData of the IcoSphere
  86230. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86231. * * radius the radius of the IcoSphere, optional default 1
  86232. * * radiusX allows stretching in the x direction, optional, default radius
  86233. * * radiusY allows stretching in the y direction, optional, default radius
  86234. * * radiusZ allows stretching in the z direction, optional, default radius
  86235. * * flat when true creates a flat shaded mesh, optional, default true
  86236. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86238. * * 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)
  86239. * * 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)
  86240. * @returns the VertexData of the IcoSphere
  86241. */
  86242. static CreateIcoSphere(options: {
  86243. radius?: number;
  86244. radiusX?: number;
  86245. radiusY?: number;
  86246. radiusZ?: number;
  86247. flat?: boolean;
  86248. subdivisions?: number;
  86249. sideOrientation?: number;
  86250. frontUVs?: Vector4;
  86251. backUVs?: Vector4;
  86252. }): VertexData;
  86253. /**
  86254. * Creates the VertexData for a Polyhedron
  86255. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86256. * * type provided types are:
  86257. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86258. * * 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)
  86259. * * size the size of the IcoSphere, optional default 1
  86260. * * sizeX allows stretching in the x direction, optional, default size
  86261. * * sizeY allows stretching in the y direction, optional, default size
  86262. * * sizeZ allows stretching in the z direction, optional, default size
  86263. * * 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
  86264. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86265. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86266. * * flat when true creates a flat shaded mesh, optional, default true
  86267. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86269. * * 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)
  86270. * * 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)
  86271. * @returns the VertexData of the Polyhedron
  86272. */
  86273. static CreatePolyhedron(options: {
  86274. type?: number;
  86275. size?: number;
  86276. sizeX?: number;
  86277. sizeY?: number;
  86278. sizeZ?: number;
  86279. custom?: any;
  86280. faceUV?: Vector4[];
  86281. faceColors?: Color4[];
  86282. flat?: boolean;
  86283. sideOrientation?: number;
  86284. frontUVs?: Vector4;
  86285. backUVs?: Vector4;
  86286. }): VertexData;
  86287. /**
  86288. * Creates the VertexData for a TorusKnot
  86289. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86290. * * radius the radius of the torus knot, optional, default 2
  86291. * * tube the thickness of the tube, optional, default 0.5
  86292. * * radialSegments the number of sides on each tube segments, optional, default 32
  86293. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86294. * * p the number of windings around the z axis, optional, default 2
  86295. * * q the number of windings around the x axis, optional, default 3
  86296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86297. * * 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)
  86298. * * 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)
  86299. * @returns the VertexData of the Torus Knot
  86300. */
  86301. static CreateTorusKnot(options: {
  86302. radius?: number;
  86303. tube?: number;
  86304. radialSegments?: number;
  86305. tubularSegments?: number;
  86306. p?: number;
  86307. q?: number;
  86308. sideOrientation?: number;
  86309. frontUVs?: Vector4;
  86310. backUVs?: Vector4;
  86311. }): VertexData;
  86312. /**
  86313. * Compute normals for given positions and indices
  86314. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86315. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86316. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86317. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86318. * * facetNormals : optional array of facet normals (vector3)
  86319. * * facetPositions : optional array of facet positions (vector3)
  86320. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86321. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86322. * * bInfo : optional bounding info, required for facetPartitioning computation
  86323. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86324. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86325. * * useRightHandedSystem: optional boolean to for right handed system computation
  86326. * * depthSort : optional boolean to enable the facet depth sort computation
  86327. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86328. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86329. */
  86330. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86331. facetNormals?: any;
  86332. facetPositions?: any;
  86333. facetPartitioning?: any;
  86334. ratio?: number;
  86335. bInfo?: any;
  86336. bbSize?: Vector3;
  86337. subDiv?: any;
  86338. useRightHandedSystem?: boolean;
  86339. depthSort?: boolean;
  86340. distanceTo?: Vector3;
  86341. depthSortedFacets?: any;
  86342. }): void;
  86343. /** @hidden */
  86344. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86345. /**
  86346. * Applies VertexData created from the imported parameters to the geometry
  86347. * @param parsedVertexData the parsed data from an imported file
  86348. * @param geometry the geometry to apply the VertexData to
  86349. */
  86350. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86351. }
  86352. }
  86353. declare module BABYLON {
  86354. /**
  86355. * Class containing static functions to help procedurally build meshes
  86356. */
  86357. export class DiscBuilder {
  86358. /**
  86359. * Creates a plane polygonal mesh. By default, this is a disc
  86360. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86361. * * 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
  86362. * * 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
  86363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86366. * @param name defines the name of the mesh
  86367. * @param options defines the options used to create the mesh
  86368. * @param scene defines the hosting scene
  86369. * @returns the plane polygonal mesh
  86370. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86371. */
  86372. static CreateDisc(name: string, options: {
  86373. radius?: number;
  86374. tessellation?: number;
  86375. arc?: number;
  86376. updatable?: boolean;
  86377. sideOrientation?: number;
  86378. frontUVs?: Vector4;
  86379. backUVs?: Vector4;
  86380. }, scene?: Nullable<Scene>): Mesh;
  86381. }
  86382. }
  86383. declare module BABYLON {
  86384. /**
  86385. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86386. *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.
  86387. * The SPS is also a particle system. It provides some methods to manage the particles.
  86388. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86389. *
  86390. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86391. */
  86392. export class SolidParticleSystem implements IDisposable {
  86393. /**
  86394. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86395. * Example : var p = SPS.particles[i];
  86396. */
  86397. particles: SolidParticle[];
  86398. /**
  86399. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86400. */
  86401. nbParticles: number;
  86402. /**
  86403. * If the particles must ever face the camera (default false). Useful for planar particles.
  86404. */
  86405. billboard: boolean;
  86406. /**
  86407. * Recompute normals when adding a shape
  86408. */
  86409. recomputeNormals: boolean;
  86410. /**
  86411. * This a counter ofr your own usage. It's not set by any SPS functions.
  86412. */
  86413. counter: number;
  86414. /**
  86415. * The SPS name. This name is also given to the underlying mesh.
  86416. */
  86417. name: string;
  86418. /**
  86419. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86420. */
  86421. mesh: Mesh;
  86422. /**
  86423. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86424. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86425. */
  86426. vars: any;
  86427. /**
  86428. * This array is populated when the SPS is set as 'pickable'.
  86429. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86430. * Each element of this array is an object `{idx: int, faceId: int}`.
  86431. * `idx` is the picked particle index in the `SPS.particles` array
  86432. * `faceId` is the picked face index counted within this particle.
  86433. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86434. */
  86435. pickedParticles: {
  86436. idx: number;
  86437. faceId: number;
  86438. }[];
  86439. /**
  86440. * This array is populated when `enableDepthSort` is set to true.
  86441. * Each element of this array is an instance of the class DepthSortedParticle.
  86442. */
  86443. depthSortedParticles: DepthSortedParticle[];
  86444. /**
  86445. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86446. * @hidden
  86447. */
  86448. _bSphereOnly: boolean;
  86449. /**
  86450. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86451. * @hidden
  86452. */
  86453. _bSphereRadiusFactor: number;
  86454. private _scene;
  86455. private _positions;
  86456. private _indices;
  86457. private _normals;
  86458. private _colors;
  86459. private _uvs;
  86460. private _indices32;
  86461. private _positions32;
  86462. private _normals32;
  86463. private _fixedNormal32;
  86464. private _colors32;
  86465. private _uvs32;
  86466. private _index;
  86467. private _updatable;
  86468. private _pickable;
  86469. private _isVisibilityBoxLocked;
  86470. private _alwaysVisible;
  86471. private _depthSort;
  86472. private _shapeCounter;
  86473. private _copy;
  86474. private _color;
  86475. private _computeParticleColor;
  86476. private _computeParticleTexture;
  86477. private _computeParticleRotation;
  86478. private _computeParticleVertex;
  86479. private _computeBoundingBox;
  86480. private _depthSortParticles;
  86481. private _camera;
  86482. private _mustUnrotateFixedNormals;
  86483. private _particlesIntersect;
  86484. private _needs32Bits;
  86485. /**
  86486. * Creates a SPS (Solid Particle System) object.
  86487. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86488. * @param scene (Scene) is the scene in which the SPS is added.
  86489. * @param options defines the options of the sps e.g.
  86490. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86491. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86492. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86493. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86494. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86495. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86496. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86497. */
  86498. constructor(name: string, scene: Scene, options?: {
  86499. updatable?: boolean;
  86500. isPickable?: boolean;
  86501. enableDepthSort?: boolean;
  86502. particleIntersection?: boolean;
  86503. boundingSphereOnly?: boolean;
  86504. bSphereRadiusFactor?: number;
  86505. });
  86506. /**
  86507. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86508. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86509. * @returns the created mesh
  86510. */
  86511. buildMesh(): Mesh;
  86512. /**
  86513. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86514. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86515. * Thus the particles generated from `digest()` have their property `position` set yet.
  86516. * @param mesh ( Mesh ) is the mesh to be digested
  86517. * @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
  86518. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86519. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86520. * @returns the current SPS
  86521. */
  86522. digest(mesh: Mesh, options?: {
  86523. facetNb?: number;
  86524. number?: number;
  86525. delta?: number;
  86526. }): SolidParticleSystem;
  86527. private _unrotateFixedNormals;
  86528. private _resetCopy;
  86529. private _meshBuilder;
  86530. private _posToShape;
  86531. private _uvsToShapeUV;
  86532. private _addParticle;
  86533. /**
  86534. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86535. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86536. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86537. * @param nb (positive integer) the number of particles to be created from this model
  86538. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86539. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86540. * @returns the number of shapes in the system
  86541. */
  86542. addShape(mesh: Mesh, nb: number, options?: {
  86543. positionFunction?: any;
  86544. vertexFunction?: any;
  86545. }): number;
  86546. private _rebuildParticle;
  86547. /**
  86548. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86549. * @returns the SPS.
  86550. */
  86551. rebuildMesh(): SolidParticleSystem;
  86552. /**
  86553. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86554. * This method calls `updateParticle()` for each particle of the SPS.
  86555. * For an animated SPS, it is usually called within the render loop.
  86556. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86557. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86558. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86559. * @returns the SPS.
  86560. */
  86561. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86562. /**
  86563. * Disposes the SPS.
  86564. */
  86565. dispose(): void;
  86566. /**
  86567. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86568. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86569. * @returns the SPS.
  86570. */
  86571. refreshVisibleSize(): SolidParticleSystem;
  86572. /**
  86573. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86574. * @param size the size (float) of the visibility box
  86575. * note : this doesn't lock the SPS mesh bounding box.
  86576. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86577. */
  86578. setVisibilityBox(size: number): void;
  86579. /**
  86580. * Gets whether the SPS as always visible or not
  86581. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86582. */
  86583. /**
  86584. * Sets the SPS as always visible or not
  86585. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86586. */
  86587. isAlwaysVisible: boolean;
  86588. /**
  86589. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86590. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86591. */
  86592. /**
  86593. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86594. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86595. */
  86596. isVisibilityBoxLocked: boolean;
  86597. /**
  86598. * Tells to `setParticles()` to compute the particle rotations or not.
  86599. * Default value : true. The SPS is faster when it's set to false.
  86600. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86601. */
  86602. /**
  86603. * Gets if `setParticles()` computes the particle rotations or not.
  86604. * Default value : true. The SPS is faster when it's set to false.
  86605. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86606. */
  86607. computeParticleRotation: boolean;
  86608. /**
  86609. * Tells to `setParticles()` to compute the particle colors or not.
  86610. * Default value : true. The SPS is faster when it's set to false.
  86611. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86612. */
  86613. /**
  86614. * Gets if `setParticles()` computes the particle colors or not.
  86615. * Default value : true. The SPS is faster when it's set to false.
  86616. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86617. */
  86618. computeParticleColor: boolean;
  86619. /**
  86620. * Gets if `setParticles()` computes the particle textures or not.
  86621. * Default value : true. The SPS is faster when it's set to false.
  86622. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86623. */
  86624. computeParticleTexture: boolean;
  86625. /**
  86626. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86627. * Default value : false. The SPS is faster when it's set to false.
  86628. * Note : the particle custom vertex positions aren't stored values.
  86629. */
  86630. /**
  86631. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86632. * Default value : false. The SPS is faster when it's set to false.
  86633. * Note : the particle custom vertex positions aren't stored values.
  86634. */
  86635. computeParticleVertex: boolean;
  86636. /**
  86637. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86638. */
  86639. /**
  86640. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86641. */
  86642. computeBoundingBox: boolean;
  86643. /**
  86644. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86645. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86646. * Default : `true`
  86647. */
  86648. /**
  86649. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86650. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86651. * Default : `true`
  86652. */
  86653. depthSortParticles: boolean;
  86654. /**
  86655. * This function does nothing. It may be overwritten to set all the particle first values.
  86656. * The SPS doesn't call this function, you may have to call it by your own.
  86657. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86658. */
  86659. initParticles(): void;
  86660. /**
  86661. * This function does nothing. It may be overwritten to recycle a particle.
  86662. * The SPS doesn't call this function, you may have to call it by your own.
  86663. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86664. * @param particle The particle to recycle
  86665. * @returns the recycled particle
  86666. */
  86667. recycleParticle(particle: SolidParticle): SolidParticle;
  86668. /**
  86669. * Updates a particle : this function should be overwritten by the user.
  86670. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86671. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86672. * @example : just set a particle position or velocity and recycle conditions
  86673. * @param particle The particle to update
  86674. * @returns the updated particle
  86675. */
  86676. updateParticle(particle: SolidParticle): SolidParticle;
  86677. /**
  86678. * Updates a vertex of a particle : it can be overwritten by the user.
  86679. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86680. * @param particle the current particle
  86681. * @param vertex the current index of the current particle
  86682. * @param pt the index of the current vertex in the particle shape
  86683. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86684. * @example : just set a vertex particle position
  86685. * @returns the updated vertex
  86686. */
  86687. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86688. /**
  86689. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86690. * This does nothing and may be overwritten by the user.
  86691. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86692. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86693. * @param update the boolean update value actually passed to setParticles()
  86694. */
  86695. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86696. /**
  86697. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86698. * This will be passed three parameters.
  86699. * This does nothing and may be overwritten by the user.
  86700. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86701. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86702. * @param update the boolean update value actually passed to setParticles()
  86703. */
  86704. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86705. }
  86706. }
  86707. declare module BABYLON {
  86708. /**
  86709. * Represents one particle of a solid particle system.
  86710. */
  86711. export class SolidParticle {
  86712. /**
  86713. * particle global index
  86714. */
  86715. idx: number;
  86716. /**
  86717. * The color of the particle
  86718. */
  86719. color: Nullable<Color4>;
  86720. /**
  86721. * The world space position of the particle.
  86722. */
  86723. position: Vector3;
  86724. /**
  86725. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86726. */
  86727. rotation: Vector3;
  86728. /**
  86729. * The world space rotation quaternion of the particle.
  86730. */
  86731. rotationQuaternion: Nullable<Quaternion>;
  86732. /**
  86733. * The scaling of the particle.
  86734. */
  86735. scaling: Vector3;
  86736. /**
  86737. * The uvs of the particle.
  86738. */
  86739. uvs: Vector4;
  86740. /**
  86741. * The current speed of the particle.
  86742. */
  86743. velocity: Vector3;
  86744. /**
  86745. * The pivot point in the particle local space.
  86746. */
  86747. pivot: Vector3;
  86748. /**
  86749. * Must the particle be translated from its pivot point in its local space ?
  86750. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86751. * Default : false
  86752. */
  86753. translateFromPivot: boolean;
  86754. /**
  86755. * Is the particle active or not ?
  86756. */
  86757. alive: boolean;
  86758. /**
  86759. * Is the particle visible or not ?
  86760. */
  86761. isVisible: boolean;
  86762. /**
  86763. * Index of this particle in the global "positions" array (Internal use)
  86764. * @hidden
  86765. */
  86766. _pos: number;
  86767. /**
  86768. * @hidden Index of this particle in the global "indices" array (Internal use)
  86769. */
  86770. _ind: number;
  86771. /**
  86772. * @hidden ModelShape of this particle (Internal use)
  86773. */
  86774. _model: ModelShape;
  86775. /**
  86776. * ModelShape id of this particle
  86777. */
  86778. shapeId: number;
  86779. /**
  86780. * Index of the particle in its shape id (Internal use)
  86781. */
  86782. idxInShape: number;
  86783. /**
  86784. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86785. */
  86786. _modelBoundingInfo: BoundingInfo;
  86787. /**
  86788. * @hidden Particle BoundingInfo object (Internal use)
  86789. */
  86790. _boundingInfo: BoundingInfo;
  86791. /**
  86792. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86793. */
  86794. _sps: SolidParticleSystem;
  86795. /**
  86796. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86797. */
  86798. _stillInvisible: boolean;
  86799. /**
  86800. * @hidden Last computed particle rotation matrix
  86801. */
  86802. _rotationMatrix: number[];
  86803. /**
  86804. * Parent particle Id, if any.
  86805. * Default null.
  86806. */
  86807. parentId: Nullable<number>;
  86808. /**
  86809. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86810. * The possible values are :
  86811. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86812. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86813. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86814. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86815. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86816. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86817. * */
  86818. cullingStrategy: number;
  86819. /**
  86820. * @hidden Internal global position in the SPS.
  86821. */
  86822. _globalPosition: Vector3;
  86823. /**
  86824. * Creates a Solid Particle object.
  86825. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86826. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86827. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86828. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86829. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86830. * @param shapeId (integer) is the model shape identifier in the SPS.
  86831. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86832. * @param sps defines the sps it is associated to
  86833. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86834. */
  86835. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86836. /**
  86837. * Legacy support, changed scale to scaling
  86838. */
  86839. /**
  86840. * Legacy support, changed scale to scaling
  86841. */
  86842. scale: Vector3;
  86843. /**
  86844. * Legacy support, changed quaternion to rotationQuaternion
  86845. */
  86846. /**
  86847. * Legacy support, changed quaternion to rotationQuaternion
  86848. */
  86849. quaternion: Nullable<Quaternion>;
  86850. /**
  86851. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86852. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86853. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86854. * @returns true if it intersects
  86855. */
  86856. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86857. /**
  86858. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86859. * A particle is in the frustum if its bounding box intersects the frustum
  86860. * @param frustumPlanes defines the frustum to test
  86861. * @returns true if the particle is in the frustum planes
  86862. */
  86863. isInFrustum(frustumPlanes: Plane[]): boolean;
  86864. /**
  86865. * get the rotation matrix of the particle
  86866. * @hidden
  86867. */
  86868. getRotationMatrix(m: Matrix): void;
  86869. }
  86870. /**
  86871. * Represents the shape of the model used by one particle of a solid particle system.
  86872. * SPS internal tool, don't use it manually.
  86873. */
  86874. export class ModelShape {
  86875. /**
  86876. * The shape id
  86877. * @hidden
  86878. */
  86879. shapeID: number;
  86880. /**
  86881. * flat array of model positions (internal use)
  86882. * @hidden
  86883. */
  86884. _shape: Vector3[];
  86885. /**
  86886. * flat array of model UVs (internal use)
  86887. * @hidden
  86888. */
  86889. _shapeUV: number[];
  86890. /**
  86891. * length of the shape in the model indices array (internal use)
  86892. * @hidden
  86893. */
  86894. _indicesLength: number;
  86895. /**
  86896. * Custom position function (internal use)
  86897. * @hidden
  86898. */
  86899. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86900. /**
  86901. * Custom vertex function (internal use)
  86902. * @hidden
  86903. */
  86904. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86905. /**
  86906. * 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.
  86907. * SPS internal tool, don't use it manually.
  86908. * @hidden
  86909. */
  86910. 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>);
  86911. }
  86912. /**
  86913. * Represents a Depth Sorted Particle in the solid particle system.
  86914. */
  86915. export class DepthSortedParticle {
  86916. /**
  86917. * Index of the particle in the "indices" array
  86918. */
  86919. ind: number;
  86920. /**
  86921. * Length of the particle shape in the "indices" array
  86922. */
  86923. indicesLength: number;
  86924. /**
  86925. * Squared distance from the particle to the camera
  86926. */
  86927. sqDistance: number;
  86928. }
  86929. }
  86930. declare module BABYLON {
  86931. /**
  86932. * @hidden
  86933. */
  86934. export class _MeshCollisionData {
  86935. _checkCollisions: boolean;
  86936. _collisionMask: number;
  86937. _collisionGroup: number;
  86938. _collider: Nullable<Collider>;
  86939. _oldPositionForCollisions: Vector3;
  86940. _diffPositionForCollisions: Vector3;
  86941. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  86942. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  86943. }
  86944. }
  86945. declare module BABYLON {
  86946. /** @hidden */
  86947. class _FacetDataStorage {
  86948. facetPositions: Vector3[];
  86949. facetNormals: Vector3[];
  86950. facetPartitioning: number[][];
  86951. facetNb: number;
  86952. partitioningSubdivisions: number;
  86953. partitioningBBoxRatio: number;
  86954. facetDataEnabled: boolean;
  86955. facetParameters: any;
  86956. bbSize: Vector3;
  86957. subDiv: {
  86958. max: number;
  86959. X: number;
  86960. Y: number;
  86961. Z: number;
  86962. };
  86963. facetDepthSort: boolean;
  86964. facetDepthSortEnabled: boolean;
  86965. depthSortedIndices: IndicesArray;
  86966. depthSortedFacets: {
  86967. ind: number;
  86968. sqDistance: number;
  86969. }[];
  86970. facetDepthSortFunction: (f1: {
  86971. ind: number;
  86972. sqDistance: number;
  86973. }, f2: {
  86974. ind: number;
  86975. sqDistance: number;
  86976. }) => number;
  86977. facetDepthSortFrom: Vector3;
  86978. facetDepthSortOrigin: Vector3;
  86979. invertedMatrix: Matrix;
  86980. }
  86981. /**
  86982. * @hidden
  86983. **/
  86984. class _InternalAbstractMeshDataInfo {
  86985. _hasVertexAlpha: boolean;
  86986. _useVertexColors: boolean;
  86987. _numBoneInfluencers: number;
  86988. _applyFog: boolean;
  86989. _receiveShadows: boolean;
  86990. _facetData: _FacetDataStorage;
  86991. _visibility: number;
  86992. _skeleton: Nullable<Skeleton>;
  86993. _layerMask: number;
  86994. _computeBonesUsingShaders: boolean;
  86995. _isActive: boolean;
  86996. _onlyForInstances: boolean;
  86997. _isActiveIntermediate: boolean;
  86998. _onlyForInstancesIntermediate: boolean;
  86999. }
  87000. /**
  87001. * Class used to store all common mesh properties
  87002. */
  87003. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87004. /** No occlusion */
  87005. static OCCLUSION_TYPE_NONE: number;
  87006. /** Occlusion set to optimisitic */
  87007. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87008. /** Occlusion set to strict */
  87009. static OCCLUSION_TYPE_STRICT: number;
  87010. /** Use an accurante occlusion algorithm */
  87011. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87012. /** Use a conservative occlusion algorithm */
  87013. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87014. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87015. * Test order :
  87016. * Is the bounding sphere outside the frustum ?
  87017. * If not, are the bounding box vertices outside the frustum ?
  87018. * It not, then the cullable object is in the frustum.
  87019. */
  87020. static readonly CULLINGSTRATEGY_STANDARD: number;
  87021. /** Culling strategy : Bounding Sphere Only.
  87022. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87023. * It's also less accurate than the standard because some not visible objects can still be selected.
  87024. * Test : is the bounding sphere outside the frustum ?
  87025. * If not, then the cullable object is in the frustum.
  87026. */
  87027. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87028. /** Culling strategy : Optimistic Inclusion.
  87029. * This in an inclusion test first, then the standard exclusion test.
  87030. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87031. * 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.
  87032. * Anyway, it's as accurate as the standard strategy.
  87033. * Test :
  87034. * Is the cullable object bounding sphere center in the frustum ?
  87035. * If not, apply the default culling strategy.
  87036. */
  87037. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87038. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87039. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87040. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87041. * 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.
  87042. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87043. * Test :
  87044. * Is the cullable object bounding sphere center in the frustum ?
  87045. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87046. */
  87047. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87048. /**
  87049. * No billboard
  87050. */
  87051. static readonly BILLBOARDMODE_NONE: number;
  87052. /** Billboard on X axis */
  87053. static readonly BILLBOARDMODE_X: number;
  87054. /** Billboard on Y axis */
  87055. static readonly BILLBOARDMODE_Y: number;
  87056. /** Billboard on Z axis */
  87057. static readonly BILLBOARDMODE_Z: number;
  87058. /** Billboard on all axes */
  87059. static readonly BILLBOARDMODE_ALL: number;
  87060. /** @hidden */
  87061. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87062. /**
  87063. * The culling strategy to use to check whether the mesh must be rendered or not.
  87064. * This value can be changed at any time and will be used on the next render mesh selection.
  87065. * The possible values are :
  87066. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87067. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87068. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87069. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87070. * Please read each static variable documentation to get details about the culling process.
  87071. * */
  87072. cullingStrategy: number;
  87073. /**
  87074. * Gets the number of facets in the mesh
  87075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87076. */
  87077. readonly facetNb: number;
  87078. /**
  87079. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87081. */
  87082. partitioningSubdivisions: number;
  87083. /**
  87084. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87085. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87087. */
  87088. partitioningBBoxRatio: number;
  87089. /**
  87090. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87091. * Works only for updatable meshes.
  87092. * Doesn't work with multi-materials
  87093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87094. */
  87095. mustDepthSortFacets: boolean;
  87096. /**
  87097. * The location (Vector3) where the facet depth sort must be computed from.
  87098. * By default, the active camera position.
  87099. * Used only when facet depth sort is enabled
  87100. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87101. */
  87102. facetDepthSortFrom: Vector3;
  87103. /**
  87104. * gets a boolean indicating if facetData is enabled
  87105. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87106. */
  87107. readonly isFacetDataEnabled: boolean;
  87108. /** @hidden */
  87109. _updateNonUniformScalingState(value: boolean): boolean;
  87110. /**
  87111. * An event triggered when this mesh collides with another one
  87112. */
  87113. onCollideObservable: Observable<AbstractMesh>;
  87114. /** Set a function to call when this mesh collides with another one */
  87115. onCollide: () => void;
  87116. /**
  87117. * An event triggered when the collision's position changes
  87118. */
  87119. onCollisionPositionChangeObservable: Observable<Vector3>;
  87120. /** Set a function to call when the collision's position changes */
  87121. onCollisionPositionChange: () => void;
  87122. /**
  87123. * An event triggered when material is changed
  87124. */
  87125. onMaterialChangedObservable: Observable<AbstractMesh>;
  87126. /**
  87127. * Gets or sets the orientation for POV movement & rotation
  87128. */
  87129. definedFacingForward: boolean;
  87130. /** @hidden */
  87131. _occlusionQuery: Nullable<WebGLQuery>;
  87132. /** @hidden */
  87133. _renderingGroup: Nullable<RenderingGroup>;
  87134. /**
  87135. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87136. */
  87137. /**
  87138. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87139. */
  87140. visibility: number;
  87141. /** Gets or sets the alpha index used to sort transparent meshes
  87142. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87143. */
  87144. alphaIndex: number;
  87145. /**
  87146. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87147. */
  87148. isVisible: boolean;
  87149. /**
  87150. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87151. */
  87152. isPickable: boolean;
  87153. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87154. showSubMeshesBoundingBox: boolean;
  87155. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87156. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87157. */
  87158. isBlocker: boolean;
  87159. /**
  87160. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87161. */
  87162. enablePointerMoveEvents: boolean;
  87163. /**
  87164. * Specifies the rendering group id for this mesh (0 by default)
  87165. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87166. */
  87167. renderingGroupId: number;
  87168. private _material;
  87169. /** Gets or sets current material */
  87170. material: Nullable<Material>;
  87171. /**
  87172. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87173. * @see http://doc.babylonjs.com/babylon101/shadows
  87174. */
  87175. receiveShadows: boolean;
  87176. /** Defines color to use when rendering outline */
  87177. outlineColor: Color3;
  87178. /** Define width to use when rendering outline */
  87179. outlineWidth: number;
  87180. /** Defines color to use when rendering overlay */
  87181. overlayColor: Color3;
  87182. /** Defines alpha to use when rendering overlay */
  87183. overlayAlpha: number;
  87184. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87185. hasVertexAlpha: boolean;
  87186. /** 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) */
  87187. useVertexColors: boolean;
  87188. /**
  87189. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87190. */
  87191. computeBonesUsingShaders: boolean;
  87192. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87193. numBoneInfluencers: number;
  87194. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87195. applyFog: boolean;
  87196. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87197. useOctreeForRenderingSelection: boolean;
  87198. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87199. useOctreeForPicking: boolean;
  87200. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87201. useOctreeForCollisions: boolean;
  87202. /**
  87203. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87204. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87205. */
  87206. layerMask: number;
  87207. /**
  87208. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87209. */
  87210. alwaysSelectAsActiveMesh: boolean;
  87211. /**
  87212. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87213. */
  87214. doNotSyncBoundingInfo: boolean;
  87215. /**
  87216. * Gets or sets the current action manager
  87217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87218. */
  87219. actionManager: Nullable<AbstractActionManager>;
  87220. private _meshCollisionData;
  87221. /**
  87222. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87224. */
  87225. ellipsoid: Vector3;
  87226. /**
  87227. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87228. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87229. */
  87230. ellipsoidOffset: Vector3;
  87231. /**
  87232. * Gets or sets a collision mask used to mask collisions (default is -1).
  87233. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87234. */
  87235. collisionMask: number;
  87236. /**
  87237. * Gets or sets the current collision group mask (-1 by default).
  87238. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87239. */
  87240. collisionGroup: number;
  87241. /**
  87242. * Defines edge width used when edgesRenderer is enabled
  87243. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87244. */
  87245. edgesWidth: number;
  87246. /**
  87247. * Defines edge color used when edgesRenderer is enabled
  87248. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87249. */
  87250. edgesColor: Color4;
  87251. /** @hidden */
  87252. _edgesRenderer: Nullable<IEdgesRenderer>;
  87253. /** @hidden */
  87254. _masterMesh: Nullable<AbstractMesh>;
  87255. /** @hidden */
  87256. _boundingInfo: Nullable<BoundingInfo>;
  87257. /** @hidden */
  87258. _renderId: number;
  87259. /**
  87260. * Gets or sets the list of subMeshes
  87261. * @see http://doc.babylonjs.com/how_to/multi_materials
  87262. */
  87263. subMeshes: SubMesh[];
  87264. /** @hidden */
  87265. _intersectionsInProgress: AbstractMesh[];
  87266. /** @hidden */
  87267. _unIndexed: boolean;
  87268. /** @hidden */
  87269. _lightSources: Light[];
  87270. /** Gets the list of lights affecting that mesh */
  87271. readonly lightSources: Light[];
  87272. /** @hidden */
  87273. readonly _positions: Nullable<Vector3[]>;
  87274. /** @hidden */
  87275. _waitingData: {
  87276. lods: Nullable<any>;
  87277. actions: Nullable<any>;
  87278. freezeWorldMatrix: Nullable<boolean>;
  87279. };
  87280. /** @hidden */
  87281. _bonesTransformMatrices: Nullable<Float32Array>;
  87282. /**
  87283. * Gets or sets a skeleton to apply skining transformations
  87284. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87285. */
  87286. skeleton: Nullable<Skeleton>;
  87287. /**
  87288. * An event triggered when the mesh is rebuilt.
  87289. */
  87290. onRebuildObservable: Observable<AbstractMesh>;
  87291. /**
  87292. * Creates a new AbstractMesh
  87293. * @param name defines the name of the mesh
  87294. * @param scene defines the hosting scene
  87295. */
  87296. constructor(name: string, scene?: Nullable<Scene>);
  87297. /**
  87298. * Returns the string "AbstractMesh"
  87299. * @returns "AbstractMesh"
  87300. */
  87301. getClassName(): string;
  87302. /**
  87303. * Gets a string representation of the current mesh
  87304. * @param fullDetails defines a boolean indicating if full details must be included
  87305. * @returns a string representation of the current mesh
  87306. */
  87307. toString(fullDetails?: boolean): string;
  87308. /**
  87309. * @hidden
  87310. */
  87311. protected _getEffectiveParent(): Nullable<Node>;
  87312. /** @hidden */
  87313. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87314. /** @hidden */
  87315. _rebuild(): void;
  87316. /** @hidden */
  87317. _resyncLightSources(): void;
  87318. /** @hidden */
  87319. _resyncLighSource(light: Light): void;
  87320. /** @hidden */
  87321. _unBindEffect(): void;
  87322. /** @hidden */
  87323. _removeLightSource(light: Light): void;
  87324. private _markSubMeshesAsDirty;
  87325. /** @hidden */
  87326. _markSubMeshesAsLightDirty(): void;
  87327. /** @hidden */
  87328. _markSubMeshesAsAttributesDirty(): void;
  87329. /** @hidden */
  87330. _markSubMeshesAsMiscDirty(): void;
  87331. /**
  87332. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87333. */
  87334. scaling: Vector3;
  87335. /**
  87336. * Returns true if the mesh is blocked. Implemented by child classes
  87337. */
  87338. readonly isBlocked: boolean;
  87339. /**
  87340. * Returns the mesh itself by default. Implemented by child classes
  87341. * @param camera defines the camera to use to pick the right LOD level
  87342. * @returns the currentAbstractMesh
  87343. */
  87344. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87345. /**
  87346. * Returns 0 by default. Implemented by child classes
  87347. * @returns an integer
  87348. */
  87349. getTotalVertices(): number;
  87350. /**
  87351. * Returns a positive integer : the total number of indices in this mesh geometry.
  87352. * @returns the numner of indices or zero if the mesh has no geometry.
  87353. */
  87354. getTotalIndices(): number;
  87355. /**
  87356. * Returns null by default. Implemented by child classes
  87357. * @returns null
  87358. */
  87359. getIndices(): Nullable<IndicesArray>;
  87360. /**
  87361. * Returns the array of the requested vertex data kind. Implemented by child classes
  87362. * @param kind defines the vertex data kind to use
  87363. * @returns null
  87364. */
  87365. getVerticesData(kind: string): Nullable<FloatArray>;
  87366. /**
  87367. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87368. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87369. * Note that a new underlying VertexBuffer object is created each call.
  87370. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87371. * @param kind defines vertex data kind:
  87372. * * VertexBuffer.PositionKind
  87373. * * VertexBuffer.UVKind
  87374. * * VertexBuffer.UV2Kind
  87375. * * VertexBuffer.UV3Kind
  87376. * * VertexBuffer.UV4Kind
  87377. * * VertexBuffer.UV5Kind
  87378. * * VertexBuffer.UV6Kind
  87379. * * VertexBuffer.ColorKind
  87380. * * VertexBuffer.MatricesIndicesKind
  87381. * * VertexBuffer.MatricesIndicesExtraKind
  87382. * * VertexBuffer.MatricesWeightsKind
  87383. * * VertexBuffer.MatricesWeightsExtraKind
  87384. * @param data defines the data source
  87385. * @param updatable defines if the data must be flagged as updatable (or static)
  87386. * @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
  87387. * @returns the current mesh
  87388. */
  87389. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87390. /**
  87391. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87392. * If the mesh has no geometry, it is simply returned as it is.
  87393. * @param kind defines vertex data kind:
  87394. * * VertexBuffer.PositionKind
  87395. * * VertexBuffer.UVKind
  87396. * * VertexBuffer.UV2Kind
  87397. * * VertexBuffer.UV3Kind
  87398. * * VertexBuffer.UV4Kind
  87399. * * VertexBuffer.UV5Kind
  87400. * * VertexBuffer.UV6Kind
  87401. * * VertexBuffer.ColorKind
  87402. * * VertexBuffer.MatricesIndicesKind
  87403. * * VertexBuffer.MatricesIndicesExtraKind
  87404. * * VertexBuffer.MatricesWeightsKind
  87405. * * VertexBuffer.MatricesWeightsExtraKind
  87406. * @param data defines the data source
  87407. * @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
  87408. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87409. * @returns the current mesh
  87410. */
  87411. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87412. /**
  87413. * Sets the mesh indices,
  87414. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87415. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87416. * @param totalVertices Defines the total number of vertices
  87417. * @returns the current mesh
  87418. */
  87419. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87420. /**
  87421. * Gets a boolean indicating if specific vertex data is present
  87422. * @param kind defines the vertex data kind to use
  87423. * @returns true is data kind is present
  87424. */
  87425. isVerticesDataPresent(kind: string): boolean;
  87426. /**
  87427. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  87428. * @returns a BoundingInfo
  87429. */
  87430. getBoundingInfo(): BoundingInfo;
  87431. /**
  87432. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87433. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87434. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87435. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87436. * @returns the current mesh
  87437. */
  87438. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87439. /**
  87440. * Overwrite the current bounding info
  87441. * @param boundingInfo defines the new bounding info
  87442. * @returns the current mesh
  87443. */
  87444. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87445. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87446. readonly useBones: boolean;
  87447. /** @hidden */
  87448. _preActivate(): void;
  87449. /** @hidden */
  87450. _preActivateForIntermediateRendering(renderId: number): void;
  87451. /** @hidden */
  87452. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87453. /** @hidden */
  87454. _postActivate(): void;
  87455. /** @hidden */
  87456. _freeze(): void;
  87457. /** @hidden */
  87458. _unFreeze(): void;
  87459. /**
  87460. * Gets the current world matrix
  87461. * @returns a Matrix
  87462. */
  87463. getWorldMatrix(): Matrix;
  87464. /** @hidden */
  87465. _getWorldMatrixDeterminant(): number;
  87466. /**
  87467. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87468. */
  87469. readonly isAnInstance: boolean;
  87470. /**
  87471. * Perform relative position change from the point of view of behind the front of the mesh.
  87472. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87473. * Supports definition of mesh facing forward or backward
  87474. * @param amountRight defines the distance on the right axis
  87475. * @param amountUp defines the distance on the up axis
  87476. * @param amountForward defines the distance on the forward axis
  87477. * @returns the current mesh
  87478. */
  87479. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87480. /**
  87481. * Calculate relative position change from the point of view of behind the front of the mesh.
  87482. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87483. * Supports definition of mesh facing forward or backward
  87484. * @param amountRight defines the distance on the right axis
  87485. * @param amountUp defines the distance on the up axis
  87486. * @param amountForward defines the distance on the forward axis
  87487. * @returns the new displacement vector
  87488. */
  87489. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87490. /**
  87491. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87492. * Supports definition of mesh facing forward or backward
  87493. * @param flipBack defines the flip
  87494. * @param twirlClockwise defines the twirl
  87495. * @param tiltRight defines the tilt
  87496. * @returns the current mesh
  87497. */
  87498. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87499. /**
  87500. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87501. * Supports definition of mesh facing forward or backward.
  87502. * @param flipBack defines the flip
  87503. * @param twirlClockwise defines the twirl
  87504. * @param tiltRight defines the tilt
  87505. * @returns the new rotation vector
  87506. */
  87507. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87508. /**
  87509. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87510. * This means the mesh underlying bounding box and sphere are recomputed.
  87511. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87512. * @returns the current mesh
  87513. */
  87514. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87515. /** @hidden */
  87516. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87517. /** @hidden */
  87518. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87519. /** @hidden */
  87520. _updateBoundingInfo(): AbstractMesh;
  87521. /** @hidden */
  87522. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87523. /** @hidden */
  87524. protected _afterComputeWorldMatrix(): void;
  87525. /** @hidden */
  87526. readonly _effectiveMesh: AbstractMesh;
  87527. /**
  87528. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87529. * A mesh is in the frustum if its bounding box intersects the frustum
  87530. * @param frustumPlanes defines the frustum to test
  87531. * @returns true if the mesh is in the frustum planes
  87532. */
  87533. isInFrustum(frustumPlanes: Plane[]): boolean;
  87534. /**
  87535. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87536. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87537. * @param frustumPlanes defines the frustum to test
  87538. * @returns true if the mesh is completely in the frustum planes
  87539. */
  87540. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87541. /**
  87542. * True if the mesh intersects another mesh or a SolidParticle object
  87543. * @param mesh defines a target mesh or SolidParticle to test
  87544. * @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)
  87545. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87546. * @returns true if there is an intersection
  87547. */
  87548. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87549. /**
  87550. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87551. * @param point defines the point to test
  87552. * @returns true if there is an intersection
  87553. */
  87554. intersectsPoint(point: Vector3): boolean;
  87555. /**
  87556. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87557. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87558. */
  87559. checkCollisions: boolean;
  87560. /**
  87561. * Gets Collider object used to compute collisions (not physics)
  87562. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87563. */
  87564. readonly collider: Nullable<Collider>;
  87565. /**
  87566. * Move the mesh using collision engine
  87567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87568. * @param displacement defines the requested displacement vector
  87569. * @returns the current mesh
  87570. */
  87571. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87572. private _onCollisionPositionChange;
  87573. /** @hidden */
  87574. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87575. /** @hidden */
  87576. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87577. /** @hidden */
  87578. _checkCollision(collider: Collider): AbstractMesh;
  87579. /** @hidden */
  87580. _generatePointsArray(): boolean;
  87581. /**
  87582. * Checks if the passed Ray intersects with the mesh
  87583. * @param ray defines the ray to use
  87584. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87585. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87586. * @returns the picking info
  87587. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87588. */
  87589. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87590. /**
  87591. * Clones the current mesh
  87592. * @param name defines the mesh name
  87593. * @param newParent defines the new mesh parent
  87594. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87595. * @returns the new mesh
  87596. */
  87597. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87598. /**
  87599. * Disposes all the submeshes of the current meshnp
  87600. * @returns the current mesh
  87601. */
  87602. releaseSubMeshes(): AbstractMesh;
  87603. /**
  87604. * Releases resources associated with this abstract mesh.
  87605. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87606. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87607. */
  87608. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87609. /**
  87610. * Adds the passed mesh as a child to the current mesh
  87611. * @param mesh defines the child mesh
  87612. * @returns the current mesh
  87613. */
  87614. addChild(mesh: AbstractMesh): AbstractMesh;
  87615. /**
  87616. * Removes the passed mesh from the current mesh children list
  87617. * @param mesh defines the child mesh
  87618. * @returns the current mesh
  87619. */
  87620. removeChild(mesh: AbstractMesh): AbstractMesh;
  87621. /** @hidden */
  87622. private _initFacetData;
  87623. /**
  87624. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87625. * This method can be called within the render loop.
  87626. * 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
  87627. * @returns the current mesh
  87628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87629. */
  87630. updateFacetData(): AbstractMesh;
  87631. /**
  87632. * Returns the facetLocalNormals array.
  87633. * The normals are expressed in the mesh local spac
  87634. * @returns an array of Vector3
  87635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87636. */
  87637. getFacetLocalNormals(): Vector3[];
  87638. /**
  87639. * Returns the facetLocalPositions array.
  87640. * The facet positions are expressed in the mesh local space
  87641. * @returns an array of Vector3
  87642. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87643. */
  87644. getFacetLocalPositions(): Vector3[];
  87645. /**
  87646. * Returns the facetLocalPartioning array
  87647. * @returns an array of array of numbers
  87648. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87649. */
  87650. getFacetLocalPartitioning(): number[][];
  87651. /**
  87652. * Returns the i-th facet position in the world system.
  87653. * This method allocates a new Vector3 per call
  87654. * @param i defines the facet index
  87655. * @returns a new Vector3
  87656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87657. */
  87658. getFacetPosition(i: number): Vector3;
  87659. /**
  87660. * Sets the reference Vector3 with the i-th facet position in the world system
  87661. * @param i defines the facet index
  87662. * @param ref defines the target vector
  87663. * @returns the current mesh
  87664. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87665. */
  87666. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87667. /**
  87668. * Returns the i-th facet normal in the world system.
  87669. * This method allocates a new Vector3 per call
  87670. * @param i defines the facet index
  87671. * @returns a new Vector3
  87672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87673. */
  87674. getFacetNormal(i: number): Vector3;
  87675. /**
  87676. * Sets the reference Vector3 with the i-th facet normal in the world system
  87677. * @param i defines the facet index
  87678. * @param ref defines the target vector
  87679. * @returns the current mesh
  87680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87681. */
  87682. getFacetNormalToRef(i: number, ref: Vector3): this;
  87683. /**
  87684. * 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)
  87685. * @param x defines x coordinate
  87686. * @param y defines y coordinate
  87687. * @param z defines z coordinate
  87688. * @returns the array of facet indexes
  87689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87690. */
  87691. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87692. /**
  87693. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87694. * @param projected sets as the (x,y,z) world projection on the facet
  87695. * @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
  87696. * @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
  87697. * @param x defines x coordinate
  87698. * @param y defines y coordinate
  87699. * @param z defines z coordinate
  87700. * @returns the face index if found (or null instead)
  87701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87702. */
  87703. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87704. /**
  87705. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87706. * @param projected sets as the (x,y,z) local projection on the facet
  87707. * @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
  87708. * @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
  87709. * @param x defines x coordinate
  87710. * @param y defines y coordinate
  87711. * @param z defines z coordinate
  87712. * @returns the face index if found (or null instead)
  87713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87714. */
  87715. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87716. /**
  87717. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87718. * @returns the parameters
  87719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87720. */
  87721. getFacetDataParameters(): any;
  87722. /**
  87723. * Disables the feature FacetData and frees the related memory
  87724. * @returns the current mesh
  87725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87726. */
  87727. disableFacetData(): AbstractMesh;
  87728. /**
  87729. * Updates the AbstractMesh indices array
  87730. * @param indices defines the data source
  87731. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87732. * @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)
  87733. * @returns the current mesh
  87734. */
  87735. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87736. /**
  87737. * Creates new normals data for the mesh
  87738. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87739. * @returns the current mesh
  87740. */
  87741. createNormals(updatable: boolean): AbstractMesh;
  87742. /**
  87743. * Align the mesh with a normal
  87744. * @param normal defines the normal to use
  87745. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87746. * @returns the current mesh
  87747. */
  87748. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87749. /** @hidden */
  87750. _checkOcclusionQuery(): boolean;
  87751. /**
  87752. * Disables the mesh edge rendering mode
  87753. * @returns the currentAbstractMesh
  87754. */
  87755. disableEdgesRendering(): AbstractMesh;
  87756. /**
  87757. * Enables the edge rendering mode on the mesh.
  87758. * This mode makes the mesh edges visible
  87759. * @param epsilon defines the maximal distance between two angles to detect a face
  87760. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87761. * @returns the currentAbstractMesh
  87762. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87763. */
  87764. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87765. }
  87766. }
  87767. declare module BABYLON {
  87768. /**
  87769. * Interface used to define ActionEvent
  87770. */
  87771. export interface IActionEvent {
  87772. /** The mesh or sprite that triggered the action */
  87773. source: any;
  87774. /** The X mouse cursor position at the time of the event */
  87775. pointerX: number;
  87776. /** The Y mouse cursor position at the time of the event */
  87777. pointerY: number;
  87778. /** The mesh that is currently pointed at (can be null) */
  87779. meshUnderPointer: Nullable<AbstractMesh>;
  87780. /** the original (browser) event that triggered the ActionEvent */
  87781. sourceEvent?: any;
  87782. /** additional data for the event */
  87783. additionalData?: any;
  87784. }
  87785. /**
  87786. * ActionEvent is the event being sent when an action is triggered.
  87787. */
  87788. export class ActionEvent implements IActionEvent {
  87789. /** The mesh or sprite that triggered the action */
  87790. source: any;
  87791. /** The X mouse cursor position at the time of the event */
  87792. pointerX: number;
  87793. /** The Y mouse cursor position at the time of the event */
  87794. pointerY: number;
  87795. /** The mesh that is currently pointed at (can be null) */
  87796. meshUnderPointer: Nullable<AbstractMesh>;
  87797. /** the original (browser) event that triggered the ActionEvent */
  87798. sourceEvent?: any;
  87799. /** additional data for the event */
  87800. additionalData?: any;
  87801. /**
  87802. * Creates a new ActionEvent
  87803. * @param source The mesh or sprite that triggered the action
  87804. * @param pointerX The X mouse cursor position at the time of the event
  87805. * @param pointerY The Y mouse cursor position at the time of the event
  87806. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87807. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87808. * @param additionalData additional data for the event
  87809. */
  87810. constructor(
  87811. /** The mesh or sprite that triggered the action */
  87812. source: any,
  87813. /** The X mouse cursor position at the time of the event */
  87814. pointerX: number,
  87815. /** The Y mouse cursor position at the time of the event */
  87816. pointerY: number,
  87817. /** The mesh that is currently pointed at (can be null) */
  87818. meshUnderPointer: Nullable<AbstractMesh>,
  87819. /** the original (browser) event that triggered the ActionEvent */
  87820. sourceEvent?: any,
  87821. /** additional data for the event */
  87822. additionalData?: any);
  87823. /**
  87824. * Helper function to auto-create an ActionEvent from a source mesh.
  87825. * @param source The source mesh that triggered the event
  87826. * @param evt The original (browser) event
  87827. * @param additionalData additional data for the event
  87828. * @returns the new ActionEvent
  87829. */
  87830. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87831. /**
  87832. * Helper function to auto-create an ActionEvent from a source sprite
  87833. * @param source The source sprite that triggered the event
  87834. * @param scene Scene associated with the sprite
  87835. * @param evt The original (browser) event
  87836. * @param additionalData additional data for the event
  87837. * @returns the new ActionEvent
  87838. */
  87839. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87840. /**
  87841. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87842. * @param scene the scene where the event occurred
  87843. * @param evt The original (browser) event
  87844. * @returns the new ActionEvent
  87845. */
  87846. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87847. /**
  87848. * Helper function to auto-create an ActionEvent from a primitive
  87849. * @param prim defines the target primitive
  87850. * @param pointerPos defines the pointer position
  87851. * @param evt The original (browser) event
  87852. * @param additionalData additional data for the event
  87853. * @returns the new ActionEvent
  87854. */
  87855. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87856. }
  87857. }
  87858. declare module BABYLON {
  87859. /**
  87860. * Abstract class used to decouple action Manager from scene and meshes.
  87861. * Do not instantiate.
  87862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87863. */
  87864. export abstract class AbstractActionManager implements IDisposable {
  87865. /** Gets the list of active triggers */
  87866. static Triggers: {
  87867. [key: string]: number;
  87868. };
  87869. /** Gets the cursor to use when hovering items */
  87870. hoverCursor: string;
  87871. /** Gets the list of actions */
  87872. actions: IAction[];
  87873. /**
  87874. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87875. */
  87876. isRecursive: boolean;
  87877. /**
  87878. * Releases all associated resources
  87879. */
  87880. abstract dispose(): void;
  87881. /**
  87882. * Does this action manager has pointer triggers
  87883. */
  87884. abstract readonly hasPointerTriggers: boolean;
  87885. /**
  87886. * Does this action manager has pick triggers
  87887. */
  87888. abstract readonly hasPickTriggers: boolean;
  87889. /**
  87890. * Process a specific trigger
  87891. * @param trigger defines the trigger to process
  87892. * @param evt defines the event details to be processed
  87893. */
  87894. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87895. /**
  87896. * Does this action manager handles actions of any of the given triggers
  87897. * @param triggers defines the triggers to be tested
  87898. * @return a boolean indicating whether one (or more) of the triggers is handled
  87899. */
  87900. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87901. /**
  87902. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87903. * speed.
  87904. * @param triggerA defines the trigger to be tested
  87905. * @param triggerB defines the trigger to be tested
  87906. * @return a boolean indicating whether one (or more) of the triggers is handled
  87907. */
  87908. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87909. /**
  87910. * Does this action manager handles actions of a given trigger
  87911. * @param trigger defines the trigger to be tested
  87912. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87913. * @return whether the trigger is handled
  87914. */
  87915. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87916. /**
  87917. * Serialize this manager to a JSON object
  87918. * @param name defines the property name to store this manager
  87919. * @returns a JSON representation of this manager
  87920. */
  87921. abstract serialize(name: string): any;
  87922. /**
  87923. * Registers an action to this action manager
  87924. * @param action defines the action to be registered
  87925. * @return the action amended (prepared) after registration
  87926. */
  87927. abstract registerAction(action: IAction): Nullable<IAction>;
  87928. /**
  87929. * Unregisters an action to this action manager
  87930. * @param action defines the action to be unregistered
  87931. * @return a boolean indicating whether the action has been unregistered
  87932. */
  87933. abstract unregisterAction(action: IAction): Boolean;
  87934. /**
  87935. * Does exist one action manager with at least one trigger
  87936. **/
  87937. static readonly HasTriggers: boolean;
  87938. /**
  87939. * Does exist one action manager with at least one pick trigger
  87940. **/
  87941. static readonly HasPickTriggers: boolean;
  87942. /**
  87943. * Does exist one action manager that handles actions of a given trigger
  87944. * @param trigger defines the trigger to be tested
  87945. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  87946. **/
  87947. static HasSpecificTrigger(trigger: number): boolean;
  87948. }
  87949. }
  87950. declare module BABYLON {
  87951. /**
  87952. * Defines how a node can be built from a string name.
  87953. */
  87954. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  87955. /**
  87956. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  87957. */
  87958. export class Node implements IBehaviorAware<Node> {
  87959. /** @hidden */
  87960. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  87961. private static _NodeConstructors;
  87962. /**
  87963. * Add a new node constructor
  87964. * @param type defines the type name of the node to construct
  87965. * @param constructorFunc defines the constructor function
  87966. */
  87967. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  87968. /**
  87969. * Returns a node constructor based on type name
  87970. * @param type defines the type name
  87971. * @param name defines the new node name
  87972. * @param scene defines the hosting scene
  87973. * @param options defines optional options to transmit to constructors
  87974. * @returns the new constructor or null
  87975. */
  87976. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  87977. /**
  87978. * Gets or sets the name of the node
  87979. */
  87980. name: string;
  87981. /**
  87982. * Gets or sets the id of the node
  87983. */
  87984. id: string;
  87985. /**
  87986. * Gets or sets the unique id of the node
  87987. */
  87988. uniqueId: number;
  87989. /**
  87990. * Gets or sets a string used to store user defined state for the node
  87991. */
  87992. state: string;
  87993. /**
  87994. * Gets or sets an object used to store user defined information for the node
  87995. */
  87996. metadata: any;
  87997. /**
  87998. * For internal use only. Please do not use.
  87999. */
  88000. reservedDataStore: any;
  88001. /**
  88002. * List of inspectable custom properties (used by the Inspector)
  88003. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88004. */
  88005. inspectableCustomProperties: IInspectable[];
  88006. /**
  88007. * Gets or sets a boolean used to define if the node must be serialized
  88008. */
  88009. doNotSerialize: boolean;
  88010. /** @hidden */
  88011. _isDisposed: boolean;
  88012. /**
  88013. * Gets a list of Animations associated with the node
  88014. */
  88015. animations: Animation[];
  88016. protected _ranges: {
  88017. [name: string]: Nullable<AnimationRange>;
  88018. };
  88019. /**
  88020. * Callback raised when the node is ready to be used
  88021. */
  88022. onReady: Nullable<(node: Node) => void>;
  88023. private _isEnabled;
  88024. private _isParentEnabled;
  88025. private _isReady;
  88026. /** @hidden */
  88027. _currentRenderId: number;
  88028. private _parentUpdateId;
  88029. /** @hidden */
  88030. _childUpdateId: number;
  88031. /** @hidden */
  88032. _waitingParentId: Nullable<string>;
  88033. /** @hidden */
  88034. _scene: Scene;
  88035. /** @hidden */
  88036. _cache: any;
  88037. private _parentNode;
  88038. private _children;
  88039. /** @hidden */
  88040. _worldMatrix: Matrix;
  88041. /** @hidden */
  88042. _worldMatrixDeterminant: number;
  88043. /** @hidden */
  88044. _worldMatrixDeterminantIsDirty: boolean;
  88045. /** @hidden */
  88046. private _sceneRootNodesIndex;
  88047. /**
  88048. * Gets a boolean indicating if the node has been disposed
  88049. * @returns true if the node was disposed
  88050. */
  88051. isDisposed(): boolean;
  88052. /**
  88053. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88054. * @see https://doc.babylonjs.com/how_to/parenting
  88055. */
  88056. parent: Nullable<Node>;
  88057. private addToSceneRootNodes;
  88058. private removeFromSceneRootNodes;
  88059. private _animationPropertiesOverride;
  88060. /**
  88061. * Gets or sets the animation properties override
  88062. */
  88063. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88064. /**
  88065. * Gets a string idenfifying the name of the class
  88066. * @returns "Node" string
  88067. */
  88068. getClassName(): string;
  88069. /** @hidden */
  88070. readonly _isNode: boolean;
  88071. /**
  88072. * An event triggered when the mesh is disposed
  88073. */
  88074. onDisposeObservable: Observable<Node>;
  88075. private _onDisposeObserver;
  88076. /**
  88077. * Sets a callback that will be raised when the node will be disposed
  88078. */
  88079. onDispose: () => void;
  88080. /**
  88081. * Creates a new Node
  88082. * @param name the name and id to be given to this node
  88083. * @param scene the scene this node will be added to
  88084. * @param addToRootNodes the node will be added to scene.rootNodes
  88085. */
  88086. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88087. /**
  88088. * Gets the scene of the node
  88089. * @returns a scene
  88090. */
  88091. getScene(): Scene;
  88092. /**
  88093. * Gets the engine of the node
  88094. * @returns a Engine
  88095. */
  88096. getEngine(): Engine;
  88097. private _behaviors;
  88098. /**
  88099. * Attach a behavior to the node
  88100. * @see http://doc.babylonjs.com/features/behaviour
  88101. * @param behavior defines the behavior to attach
  88102. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88103. * @returns the current Node
  88104. */
  88105. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88106. /**
  88107. * Remove an attached behavior
  88108. * @see http://doc.babylonjs.com/features/behaviour
  88109. * @param behavior defines the behavior to attach
  88110. * @returns the current Node
  88111. */
  88112. removeBehavior(behavior: Behavior<Node>): Node;
  88113. /**
  88114. * Gets the list of attached behaviors
  88115. * @see http://doc.babylonjs.com/features/behaviour
  88116. */
  88117. readonly behaviors: Behavior<Node>[];
  88118. /**
  88119. * Gets an attached behavior by name
  88120. * @param name defines the name of the behavior to look for
  88121. * @see http://doc.babylonjs.com/features/behaviour
  88122. * @returns null if behavior was not found else the requested behavior
  88123. */
  88124. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88125. /**
  88126. * Returns the latest update of the World matrix
  88127. * @returns a Matrix
  88128. */
  88129. getWorldMatrix(): Matrix;
  88130. /** @hidden */
  88131. _getWorldMatrixDeterminant(): number;
  88132. /**
  88133. * Returns directly the latest state of the mesh World matrix.
  88134. * A Matrix is returned.
  88135. */
  88136. readonly worldMatrixFromCache: Matrix;
  88137. /** @hidden */
  88138. _initCache(): void;
  88139. /** @hidden */
  88140. updateCache(force?: boolean): void;
  88141. /** @hidden */
  88142. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88143. /** @hidden */
  88144. _updateCache(ignoreParentClass?: boolean): void;
  88145. /** @hidden */
  88146. _isSynchronized(): boolean;
  88147. /** @hidden */
  88148. _markSyncedWithParent(): void;
  88149. /** @hidden */
  88150. isSynchronizedWithParent(): boolean;
  88151. /** @hidden */
  88152. isSynchronized(): boolean;
  88153. /**
  88154. * Is this node ready to be used/rendered
  88155. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88156. * @return true if the node is ready
  88157. */
  88158. isReady(completeCheck?: boolean): boolean;
  88159. /**
  88160. * Is this node enabled?
  88161. * 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
  88162. * @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
  88163. * @return whether this node (and its parent) is enabled
  88164. */
  88165. isEnabled(checkAncestors?: boolean): boolean;
  88166. /** @hidden */
  88167. protected _syncParentEnabledState(): void;
  88168. /**
  88169. * Set the enabled state of this node
  88170. * @param value defines the new enabled state
  88171. */
  88172. setEnabled(value: boolean): void;
  88173. /**
  88174. * Is this node a descendant of the given node?
  88175. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88176. * @param ancestor defines the parent node to inspect
  88177. * @returns a boolean indicating if this node is a descendant of the given node
  88178. */
  88179. isDescendantOf(ancestor: Node): boolean;
  88180. /** @hidden */
  88181. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88182. /**
  88183. * Will return all nodes that have this node as ascendant
  88184. * @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
  88185. * @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
  88186. * @return all children nodes of all types
  88187. */
  88188. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88189. /**
  88190. * Get all child-meshes of this node
  88191. * @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)
  88192. * @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
  88193. * @returns an array of AbstractMesh
  88194. */
  88195. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88196. /**
  88197. * Get all direct children of this node
  88198. * @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
  88199. * @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)
  88200. * @returns an array of Node
  88201. */
  88202. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88203. /** @hidden */
  88204. _setReady(state: boolean): void;
  88205. /**
  88206. * Get an animation by name
  88207. * @param name defines the name of the animation to look for
  88208. * @returns null if not found else the requested animation
  88209. */
  88210. getAnimationByName(name: string): Nullable<Animation>;
  88211. /**
  88212. * Creates an animation range for this node
  88213. * @param name defines the name of the range
  88214. * @param from defines the starting key
  88215. * @param to defines the end key
  88216. */
  88217. createAnimationRange(name: string, from: number, to: number): void;
  88218. /**
  88219. * Delete a specific animation range
  88220. * @param name defines the name of the range to delete
  88221. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88222. */
  88223. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88224. /**
  88225. * Get an animation range by name
  88226. * @param name defines the name of the animation range to look for
  88227. * @returns null if not found else the requested animation range
  88228. */
  88229. getAnimationRange(name: string): Nullable<AnimationRange>;
  88230. /**
  88231. * Gets the list of all animation ranges defined on this node
  88232. * @returns an array
  88233. */
  88234. getAnimationRanges(): Nullable<AnimationRange>[];
  88235. /**
  88236. * Will start the animation sequence
  88237. * @param name defines the range frames for animation sequence
  88238. * @param loop defines if the animation should loop (false by default)
  88239. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88240. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88241. * @returns the object created for this animation. If range does not exist, it will return null
  88242. */
  88243. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88244. /**
  88245. * Serialize animation ranges into a JSON compatible object
  88246. * @returns serialization object
  88247. */
  88248. serializeAnimationRanges(): any;
  88249. /**
  88250. * Computes the world matrix of the node
  88251. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88252. * @returns the world matrix
  88253. */
  88254. computeWorldMatrix(force?: boolean): Matrix;
  88255. /**
  88256. * Releases resources associated with this node.
  88257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88259. */
  88260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88261. /**
  88262. * Parse animation range data from a serialization object and store them into a given node
  88263. * @param node defines where to store the animation ranges
  88264. * @param parsedNode defines the serialization object to read data from
  88265. * @param scene defines the hosting scene
  88266. */
  88267. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88268. /**
  88269. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88270. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88271. * @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
  88272. * @returns the new bounding vectors
  88273. */
  88274. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88275. min: Vector3;
  88276. max: Vector3;
  88277. };
  88278. }
  88279. }
  88280. declare module BABYLON {
  88281. /**
  88282. * @hidden
  88283. */
  88284. export class _IAnimationState {
  88285. key: number;
  88286. repeatCount: number;
  88287. workValue?: any;
  88288. loopMode?: number;
  88289. offsetValue?: any;
  88290. highLimitValue?: any;
  88291. }
  88292. /**
  88293. * Class used to store any kind of animation
  88294. */
  88295. export class Animation {
  88296. /**Name of the animation */
  88297. name: string;
  88298. /**Property to animate */
  88299. targetProperty: string;
  88300. /**The frames per second of the animation */
  88301. framePerSecond: number;
  88302. /**The data type of the animation */
  88303. dataType: number;
  88304. /**The loop mode of the animation */
  88305. loopMode?: number | undefined;
  88306. /**Specifies if blending should be enabled */
  88307. enableBlending?: boolean | undefined;
  88308. /**
  88309. * Use matrix interpolation instead of using direct key value when animating matrices
  88310. */
  88311. static AllowMatricesInterpolation: boolean;
  88312. /**
  88313. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88314. */
  88315. static AllowMatrixDecomposeForInterpolation: boolean;
  88316. /**
  88317. * Stores the key frames of the animation
  88318. */
  88319. private _keys;
  88320. /**
  88321. * Stores the easing function of the animation
  88322. */
  88323. private _easingFunction;
  88324. /**
  88325. * @hidden Internal use only
  88326. */
  88327. _runtimeAnimations: RuntimeAnimation[];
  88328. /**
  88329. * The set of event that will be linked to this animation
  88330. */
  88331. private _events;
  88332. /**
  88333. * Stores an array of target property paths
  88334. */
  88335. targetPropertyPath: string[];
  88336. /**
  88337. * Stores the blending speed of the animation
  88338. */
  88339. blendingSpeed: number;
  88340. /**
  88341. * Stores the animation ranges for the animation
  88342. */
  88343. private _ranges;
  88344. /**
  88345. * @hidden Internal use
  88346. */
  88347. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88348. /**
  88349. * Sets up an animation
  88350. * @param property The property to animate
  88351. * @param animationType The animation type to apply
  88352. * @param framePerSecond The frames per second of the animation
  88353. * @param easingFunction The easing function used in the animation
  88354. * @returns The created animation
  88355. */
  88356. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88357. /**
  88358. * Create and start an animation on a node
  88359. * @param name defines the name of the global animation that will be run on all nodes
  88360. * @param node defines the root node where the animation will take place
  88361. * @param targetProperty defines property to animate
  88362. * @param framePerSecond defines the number of frame per second yo use
  88363. * @param totalFrame defines the number of frames in total
  88364. * @param from defines the initial value
  88365. * @param to defines the final value
  88366. * @param loopMode defines which loop mode you want to use (off by default)
  88367. * @param easingFunction defines the easing function to use (linear by default)
  88368. * @param onAnimationEnd defines the callback to call when animation end
  88369. * @returns the animatable created for this animation
  88370. */
  88371. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88372. /**
  88373. * Create and start an animation on a node and its descendants
  88374. * @param name defines the name of the global animation that will be run on all nodes
  88375. * @param node defines the root node where the animation will take place
  88376. * @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
  88377. * @param targetProperty defines property to animate
  88378. * @param framePerSecond defines the number of frame per second to use
  88379. * @param totalFrame defines the number of frames in total
  88380. * @param from defines the initial value
  88381. * @param to defines the final value
  88382. * @param loopMode defines which loop mode you want to use (off by default)
  88383. * @param easingFunction defines the easing function to use (linear by default)
  88384. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88385. * @returns the list of animatables created for all nodes
  88386. * @example https://www.babylonjs-playground.com/#MH0VLI
  88387. */
  88388. 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[]>;
  88389. /**
  88390. * Creates a new animation, merges it with the existing animations and starts it
  88391. * @param name Name of the animation
  88392. * @param node Node which contains the scene that begins the animations
  88393. * @param targetProperty Specifies which property to animate
  88394. * @param framePerSecond The frames per second of the animation
  88395. * @param totalFrame The total number of frames
  88396. * @param from The frame at the beginning of the animation
  88397. * @param to The frame at the end of the animation
  88398. * @param loopMode Specifies the loop mode of the animation
  88399. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88400. * @param onAnimationEnd Callback to run once the animation is complete
  88401. * @returns Nullable animation
  88402. */
  88403. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88404. /**
  88405. * Transition property of an host to the target Value
  88406. * @param property The property to transition
  88407. * @param targetValue The target Value of the property
  88408. * @param host The object where the property to animate belongs
  88409. * @param scene Scene used to run the animation
  88410. * @param frameRate Framerate (in frame/s) to use
  88411. * @param transition The transition type we want to use
  88412. * @param duration The duration of the animation, in milliseconds
  88413. * @param onAnimationEnd Callback trigger at the end of the animation
  88414. * @returns Nullable animation
  88415. */
  88416. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88417. /**
  88418. * Return the array of runtime animations currently using this animation
  88419. */
  88420. readonly runtimeAnimations: RuntimeAnimation[];
  88421. /**
  88422. * Specifies if any of the runtime animations are currently running
  88423. */
  88424. readonly hasRunningRuntimeAnimations: boolean;
  88425. /**
  88426. * Initializes the animation
  88427. * @param name Name of the animation
  88428. * @param targetProperty Property to animate
  88429. * @param framePerSecond The frames per second of the animation
  88430. * @param dataType The data type of the animation
  88431. * @param loopMode The loop mode of the animation
  88432. * @param enableBlending Specifies if blending should be enabled
  88433. */
  88434. constructor(
  88435. /**Name of the animation */
  88436. name: string,
  88437. /**Property to animate */
  88438. targetProperty: string,
  88439. /**The frames per second of the animation */
  88440. framePerSecond: number,
  88441. /**The data type of the animation */
  88442. dataType: number,
  88443. /**The loop mode of the animation */
  88444. loopMode?: number | undefined,
  88445. /**Specifies if blending should be enabled */
  88446. enableBlending?: boolean | undefined);
  88447. /**
  88448. * Converts the animation to a string
  88449. * @param fullDetails support for multiple levels of logging within scene loading
  88450. * @returns String form of the animation
  88451. */
  88452. toString(fullDetails?: boolean): string;
  88453. /**
  88454. * Add an event to this animation
  88455. * @param event Event to add
  88456. */
  88457. addEvent(event: AnimationEvent): void;
  88458. /**
  88459. * Remove all events found at the given frame
  88460. * @param frame The frame to remove events from
  88461. */
  88462. removeEvents(frame: number): void;
  88463. /**
  88464. * Retrieves all the events from the animation
  88465. * @returns Events from the animation
  88466. */
  88467. getEvents(): AnimationEvent[];
  88468. /**
  88469. * Creates an animation range
  88470. * @param name Name of the animation range
  88471. * @param from Starting frame of the animation range
  88472. * @param to Ending frame of the animation
  88473. */
  88474. createRange(name: string, from: number, to: number): void;
  88475. /**
  88476. * Deletes an animation range by name
  88477. * @param name Name of the animation range to delete
  88478. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88479. */
  88480. deleteRange(name: string, deleteFrames?: boolean): void;
  88481. /**
  88482. * Gets the animation range by name, or null if not defined
  88483. * @param name Name of the animation range
  88484. * @returns Nullable animation range
  88485. */
  88486. getRange(name: string): Nullable<AnimationRange>;
  88487. /**
  88488. * Gets the key frames from the animation
  88489. * @returns The key frames of the animation
  88490. */
  88491. getKeys(): Array<IAnimationKey>;
  88492. /**
  88493. * Gets the highest frame rate of the animation
  88494. * @returns Highest frame rate of the animation
  88495. */
  88496. getHighestFrame(): number;
  88497. /**
  88498. * Gets the easing function of the animation
  88499. * @returns Easing function of the animation
  88500. */
  88501. getEasingFunction(): IEasingFunction;
  88502. /**
  88503. * Sets the easing function of the animation
  88504. * @param easingFunction A custom mathematical formula for animation
  88505. */
  88506. setEasingFunction(easingFunction: EasingFunction): void;
  88507. /**
  88508. * Interpolates a scalar linearly
  88509. * @param startValue Start value of the animation curve
  88510. * @param endValue End value of the animation curve
  88511. * @param gradient Scalar amount to interpolate
  88512. * @returns Interpolated scalar value
  88513. */
  88514. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88515. /**
  88516. * Interpolates a scalar cubically
  88517. * @param startValue Start value of the animation curve
  88518. * @param outTangent End tangent of the animation
  88519. * @param endValue End value of the animation curve
  88520. * @param inTangent Start tangent of the animation curve
  88521. * @param gradient Scalar amount to interpolate
  88522. * @returns Interpolated scalar value
  88523. */
  88524. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88525. /**
  88526. * Interpolates a quaternion using a spherical linear interpolation
  88527. * @param startValue Start value of the animation curve
  88528. * @param endValue End value of the animation curve
  88529. * @param gradient Scalar amount to interpolate
  88530. * @returns Interpolated quaternion value
  88531. */
  88532. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88533. /**
  88534. * Interpolates a quaternion cubically
  88535. * @param startValue Start value of the animation curve
  88536. * @param outTangent End tangent of the animation curve
  88537. * @param endValue End value of the animation curve
  88538. * @param inTangent Start tangent of the animation curve
  88539. * @param gradient Scalar amount to interpolate
  88540. * @returns Interpolated quaternion value
  88541. */
  88542. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88543. /**
  88544. * Interpolates a Vector3 linearl
  88545. * @param startValue Start value of the animation curve
  88546. * @param endValue End value of the animation curve
  88547. * @param gradient Scalar amount to interpolate
  88548. * @returns Interpolated scalar value
  88549. */
  88550. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88551. /**
  88552. * Interpolates a Vector3 cubically
  88553. * @param startValue Start value of the animation curve
  88554. * @param outTangent End tangent of the animation
  88555. * @param endValue End value of the animation curve
  88556. * @param inTangent Start tangent of the animation curve
  88557. * @param gradient Scalar amount to interpolate
  88558. * @returns InterpolatedVector3 value
  88559. */
  88560. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88561. /**
  88562. * Interpolates a Vector2 linearly
  88563. * @param startValue Start value of the animation curve
  88564. * @param endValue End value of the animation curve
  88565. * @param gradient Scalar amount to interpolate
  88566. * @returns Interpolated Vector2 value
  88567. */
  88568. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88569. /**
  88570. * Interpolates a Vector2 cubically
  88571. * @param startValue Start value of the animation curve
  88572. * @param outTangent End tangent of the animation
  88573. * @param endValue End value of the animation curve
  88574. * @param inTangent Start tangent of the animation curve
  88575. * @param gradient Scalar amount to interpolate
  88576. * @returns Interpolated Vector2 value
  88577. */
  88578. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88579. /**
  88580. * Interpolates a size linearly
  88581. * @param startValue Start value of the animation curve
  88582. * @param endValue End value of the animation curve
  88583. * @param gradient Scalar amount to interpolate
  88584. * @returns Interpolated Size value
  88585. */
  88586. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88587. /**
  88588. * Interpolates a Color3 linearly
  88589. * @param startValue Start value of the animation curve
  88590. * @param endValue End value of the animation curve
  88591. * @param gradient Scalar amount to interpolate
  88592. * @returns Interpolated Color3 value
  88593. */
  88594. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88595. /**
  88596. * @hidden Internal use only
  88597. */
  88598. _getKeyValue(value: any): any;
  88599. /**
  88600. * @hidden Internal use only
  88601. */
  88602. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88603. /**
  88604. * Defines the function to use to interpolate matrices
  88605. * @param startValue defines the start matrix
  88606. * @param endValue defines the end matrix
  88607. * @param gradient defines the gradient between both matrices
  88608. * @param result defines an optional target matrix where to store the interpolation
  88609. * @returns the interpolated matrix
  88610. */
  88611. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88612. /**
  88613. * Makes a copy of the animation
  88614. * @returns Cloned animation
  88615. */
  88616. clone(): Animation;
  88617. /**
  88618. * Sets the key frames of the animation
  88619. * @param values The animation key frames to set
  88620. */
  88621. setKeys(values: Array<IAnimationKey>): void;
  88622. /**
  88623. * Serializes the animation to an object
  88624. * @returns Serialized object
  88625. */
  88626. serialize(): any;
  88627. /**
  88628. * Float animation type
  88629. */
  88630. private static _ANIMATIONTYPE_FLOAT;
  88631. /**
  88632. * Vector3 animation type
  88633. */
  88634. private static _ANIMATIONTYPE_VECTOR3;
  88635. /**
  88636. * Quaternion animation type
  88637. */
  88638. private static _ANIMATIONTYPE_QUATERNION;
  88639. /**
  88640. * Matrix animation type
  88641. */
  88642. private static _ANIMATIONTYPE_MATRIX;
  88643. /**
  88644. * Color3 animation type
  88645. */
  88646. private static _ANIMATIONTYPE_COLOR3;
  88647. /**
  88648. * Vector2 animation type
  88649. */
  88650. private static _ANIMATIONTYPE_VECTOR2;
  88651. /**
  88652. * Size animation type
  88653. */
  88654. private static _ANIMATIONTYPE_SIZE;
  88655. /**
  88656. * Relative Loop Mode
  88657. */
  88658. private static _ANIMATIONLOOPMODE_RELATIVE;
  88659. /**
  88660. * Cycle Loop Mode
  88661. */
  88662. private static _ANIMATIONLOOPMODE_CYCLE;
  88663. /**
  88664. * Constant Loop Mode
  88665. */
  88666. private static _ANIMATIONLOOPMODE_CONSTANT;
  88667. /**
  88668. * Get the float animation type
  88669. */
  88670. static readonly ANIMATIONTYPE_FLOAT: number;
  88671. /**
  88672. * Get the Vector3 animation type
  88673. */
  88674. static readonly ANIMATIONTYPE_VECTOR3: number;
  88675. /**
  88676. * Get the Vector2 animation type
  88677. */
  88678. static readonly ANIMATIONTYPE_VECTOR2: number;
  88679. /**
  88680. * Get the Size animation type
  88681. */
  88682. static readonly ANIMATIONTYPE_SIZE: number;
  88683. /**
  88684. * Get the Quaternion animation type
  88685. */
  88686. static readonly ANIMATIONTYPE_QUATERNION: number;
  88687. /**
  88688. * Get the Matrix animation type
  88689. */
  88690. static readonly ANIMATIONTYPE_MATRIX: number;
  88691. /**
  88692. * Get the Color3 animation type
  88693. */
  88694. static readonly ANIMATIONTYPE_COLOR3: number;
  88695. /**
  88696. * Get the Relative Loop Mode
  88697. */
  88698. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88699. /**
  88700. * Get the Cycle Loop Mode
  88701. */
  88702. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88703. /**
  88704. * Get the Constant Loop Mode
  88705. */
  88706. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88707. /** @hidden */
  88708. static _UniversalLerp(left: any, right: any, amount: number): any;
  88709. /**
  88710. * Parses an animation object and creates an animation
  88711. * @param parsedAnimation Parsed animation object
  88712. * @returns Animation object
  88713. */
  88714. static Parse(parsedAnimation: any): Animation;
  88715. /**
  88716. * Appends the serialized animations from the source animations
  88717. * @param source Source containing the animations
  88718. * @param destination Target to store the animations
  88719. */
  88720. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88721. }
  88722. }
  88723. declare module BABYLON {
  88724. /**
  88725. * Base class of all the textures in babylon.
  88726. * It groups all the common properties the materials, post process, lights... might need
  88727. * in order to make a correct use of the texture.
  88728. */
  88729. export class BaseTexture implements IAnimatable {
  88730. /**
  88731. * Default anisotropic filtering level for the application.
  88732. * It is set to 4 as a good tradeoff between perf and quality.
  88733. */
  88734. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88735. /**
  88736. * Gets or sets the unique id of the texture
  88737. */
  88738. uniqueId: number;
  88739. /**
  88740. * Define the name of the texture.
  88741. */
  88742. name: string;
  88743. /**
  88744. * Gets or sets an object used to store user defined information.
  88745. */
  88746. metadata: any;
  88747. /**
  88748. * For internal use only. Please do not use.
  88749. */
  88750. reservedDataStore: any;
  88751. private _hasAlpha;
  88752. /**
  88753. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88754. */
  88755. hasAlpha: boolean;
  88756. /**
  88757. * Defines if the alpha value should be determined via the rgb values.
  88758. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88759. */
  88760. getAlphaFromRGB: boolean;
  88761. /**
  88762. * Intensity or strength of the texture.
  88763. * It is commonly used by materials to fine tune the intensity of the texture
  88764. */
  88765. level: number;
  88766. /**
  88767. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88768. * This is part of the texture as textures usually maps to one uv set.
  88769. */
  88770. coordinatesIndex: number;
  88771. private _coordinatesMode;
  88772. /**
  88773. * How a texture is mapped.
  88774. *
  88775. * | Value | Type | Description |
  88776. * | ----- | ----------------------------------- | ----------- |
  88777. * | 0 | EXPLICIT_MODE | |
  88778. * | 1 | SPHERICAL_MODE | |
  88779. * | 2 | PLANAR_MODE | |
  88780. * | 3 | CUBIC_MODE | |
  88781. * | 4 | PROJECTION_MODE | |
  88782. * | 5 | SKYBOX_MODE | |
  88783. * | 6 | INVCUBIC_MODE | |
  88784. * | 7 | EQUIRECTANGULAR_MODE | |
  88785. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88786. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88787. */
  88788. coordinatesMode: number;
  88789. /**
  88790. * | Value | Type | Description |
  88791. * | ----- | ------------------ | ----------- |
  88792. * | 0 | CLAMP_ADDRESSMODE | |
  88793. * | 1 | WRAP_ADDRESSMODE | |
  88794. * | 2 | MIRROR_ADDRESSMODE | |
  88795. */
  88796. wrapU: number;
  88797. /**
  88798. * | Value | Type | Description |
  88799. * | ----- | ------------------ | ----------- |
  88800. * | 0 | CLAMP_ADDRESSMODE | |
  88801. * | 1 | WRAP_ADDRESSMODE | |
  88802. * | 2 | MIRROR_ADDRESSMODE | |
  88803. */
  88804. wrapV: number;
  88805. /**
  88806. * | Value | Type | Description |
  88807. * | ----- | ------------------ | ----------- |
  88808. * | 0 | CLAMP_ADDRESSMODE | |
  88809. * | 1 | WRAP_ADDRESSMODE | |
  88810. * | 2 | MIRROR_ADDRESSMODE | |
  88811. */
  88812. wrapR: number;
  88813. /**
  88814. * With compliant hardware and browser (supporting anisotropic filtering)
  88815. * this defines the level of anisotropic filtering in the texture.
  88816. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88817. */
  88818. anisotropicFilteringLevel: number;
  88819. /**
  88820. * Define if the texture is a cube texture or if false a 2d texture.
  88821. */
  88822. isCube: boolean;
  88823. /**
  88824. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88825. */
  88826. is3D: boolean;
  88827. /**
  88828. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88829. * HDR texture are usually stored in linear space.
  88830. * This only impacts the PBR and Background materials
  88831. */
  88832. gammaSpace: boolean;
  88833. /**
  88834. * Gets whether or not the texture contains RGBD data.
  88835. */
  88836. readonly isRGBD: boolean;
  88837. /**
  88838. * Is Z inverted in the texture (useful in a cube texture).
  88839. */
  88840. invertZ: boolean;
  88841. /**
  88842. * Are mip maps generated for this texture or not.
  88843. */
  88844. readonly noMipmap: boolean;
  88845. /**
  88846. * @hidden
  88847. */
  88848. lodLevelInAlpha: boolean;
  88849. /**
  88850. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88851. */
  88852. lodGenerationOffset: number;
  88853. /**
  88854. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88855. */
  88856. lodGenerationScale: number;
  88857. /**
  88858. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88859. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88860. * average roughness values.
  88861. */
  88862. linearSpecularLOD: boolean;
  88863. /**
  88864. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  88865. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  88866. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  88867. */
  88868. irradianceTexture: Nullable<BaseTexture>;
  88869. /**
  88870. * Define if the texture is a render target.
  88871. */
  88872. isRenderTarget: boolean;
  88873. /**
  88874. * Define the unique id of the texture in the scene.
  88875. */
  88876. readonly uid: string;
  88877. /**
  88878. * Return a string representation of the texture.
  88879. * @returns the texture as a string
  88880. */
  88881. toString(): string;
  88882. /**
  88883. * Get the class name of the texture.
  88884. * @returns "BaseTexture"
  88885. */
  88886. getClassName(): string;
  88887. /**
  88888. * Define the list of animation attached to the texture.
  88889. */
  88890. animations: Animation[];
  88891. /**
  88892. * An event triggered when the texture is disposed.
  88893. */
  88894. onDisposeObservable: Observable<BaseTexture>;
  88895. private _onDisposeObserver;
  88896. /**
  88897. * Callback triggered when the texture has been disposed.
  88898. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88899. */
  88900. onDispose: () => void;
  88901. /**
  88902. * Define the current state of the loading sequence when in delayed load mode.
  88903. */
  88904. delayLoadState: number;
  88905. private _scene;
  88906. /** @hidden */
  88907. _texture: Nullable<InternalTexture>;
  88908. private _uid;
  88909. /**
  88910. * Define if the texture is preventinga material to render or not.
  88911. * If not and the texture is not ready, the engine will use a default black texture instead.
  88912. */
  88913. readonly isBlocking: boolean;
  88914. /**
  88915. * Instantiates a new BaseTexture.
  88916. * Base class of all the textures in babylon.
  88917. * It groups all the common properties the materials, post process, lights... might need
  88918. * in order to make a correct use of the texture.
  88919. * @param scene Define the scene the texture blongs to
  88920. */
  88921. constructor(scene: Nullable<Scene>);
  88922. /**
  88923. * Get the scene the texture belongs to.
  88924. * @returns the scene or null if undefined
  88925. */
  88926. getScene(): Nullable<Scene>;
  88927. /**
  88928. * Get the texture transform matrix used to offset tile the texture for istance.
  88929. * @returns the transformation matrix
  88930. */
  88931. getTextureMatrix(): Matrix;
  88932. /**
  88933. * Get the texture reflection matrix used to rotate/transform the reflection.
  88934. * @returns the reflection matrix
  88935. */
  88936. getReflectionTextureMatrix(): Matrix;
  88937. /**
  88938. * Get the underlying lower level texture from Babylon.
  88939. * @returns the insternal texture
  88940. */
  88941. getInternalTexture(): Nullable<InternalTexture>;
  88942. /**
  88943. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  88944. * @returns true if ready or not blocking
  88945. */
  88946. isReadyOrNotBlocking(): boolean;
  88947. /**
  88948. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  88949. * @returns true if fully ready
  88950. */
  88951. isReady(): boolean;
  88952. private _cachedSize;
  88953. /**
  88954. * Get the size of the texture.
  88955. * @returns the texture size.
  88956. */
  88957. getSize(): ISize;
  88958. /**
  88959. * Get the base size of the texture.
  88960. * It can be different from the size if the texture has been resized for POT for instance
  88961. * @returns the base size
  88962. */
  88963. getBaseSize(): ISize;
  88964. /**
  88965. * Update the sampling mode of the texture.
  88966. * Default is Trilinear mode.
  88967. *
  88968. * | Value | Type | Description |
  88969. * | ----- | ------------------ | ----------- |
  88970. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  88971. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  88972. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  88973. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  88974. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  88975. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  88976. * | 7 | NEAREST_LINEAR | |
  88977. * | 8 | NEAREST_NEAREST | |
  88978. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  88979. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  88980. * | 11 | LINEAR_LINEAR | |
  88981. * | 12 | LINEAR_NEAREST | |
  88982. *
  88983. * > _mag_: magnification filter (close to the viewer)
  88984. * > _min_: minification filter (far from the viewer)
  88985. * > _mip_: filter used between mip map levels
  88986. *@param samplingMode Define the new sampling mode of the texture
  88987. */
  88988. updateSamplingMode(samplingMode: number): void;
  88989. /**
  88990. * Scales the texture if is `canRescale()`
  88991. * @param ratio the resize factor we want to use to rescale
  88992. */
  88993. scale(ratio: number): void;
  88994. /**
  88995. * Get if the texture can rescale.
  88996. */
  88997. readonly canRescale: boolean;
  88998. /** @hidden */
  88999. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89000. /** @hidden */
  89001. _rebuild(): void;
  89002. /**
  89003. * Triggers the load sequence in delayed load mode.
  89004. */
  89005. delayLoad(): void;
  89006. /**
  89007. * Clones the texture.
  89008. * @returns the cloned texture
  89009. */
  89010. clone(): Nullable<BaseTexture>;
  89011. /**
  89012. * Get the texture underlying type (INT, FLOAT...)
  89013. */
  89014. readonly textureType: number;
  89015. /**
  89016. * Get the texture underlying format (RGB, RGBA...)
  89017. */
  89018. readonly textureFormat: number;
  89019. /**
  89020. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89021. * This will returns an RGBA array buffer containing either in values (0-255) or
  89022. * float values (0-1) depending of the underlying buffer type.
  89023. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89024. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89025. * @param buffer defines a user defined buffer to fill with data (can be null)
  89026. * @returns The Array buffer containing the pixels data.
  89027. */
  89028. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89029. /**
  89030. * Release and destroy the underlying lower level texture aka internalTexture.
  89031. */
  89032. releaseInternalTexture(): void;
  89033. /**
  89034. * Get the polynomial representation of the texture data.
  89035. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89036. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89037. */
  89038. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89039. /** @hidden */
  89040. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89041. /** @hidden */
  89042. readonly _lodTextureMid: Nullable<BaseTexture>;
  89043. /** @hidden */
  89044. readonly _lodTextureLow: Nullable<BaseTexture>;
  89045. /**
  89046. * Dispose the texture and release its associated resources.
  89047. */
  89048. dispose(): void;
  89049. /**
  89050. * Serialize the texture into a JSON representation that can be parsed later on.
  89051. * @returns the JSON representation of the texture
  89052. */
  89053. serialize(): any;
  89054. /**
  89055. * Helper function to be called back once a list of texture contains only ready textures.
  89056. * @param textures Define the list of textures to wait for
  89057. * @param callback Define the callback triggered once the entire list will be ready
  89058. */
  89059. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89060. }
  89061. }
  89062. declare module BABYLON {
  89063. /**
  89064. * Uniform buffer objects.
  89065. *
  89066. * Handles blocks of uniform on the GPU.
  89067. *
  89068. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89069. *
  89070. * For more information, please refer to :
  89071. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89072. */
  89073. export class UniformBuffer {
  89074. private _engine;
  89075. private _buffer;
  89076. private _data;
  89077. private _bufferData;
  89078. private _dynamic?;
  89079. private _uniformLocations;
  89080. private _uniformSizes;
  89081. private _uniformLocationPointer;
  89082. private _needSync;
  89083. private _noUBO;
  89084. private _currentEffect;
  89085. private static _MAX_UNIFORM_SIZE;
  89086. private static _tempBuffer;
  89087. /**
  89088. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89089. * This is dynamic to allow compat with webgl 1 and 2.
  89090. * You will need to pass the name of the uniform as well as the value.
  89091. */
  89092. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89093. /**
  89094. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89095. * This is dynamic to allow compat with webgl 1 and 2.
  89096. * You will need to pass the name of the uniform as well as the value.
  89097. */
  89098. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89099. /**
  89100. * Lambda to Update a single float in a uniform buffer.
  89101. * This is dynamic to allow compat with webgl 1 and 2.
  89102. * You will need to pass the name of the uniform as well as the value.
  89103. */
  89104. updateFloat: (name: string, x: number) => void;
  89105. /**
  89106. * Lambda to Update a vec2 of float in a uniform buffer.
  89107. * This is dynamic to allow compat with webgl 1 and 2.
  89108. * You will need to pass the name of the uniform as well as the value.
  89109. */
  89110. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89111. /**
  89112. * Lambda to Update a vec3 of float in a uniform buffer.
  89113. * This is dynamic to allow compat with webgl 1 and 2.
  89114. * You will need to pass the name of the uniform as well as the value.
  89115. */
  89116. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89117. /**
  89118. * Lambda to Update a vec4 of float in a uniform buffer.
  89119. * This is dynamic to allow compat with webgl 1 and 2.
  89120. * You will need to pass the name of the uniform as well as the value.
  89121. */
  89122. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89123. /**
  89124. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89125. * This is dynamic to allow compat with webgl 1 and 2.
  89126. * You will need to pass the name of the uniform as well as the value.
  89127. */
  89128. updateMatrix: (name: string, mat: Matrix) => void;
  89129. /**
  89130. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89131. * This is dynamic to allow compat with webgl 1 and 2.
  89132. * You will need to pass the name of the uniform as well as the value.
  89133. */
  89134. updateVector3: (name: string, vector: Vector3) => void;
  89135. /**
  89136. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89137. * This is dynamic to allow compat with webgl 1 and 2.
  89138. * You will need to pass the name of the uniform as well as the value.
  89139. */
  89140. updateVector4: (name: string, vector: Vector4) => void;
  89141. /**
  89142. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89143. * This is dynamic to allow compat with webgl 1 and 2.
  89144. * You will need to pass the name of the uniform as well as the value.
  89145. */
  89146. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89147. /**
  89148. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89149. * This is dynamic to allow compat with webgl 1 and 2.
  89150. * You will need to pass the name of the uniform as well as the value.
  89151. */
  89152. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89153. /**
  89154. * Instantiates a new Uniform buffer objects.
  89155. *
  89156. * Handles blocks of uniform on the GPU.
  89157. *
  89158. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89159. *
  89160. * For more information, please refer to :
  89161. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89162. * @param engine Define the engine the buffer is associated with
  89163. * @param data Define the data contained in the buffer
  89164. * @param dynamic Define if the buffer is updatable
  89165. */
  89166. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89167. /**
  89168. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89169. * or just falling back on setUniformXXX calls.
  89170. */
  89171. readonly useUbo: boolean;
  89172. /**
  89173. * Indicates if the WebGL underlying uniform buffer is in sync
  89174. * with the javascript cache data.
  89175. */
  89176. readonly isSync: boolean;
  89177. /**
  89178. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89179. * Also, a dynamic UniformBuffer will disable cache verification and always
  89180. * update the underlying WebGL uniform buffer to the GPU.
  89181. * @returns if Dynamic, otherwise false
  89182. */
  89183. isDynamic(): boolean;
  89184. /**
  89185. * The data cache on JS side.
  89186. * @returns the underlying data as a float array
  89187. */
  89188. getData(): Float32Array;
  89189. /**
  89190. * The underlying WebGL Uniform buffer.
  89191. * @returns the webgl buffer
  89192. */
  89193. getBuffer(): Nullable<DataBuffer>;
  89194. /**
  89195. * std140 layout specifies how to align data within an UBO structure.
  89196. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89197. * for specs.
  89198. */
  89199. private _fillAlignment;
  89200. /**
  89201. * Adds an uniform in the buffer.
  89202. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89203. * for the layout to be correct !
  89204. * @param name Name of the uniform, as used in the uniform block in the shader.
  89205. * @param size Data size, or data directly.
  89206. */
  89207. addUniform(name: string, size: number | number[]): void;
  89208. /**
  89209. * Adds a Matrix 4x4 to the uniform buffer.
  89210. * @param name Name of the uniform, as used in the uniform block in the shader.
  89211. * @param mat A 4x4 matrix.
  89212. */
  89213. addMatrix(name: string, mat: Matrix): void;
  89214. /**
  89215. * Adds a vec2 to the uniform buffer.
  89216. * @param name Name of the uniform, as used in the uniform block in the shader.
  89217. * @param x Define the x component value of the vec2
  89218. * @param y Define the y component value of the vec2
  89219. */
  89220. addFloat2(name: string, x: number, y: number): void;
  89221. /**
  89222. * Adds a vec3 to the uniform buffer.
  89223. * @param name Name of the uniform, as used in the uniform block in the shader.
  89224. * @param x Define the x component value of the vec3
  89225. * @param y Define the y component value of the vec3
  89226. * @param z Define the z component value of the vec3
  89227. */
  89228. addFloat3(name: string, x: number, y: number, z: number): void;
  89229. /**
  89230. * Adds a vec3 to the uniform buffer.
  89231. * @param name Name of the uniform, as used in the uniform block in the shader.
  89232. * @param color Define the vec3 from a Color
  89233. */
  89234. addColor3(name: string, color: Color3): void;
  89235. /**
  89236. * Adds a vec4 to the uniform buffer.
  89237. * @param name Name of the uniform, as used in the uniform block in the shader.
  89238. * @param color Define the rgb components from a Color
  89239. * @param alpha Define the a component of the vec4
  89240. */
  89241. addColor4(name: string, color: Color3, alpha: number): void;
  89242. /**
  89243. * Adds a vec3 to the uniform buffer.
  89244. * @param name Name of the uniform, as used in the uniform block in the shader.
  89245. * @param vector Define the vec3 components from a Vector
  89246. */
  89247. addVector3(name: string, vector: Vector3): void;
  89248. /**
  89249. * Adds a Matrix 3x3 to the uniform buffer.
  89250. * @param name Name of the uniform, as used in the uniform block in the shader.
  89251. */
  89252. addMatrix3x3(name: string): void;
  89253. /**
  89254. * Adds a Matrix 2x2 to the uniform buffer.
  89255. * @param name Name of the uniform, as used in the uniform block in the shader.
  89256. */
  89257. addMatrix2x2(name: string): void;
  89258. /**
  89259. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89260. */
  89261. create(): void;
  89262. /** @hidden */
  89263. _rebuild(): void;
  89264. /**
  89265. * Updates the WebGL Uniform Buffer on the GPU.
  89266. * If the `dynamic` flag is set to true, no cache comparison is done.
  89267. * Otherwise, the buffer will be updated only if the cache differs.
  89268. */
  89269. update(): void;
  89270. /**
  89271. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89272. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89273. * @param data Define the flattened data
  89274. * @param size Define the size of the data.
  89275. */
  89276. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89277. private _updateMatrix3x3ForUniform;
  89278. private _updateMatrix3x3ForEffect;
  89279. private _updateMatrix2x2ForEffect;
  89280. private _updateMatrix2x2ForUniform;
  89281. private _updateFloatForEffect;
  89282. private _updateFloatForUniform;
  89283. private _updateFloat2ForEffect;
  89284. private _updateFloat2ForUniform;
  89285. private _updateFloat3ForEffect;
  89286. private _updateFloat3ForUniform;
  89287. private _updateFloat4ForEffect;
  89288. private _updateFloat4ForUniform;
  89289. private _updateMatrixForEffect;
  89290. private _updateMatrixForUniform;
  89291. private _updateVector3ForEffect;
  89292. private _updateVector3ForUniform;
  89293. private _updateVector4ForEffect;
  89294. private _updateVector4ForUniform;
  89295. private _updateColor3ForEffect;
  89296. private _updateColor3ForUniform;
  89297. private _updateColor4ForEffect;
  89298. private _updateColor4ForUniform;
  89299. /**
  89300. * Sets a sampler uniform on the effect.
  89301. * @param name Define the name of the sampler.
  89302. * @param texture Define the texture to set in the sampler
  89303. */
  89304. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89305. /**
  89306. * Directly updates the value of the uniform in the cache AND on the GPU.
  89307. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89308. * @param data Define the flattened data
  89309. */
  89310. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89311. /**
  89312. * Binds this uniform buffer to an effect.
  89313. * @param effect Define the effect to bind the buffer to
  89314. * @param name Name of the uniform block in the shader.
  89315. */
  89316. bindToEffect(effect: Effect, name: string): void;
  89317. /**
  89318. * Disposes the uniform buffer.
  89319. */
  89320. dispose(): void;
  89321. }
  89322. }
  89323. declare module BABYLON {
  89324. /**
  89325. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89327. */
  89328. export class Analyser {
  89329. /**
  89330. * Gets or sets the smoothing
  89331. * @ignorenaming
  89332. */
  89333. SMOOTHING: number;
  89334. /**
  89335. * Gets or sets the FFT table size
  89336. * @ignorenaming
  89337. */
  89338. FFT_SIZE: number;
  89339. /**
  89340. * Gets or sets the bar graph amplitude
  89341. * @ignorenaming
  89342. */
  89343. BARGRAPHAMPLITUDE: number;
  89344. /**
  89345. * Gets or sets the position of the debug canvas
  89346. * @ignorenaming
  89347. */
  89348. DEBUGCANVASPOS: {
  89349. x: number;
  89350. y: number;
  89351. };
  89352. /**
  89353. * Gets or sets the debug canvas size
  89354. * @ignorenaming
  89355. */
  89356. DEBUGCANVASSIZE: {
  89357. width: number;
  89358. height: number;
  89359. };
  89360. private _byteFreqs;
  89361. private _byteTime;
  89362. private _floatFreqs;
  89363. private _webAudioAnalyser;
  89364. private _debugCanvas;
  89365. private _debugCanvasContext;
  89366. private _scene;
  89367. private _registerFunc;
  89368. private _audioEngine;
  89369. /**
  89370. * Creates a new analyser
  89371. * @param scene defines hosting scene
  89372. */
  89373. constructor(scene: Scene);
  89374. /**
  89375. * Get the number of data values you will have to play with for the visualization
  89376. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89377. * @returns a number
  89378. */
  89379. getFrequencyBinCount(): number;
  89380. /**
  89381. * Gets the current frequency data as a byte array
  89382. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89383. * @returns a Uint8Array
  89384. */
  89385. getByteFrequencyData(): Uint8Array;
  89386. /**
  89387. * Gets the current waveform as a byte array
  89388. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89389. * @returns a Uint8Array
  89390. */
  89391. getByteTimeDomainData(): Uint8Array;
  89392. /**
  89393. * Gets the current frequency data as a float array
  89394. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89395. * @returns a Float32Array
  89396. */
  89397. getFloatFrequencyData(): Float32Array;
  89398. /**
  89399. * Renders the debug canvas
  89400. */
  89401. drawDebugCanvas(): void;
  89402. /**
  89403. * Stops rendering the debug canvas and removes it
  89404. */
  89405. stopDebugCanvas(): void;
  89406. /**
  89407. * Connects two audio nodes
  89408. * @param inputAudioNode defines first node to connect
  89409. * @param outputAudioNode defines second node to connect
  89410. */
  89411. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89412. /**
  89413. * Releases all associated resources
  89414. */
  89415. dispose(): void;
  89416. }
  89417. }
  89418. declare module BABYLON {
  89419. /**
  89420. * This represents an audio engine and it is responsible
  89421. * to play, synchronize and analyse sounds throughout the application.
  89422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89423. */
  89424. export interface IAudioEngine extends IDisposable {
  89425. /**
  89426. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89427. */
  89428. readonly canUseWebAudio: boolean;
  89429. /**
  89430. * Gets the current AudioContext if available.
  89431. */
  89432. readonly audioContext: Nullable<AudioContext>;
  89433. /**
  89434. * The master gain node defines the global audio volume of your audio engine.
  89435. */
  89436. readonly masterGain: GainNode;
  89437. /**
  89438. * Gets whether or not mp3 are supported by your browser.
  89439. */
  89440. readonly isMP3supported: boolean;
  89441. /**
  89442. * Gets whether or not ogg are supported by your browser.
  89443. */
  89444. readonly isOGGsupported: boolean;
  89445. /**
  89446. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89447. * @ignoreNaming
  89448. */
  89449. WarnedWebAudioUnsupported: boolean;
  89450. /**
  89451. * Defines if the audio engine relies on a custom unlocked button.
  89452. * In this case, the embedded button will not be displayed.
  89453. */
  89454. useCustomUnlockedButton: boolean;
  89455. /**
  89456. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89457. */
  89458. readonly unlocked: boolean;
  89459. /**
  89460. * Event raised when audio has been unlocked on the browser.
  89461. */
  89462. onAudioUnlockedObservable: Observable<AudioEngine>;
  89463. /**
  89464. * Event raised when audio has been locked on the browser.
  89465. */
  89466. onAudioLockedObservable: Observable<AudioEngine>;
  89467. /**
  89468. * Flags the audio engine in Locked state.
  89469. * This happens due to new browser policies preventing audio to autoplay.
  89470. */
  89471. lock(): void;
  89472. /**
  89473. * Unlocks the audio engine once a user action has been done on the dom.
  89474. * This is helpful to resume play once browser policies have been satisfied.
  89475. */
  89476. unlock(): void;
  89477. }
  89478. /**
  89479. * This represents the default audio engine used in babylon.
  89480. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89482. */
  89483. export class AudioEngine implements IAudioEngine {
  89484. private _audioContext;
  89485. private _audioContextInitialized;
  89486. private _muteButton;
  89487. private _hostElement;
  89488. /**
  89489. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89490. */
  89491. canUseWebAudio: boolean;
  89492. /**
  89493. * The master gain node defines the global audio volume of your audio engine.
  89494. */
  89495. masterGain: GainNode;
  89496. /**
  89497. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89498. * @ignoreNaming
  89499. */
  89500. WarnedWebAudioUnsupported: boolean;
  89501. /**
  89502. * Gets whether or not mp3 are supported by your browser.
  89503. */
  89504. isMP3supported: boolean;
  89505. /**
  89506. * Gets whether or not ogg are supported by your browser.
  89507. */
  89508. isOGGsupported: boolean;
  89509. /**
  89510. * Gets whether audio has been unlocked on the device.
  89511. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89512. * a user interaction has happened.
  89513. */
  89514. unlocked: boolean;
  89515. /**
  89516. * Defines if the audio engine relies on a custom unlocked button.
  89517. * In this case, the embedded button will not be displayed.
  89518. */
  89519. useCustomUnlockedButton: boolean;
  89520. /**
  89521. * Event raised when audio has been unlocked on the browser.
  89522. */
  89523. onAudioUnlockedObservable: Observable<AudioEngine>;
  89524. /**
  89525. * Event raised when audio has been locked on the browser.
  89526. */
  89527. onAudioLockedObservable: Observable<AudioEngine>;
  89528. /**
  89529. * Gets the current AudioContext if available.
  89530. */
  89531. readonly audioContext: Nullable<AudioContext>;
  89532. private _connectedAnalyser;
  89533. /**
  89534. * Instantiates a new audio engine.
  89535. *
  89536. * There should be only one per page as some browsers restrict the number
  89537. * of audio contexts you can create.
  89538. * @param hostElement defines the host element where to display the mute icon if necessary
  89539. */
  89540. constructor(hostElement?: Nullable<HTMLElement>);
  89541. /**
  89542. * Flags the audio engine in Locked state.
  89543. * This happens due to new browser policies preventing audio to autoplay.
  89544. */
  89545. lock(): void;
  89546. /**
  89547. * Unlocks the audio engine once a user action has been done on the dom.
  89548. * This is helpful to resume play once browser policies have been satisfied.
  89549. */
  89550. unlock(): void;
  89551. private _resumeAudioContext;
  89552. private _initializeAudioContext;
  89553. private _tryToRun;
  89554. private _triggerRunningState;
  89555. private _triggerSuspendedState;
  89556. private _displayMuteButton;
  89557. private _moveButtonToTopLeft;
  89558. private _onResize;
  89559. private _hideMuteButton;
  89560. /**
  89561. * Destroy and release the resources associated with the audio ccontext.
  89562. */
  89563. dispose(): void;
  89564. /**
  89565. * Gets the global volume sets on the master gain.
  89566. * @returns the global volume if set or -1 otherwise
  89567. */
  89568. getGlobalVolume(): number;
  89569. /**
  89570. * Sets the global volume of your experience (sets on the master gain).
  89571. * @param newVolume Defines the new global volume of the application
  89572. */
  89573. setGlobalVolume(newVolume: number): void;
  89574. /**
  89575. * Connect the audio engine to an audio analyser allowing some amazing
  89576. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89578. * @param analyser The analyser to connect to the engine
  89579. */
  89580. connectToAnalyser(analyser: Analyser): void;
  89581. }
  89582. }
  89583. declare module BABYLON {
  89584. /**
  89585. * Interface used to present a loading screen while loading a scene
  89586. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89587. */
  89588. export interface ILoadingScreen {
  89589. /**
  89590. * Function called to display the loading screen
  89591. */
  89592. displayLoadingUI: () => void;
  89593. /**
  89594. * Function called to hide the loading screen
  89595. */
  89596. hideLoadingUI: () => void;
  89597. /**
  89598. * Gets or sets the color to use for the background
  89599. */
  89600. loadingUIBackgroundColor: string;
  89601. /**
  89602. * Gets or sets the text to display while loading
  89603. */
  89604. loadingUIText: string;
  89605. }
  89606. /**
  89607. * Class used for the default loading screen
  89608. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89609. */
  89610. export class DefaultLoadingScreen implements ILoadingScreen {
  89611. private _renderingCanvas;
  89612. private _loadingText;
  89613. private _loadingDivBackgroundColor;
  89614. private _loadingDiv;
  89615. private _loadingTextDiv;
  89616. /** Gets or sets the logo url to use for the default loading screen */
  89617. static DefaultLogoUrl: string;
  89618. /** Gets or sets the spinner url to use for the default loading screen */
  89619. static DefaultSpinnerUrl: string;
  89620. /**
  89621. * Creates a new default loading screen
  89622. * @param _renderingCanvas defines the canvas used to render the scene
  89623. * @param _loadingText defines the default text to display
  89624. * @param _loadingDivBackgroundColor defines the default background color
  89625. */
  89626. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89627. /**
  89628. * Function called to display the loading screen
  89629. */
  89630. displayLoadingUI(): void;
  89631. /**
  89632. * Function called to hide the loading screen
  89633. */
  89634. hideLoadingUI(): void;
  89635. /**
  89636. * Gets or sets the text to display while loading
  89637. */
  89638. loadingUIText: string;
  89639. /**
  89640. * Gets or sets the color to use for the background
  89641. */
  89642. loadingUIBackgroundColor: string;
  89643. private _resizeLoadingUI;
  89644. }
  89645. }
  89646. declare module BABYLON {
  89647. /** @hidden */
  89648. export class WebGLPipelineContext implements IPipelineContext {
  89649. engine: Engine;
  89650. program: Nullable<WebGLProgram>;
  89651. context?: WebGLRenderingContext;
  89652. vertexShader?: WebGLShader;
  89653. fragmentShader?: WebGLShader;
  89654. isParallelCompiled: boolean;
  89655. onCompiled?: () => void;
  89656. transformFeedback?: WebGLTransformFeedback | null;
  89657. readonly isAsync: boolean;
  89658. readonly isReady: boolean;
  89659. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89660. }
  89661. }
  89662. declare module BABYLON {
  89663. /** @hidden */
  89664. export class WebGLDataBuffer extends DataBuffer {
  89665. private _buffer;
  89666. constructor(resource: WebGLBuffer);
  89667. readonly underlyingResource: any;
  89668. }
  89669. }
  89670. declare module BABYLON {
  89671. /** @hidden */
  89672. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89673. attributeProcessor(attribute: string): string;
  89674. varyingProcessor(varying: string, isFragment: boolean): string;
  89675. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89676. }
  89677. }
  89678. declare module BABYLON {
  89679. /**
  89680. * Settings for finer control over video usage
  89681. */
  89682. export interface VideoTextureSettings {
  89683. /**
  89684. * Applies `autoplay` to video, if specified
  89685. */
  89686. autoPlay?: boolean;
  89687. /**
  89688. * Applies `loop` to video, if specified
  89689. */
  89690. loop?: boolean;
  89691. /**
  89692. * Automatically updates internal texture from video at every frame in the render loop
  89693. */
  89694. autoUpdateTexture: boolean;
  89695. /**
  89696. * Image src displayed during the video loading or until the user interacts with the video.
  89697. */
  89698. poster?: string;
  89699. }
  89700. /**
  89701. * If you want to display a video in your scene, this is the special texture for that.
  89702. * This special texture works similar to other textures, with the exception of a few parameters.
  89703. * @see https://doc.babylonjs.com/how_to/video_texture
  89704. */
  89705. export class VideoTexture extends Texture {
  89706. /**
  89707. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89708. */
  89709. readonly autoUpdateTexture: boolean;
  89710. /**
  89711. * The video instance used by the texture internally
  89712. */
  89713. readonly video: HTMLVideoElement;
  89714. private _onUserActionRequestedObservable;
  89715. /**
  89716. * Event triggerd when a dom action is required by the user to play the video.
  89717. * This happens due to recent changes in browser policies preventing video to auto start.
  89718. */
  89719. readonly onUserActionRequestedObservable: Observable<Texture>;
  89720. private _generateMipMaps;
  89721. private _engine;
  89722. private _stillImageCaptured;
  89723. private _displayingPosterTexture;
  89724. private _settings;
  89725. private _createInternalTextureOnEvent;
  89726. /**
  89727. * Creates a video texture.
  89728. * If you want to display a video in your scene, this is the special texture for that.
  89729. * This special texture works similar to other textures, with the exception of a few parameters.
  89730. * @see https://doc.babylonjs.com/how_to/video_texture
  89731. * @param name optional name, will detect from video source, if not defined
  89732. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89733. * @param scene is obviously the current scene.
  89734. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89735. * @param invertY is false by default but can be used to invert video on Y axis
  89736. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89737. * @param settings allows finer control over video usage
  89738. */
  89739. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89740. private _getName;
  89741. private _getVideo;
  89742. private _createInternalTexture;
  89743. private reset;
  89744. /**
  89745. * @hidden Internal method to initiate `update`.
  89746. */
  89747. _rebuild(): void;
  89748. /**
  89749. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89750. */
  89751. update(): void;
  89752. /**
  89753. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89754. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89755. */
  89756. updateTexture(isVisible: boolean): void;
  89757. protected _updateInternalTexture: () => void;
  89758. /**
  89759. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89760. * @param url New url.
  89761. */
  89762. updateURL(url: string): void;
  89763. /**
  89764. * Dispose the texture and release its associated resources.
  89765. */
  89766. dispose(): void;
  89767. /**
  89768. * Creates a video texture straight from a stream.
  89769. * @param scene Define the scene the texture should be created in
  89770. * @param stream Define the stream the texture should be created from
  89771. * @returns The created video texture as a promise
  89772. */
  89773. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89774. /**
  89775. * Creates a video texture straight from your WebCam video feed.
  89776. * @param scene Define the scene the texture should be created in
  89777. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89778. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89779. * @returns The created video texture as a promise
  89780. */
  89781. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89782. minWidth: number;
  89783. maxWidth: number;
  89784. minHeight: number;
  89785. maxHeight: number;
  89786. deviceId: string;
  89787. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89788. /**
  89789. * Creates a video texture straight from your WebCam video feed.
  89790. * @param scene Define the scene the texture should be created in
  89791. * @param onReady Define a callback to triggered once the texture will be ready
  89792. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89793. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89794. */
  89795. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89796. minWidth: number;
  89797. maxWidth: number;
  89798. minHeight: number;
  89799. maxHeight: number;
  89800. deviceId: string;
  89801. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89802. }
  89803. }
  89804. declare module BABYLON {
  89805. /**
  89806. * Interface for attribute information associated with buffer instanciation
  89807. */
  89808. export class InstancingAttributeInfo {
  89809. /**
  89810. * Index/offset of the attribute in the vertex shader
  89811. */
  89812. index: number;
  89813. /**
  89814. * size of the attribute, 1, 2, 3 or 4
  89815. */
  89816. attributeSize: number;
  89817. /**
  89818. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89819. * default is FLOAT
  89820. */
  89821. attribyteType: number;
  89822. /**
  89823. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89824. */
  89825. normalized: boolean;
  89826. /**
  89827. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89828. */
  89829. offset: number;
  89830. /**
  89831. * Name of the GLSL attribute, for debugging purpose only
  89832. */
  89833. attributeName: string;
  89834. }
  89835. /**
  89836. * Define options used to create a depth texture
  89837. */
  89838. export class DepthTextureCreationOptions {
  89839. /** Specifies whether or not a stencil should be allocated in the texture */
  89840. generateStencil?: boolean;
  89841. /** Specifies whether or not bilinear filtering is enable on the texture */
  89842. bilinearFiltering?: boolean;
  89843. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89844. comparisonFunction?: number;
  89845. /** Specifies if the created texture is a cube texture */
  89846. isCube?: boolean;
  89847. }
  89848. /**
  89849. * Class used to describe the capabilities of the engine relatively to the current browser
  89850. */
  89851. export class EngineCapabilities {
  89852. /** Maximum textures units per fragment shader */
  89853. maxTexturesImageUnits: number;
  89854. /** Maximum texture units per vertex shader */
  89855. maxVertexTextureImageUnits: number;
  89856. /** Maximum textures units in the entire pipeline */
  89857. maxCombinedTexturesImageUnits: number;
  89858. /** Maximum texture size */
  89859. maxTextureSize: number;
  89860. /** Maximum cube texture size */
  89861. maxCubemapTextureSize: number;
  89862. /** Maximum render texture size */
  89863. maxRenderTextureSize: number;
  89864. /** Maximum number of vertex attributes */
  89865. maxVertexAttribs: number;
  89866. /** Maximum number of varyings */
  89867. maxVaryingVectors: number;
  89868. /** Maximum number of uniforms per vertex shader */
  89869. maxVertexUniformVectors: number;
  89870. /** Maximum number of uniforms per fragment shader */
  89871. maxFragmentUniformVectors: number;
  89872. /** Defines if standard derivates (dx/dy) are supported */
  89873. standardDerivatives: boolean;
  89874. /** Defines if s3tc texture compression is supported */
  89875. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89876. /** Defines if pvrtc texture compression is supported */
  89877. pvrtc: any;
  89878. /** Defines if etc1 texture compression is supported */
  89879. etc1: any;
  89880. /** Defines if etc2 texture compression is supported */
  89881. etc2: any;
  89882. /** Defines if astc texture compression is supported */
  89883. astc: any;
  89884. /** Defines if float textures are supported */
  89885. textureFloat: boolean;
  89886. /** Defines if vertex array objects are supported */
  89887. vertexArrayObject: boolean;
  89888. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89889. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89890. /** Gets the maximum level of anisotropy supported */
  89891. maxAnisotropy: number;
  89892. /** Defines if instancing is supported */
  89893. instancedArrays: boolean;
  89894. /** Defines if 32 bits indices are supported */
  89895. uintIndices: boolean;
  89896. /** Defines if high precision shaders are supported */
  89897. highPrecisionShaderSupported: boolean;
  89898. /** Defines if depth reading in the fragment shader is supported */
  89899. fragmentDepthSupported: boolean;
  89900. /** Defines if float texture linear filtering is supported*/
  89901. textureFloatLinearFiltering: boolean;
  89902. /** Defines if rendering to float textures is supported */
  89903. textureFloatRender: boolean;
  89904. /** Defines if half float textures are supported*/
  89905. textureHalfFloat: boolean;
  89906. /** Defines if half float texture linear filtering is supported*/
  89907. textureHalfFloatLinearFiltering: boolean;
  89908. /** Defines if rendering to half float textures is supported */
  89909. textureHalfFloatRender: boolean;
  89910. /** Defines if textureLOD shader command is supported */
  89911. textureLOD: boolean;
  89912. /** Defines if draw buffers extension is supported */
  89913. drawBuffersExtension: boolean;
  89914. /** Defines if depth textures are supported */
  89915. depthTextureExtension: boolean;
  89916. /** Defines if float color buffer are supported */
  89917. colorBufferFloat: boolean;
  89918. /** Gets disjoint timer query extension (null if not supported) */
  89919. timerQuery: EXT_disjoint_timer_query;
  89920. /** Defines if timestamp can be used with timer query */
  89921. canUseTimestampForTimerQuery: boolean;
  89922. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89923. multiview: any;
  89924. /** Function used to let the system compiles shaders in background */
  89925. parallelShaderCompile: {
  89926. COMPLETION_STATUS_KHR: number;
  89927. };
  89928. }
  89929. /** Interface defining initialization parameters for Engine class */
  89930. export interface EngineOptions extends WebGLContextAttributes {
  89931. /**
  89932. * Defines if the engine should no exceed a specified device ratio
  89933. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  89934. */
  89935. limitDeviceRatio?: number;
  89936. /**
  89937. * Defines if webvr should be enabled automatically
  89938. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89939. */
  89940. autoEnableWebVR?: boolean;
  89941. /**
  89942. * Defines if webgl2 should be turned off even if supported
  89943. * @see http://doc.babylonjs.com/features/webgl2
  89944. */
  89945. disableWebGL2Support?: boolean;
  89946. /**
  89947. * Defines if webaudio should be initialized as well
  89948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89949. */
  89950. audioEngine?: boolean;
  89951. /**
  89952. * Defines if animations should run using a deterministic lock step
  89953. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89954. */
  89955. deterministicLockstep?: boolean;
  89956. /** Defines the maximum steps to use with deterministic lock step mode */
  89957. lockstepMaxSteps?: number;
  89958. /**
  89959. * Defines that engine should ignore context lost events
  89960. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  89961. */
  89962. doNotHandleContextLost?: boolean;
  89963. /**
  89964. * Defines that engine should ignore modifying touch action attribute and style
  89965. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  89966. */
  89967. doNotHandleTouchAction?: boolean;
  89968. /**
  89969. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  89970. */
  89971. useHighPrecisionFloats?: boolean;
  89972. }
  89973. /**
  89974. * Defines the interface used by display changed events
  89975. */
  89976. export interface IDisplayChangedEventArgs {
  89977. /** Gets the vrDisplay object (if any) */
  89978. vrDisplay: Nullable<any>;
  89979. /** Gets a boolean indicating if webVR is supported */
  89980. vrSupported: boolean;
  89981. }
  89982. /**
  89983. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  89984. */
  89985. export class Engine {
  89986. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  89987. static ExceptionList: ({
  89988. key: string;
  89989. capture: string;
  89990. captureConstraint: number;
  89991. targets: string[];
  89992. } | {
  89993. key: string;
  89994. capture: null;
  89995. captureConstraint: null;
  89996. targets: string[];
  89997. })[];
  89998. /** Gets the list of created engines */
  89999. static readonly Instances: Engine[];
  90000. /**
  90001. * Gets the latest created engine
  90002. */
  90003. static readonly LastCreatedEngine: Nullable<Engine>;
  90004. /**
  90005. * Gets the latest created scene
  90006. */
  90007. static readonly LastCreatedScene: Nullable<Scene>;
  90008. /**
  90009. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90010. * @param flag defines which part of the materials must be marked as dirty
  90011. * @param predicate defines a predicate used to filter which materials should be affected
  90012. */
  90013. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90014. /** @hidden */
  90015. static _TextureLoaders: IInternalTextureLoader[];
  90016. /** Defines that alpha blending is disabled */
  90017. static readonly ALPHA_DISABLE: number;
  90018. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90019. static readonly ALPHA_ADD: number;
  90020. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90021. static readonly ALPHA_COMBINE: number;
  90022. /** Defines that alpha blending to DEST - SRC * DEST */
  90023. static readonly ALPHA_SUBTRACT: number;
  90024. /** Defines that alpha blending to SRC * DEST */
  90025. static readonly ALPHA_MULTIPLY: number;
  90026. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90027. static readonly ALPHA_MAXIMIZED: number;
  90028. /** Defines that alpha blending to SRC + DEST */
  90029. static readonly ALPHA_ONEONE: number;
  90030. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90031. static readonly ALPHA_PREMULTIPLIED: number;
  90032. /**
  90033. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90034. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90035. */
  90036. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90037. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90038. static readonly ALPHA_INTERPOLATE: number;
  90039. /**
  90040. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90041. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90042. */
  90043. static readonly ALPHA_SCREENMODE: number;
  90044. /** Defines that the ressource is not delayed*/
  90045. static readonly DELAYLOADSTATE_NONE: number;
  90046. /** Defines that the ressource was successfully delay loaded */
  90047. static readonly DELAYLOADSTATE_LOADED: number;
  90048. /** Defines that the ressource is currently delay loading */
  90049. static readonly DELAYLOADSTATE_LOADING: number;
  90050. /** Defines that the ressource is delayed and has not started loading */
  90051. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90052. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90053. static readonly NEVER: number;
  90054. /** 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 */
  90055. static readonly ALWAYS: number;
  90056. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90057. static readonly LESS: number;
  90058. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90059. static readonly EQUAL: number;
  90060. /** 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 */
  90061. static readonly LEQUAL: number;
  90062. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90063. static readonly GREATER: number;
  90064. /** 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 */
  90065. static readonly GEQUAL: number;
  90066. /** 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 */
  90067. static readonly NOTEQUAL: number;
  90068. /** Passed to stencilOperation to specify that stencil value must be kept */
  90069. static readonly KEEP: number;
  90070. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90071. static readonly REPLACE: number;
  90072. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90073. static readonly INCR: number;
  90074. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90075. static readonly DECR: number;
  90076. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90077. static readonly INVERT: number;
  90078. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90079. static readonly INCR_WRAP: number;
  90080. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90081. static readonly DECR_WRAP: number;
  90082. /** Texture is not repeating outside of 0..1 UVs */
  90083. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90084. /** Texture is repeating outside of 0..1 UVs */
  90085. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90086. /** Texture is repeating and mirrored */
  90087. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90088. /** ALPHA */
  90089. static readonly TEXTUREFORMAT_ALPHA: number;
  90090. /** LUMINANCE */
  90091. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90092. /** LUMINANCE_ALPHA */
  90093. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90094. /** RGB */
  90095. static readonly TEXTUREFORMAT_RGB: number;
  90096. /** RGBA */
  90097. static readonly TEXTUREFORMAT_RGBA: number;
  90098. /** RED */
  90099. static readonly TEXTUREFORMAT_RED: number;
  90100. /** RED (2nd reference) */
  90101. static readonly TEXTUREFORMAT_R: number;
  90102. /** RG */
  90103. static readonly TEXTUREFORMAT_RG: number;
  90104. /** RED_INTEGER */
  90105. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90106. /** RED_INTEGER (2nd reference) */
  90107. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90108. /** RG_INTEGER */
  90109. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90110. /** RGB_INTEGER */
  90111. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90112. /** RGBA_INTEGER */
  90113. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90114. /** UNSIGNED_BYTE */
  90115. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90116. /** UNSIGNED_BYTE (2nd reference) */
  90117. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90118. /** FLOAT */
  90119. static readonly TEXTURETYPE_FLOAT: number;
  90120. /** HALF_FLOAT */
  90121. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90122. /** BYTE */
  90123. static readonly TEXTURETYPE_BYTE: number;
  90124. /** SHORT */
  90125. static readonly TEXTURETYPE_SHORT: number;
  90126. /** UNSIGNED_SHORT */
  90127. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90128. /** INT */
  90129. static readonly TEXTURETYPE_INT: number;
  90130. /** UNSIGNED_INT */
  90131. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90132. /** UNSIGNED_SHORT_4_4_4_4 */
  90133. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90134. /** UNSIGNED_SHORT_5_5_5_1 */
  90135. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90136. /** UNSIGNED_SHORT_5_6_5 */
  90137. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90138. /** UNSIGNED_INT_2_10_10_10_REV */
  90139. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90140. /** UNSIGNED_INT_24_8 */
  90141. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90142. /** UNSIGNED_INT_10F_11F_11F_REV */
  90143. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90144. /** UNSIGNED_INT_5_9_9_9_REV */
  90145. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90146. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90147. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90148. /** nearest is mag = nearest and min = nearest and mip = linear */
  90149. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90150. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90151. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90152. /** Trilinear is mag = linear and min = linear and mip = linear */
  90153. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90154. /** nearest is mag = nearest and min = nearest and mip = linear */
  90155. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90156. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90157. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90158. /** Trilinear is mag = linear and min = linear and mip = linear */
  90159. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90160. /** mag = nearest and min = nearest and mip = nearest */
  90161. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90162. /** mag = nearest and min = linear and mip = nearest */
  90163. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90164. /** mag = nearest and min = linear and mip = linear */
  90165. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90166. /** mag = nearest and min = linear and mip = none */
  90167. static readonly TEXTURE_NEAREST_LINEAR: number;
  90168. /** mag = nearest and min = nearest and mip = none */
  90169. static readonly TEXTURE_NEAREST_NEAREST: number;
  90170. /** mag = linear and min = nearest and mip = nearest */
  90171. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90172. /** mag = linear and min = nearest and mip = linear */
  90173. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90174. /** mag = linear and min = linear and mip = none */
  90175. static readonly TEXTURE_LINEAR_LINEAR: number;
  90176. /** mag = linear and min = nearest and mip = none */
  90177. static readonly TEXTURE_LINEAR_NEAREST: number;
  90178. /** Explicit coordinates mode */
  90179. static readonly TEXTURE_EXPLICIT_MODE: number;
  90180. /** Spherical coordinates mode */
  90181. static readonly TEXTURE_SPHERICAL_MODE: number;
  90182. /** Planar coordinates mode */
  90183. static readonly TEXTURE_PLANAR_MODE: number;
  90184. /** Cubic coordinates mode */
  90185. static readonly TEXTURE_CUBIC_MODE: number;
  90186. /** Projection coordinates mode */
  90187. static readonly TEXTURE_PROJECTION_MODE: number;
  90188. /** Skybox coordinates mode */
  90189. static readonly TEXTURE_SKYBOX_MODE: number;
  90190. /** Inverse Cubic coordinates mode */
  90191. static readonly TEXTURE_INVCUBIC_MODE: number;
  90192. /** Equirectangular coordinates mode */
  90193. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90194. /** Equirectangular Fixed coordinates mode */
  90195. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90196. /** Equirectangular Fixed Mirrored coordinates mode */
  90197. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90198. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90199. static readonly SCALEMODE_FLOOR: number;
  90200. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90201. static readonly SCALEMODE_NEAREST: number;
  90202. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90203. static readonly SCALEMODE_CEILING: number;
  90204. /**
  90205. * Returns the current npm package of the sdk
  90206. */
  90207. static readonly NpmPackage: string;
  90208. /**
  90209. * Returns the current version of the framework
  90210. */
  90211. static readonly Version: string;
  90212. /**
  90213. * Returns a string describing the current engine
  90214. */
  90215. readonly description: string;
  90216. /**
  90217. * Gets or sets the epsilon value used by collision engine
  90218. */
  90219. static CollisionsEpsilon: number;
  90220. /**
  90221. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90222. */
  90223. static ShadersRepository: string;
  90224. /**
  90225. * Method called to create the default loading screen.
  90226. * This can be overriden in your own app.
  90227. * @param canvas The rendering canvas element
  90228. * @returns The loading screen
  90229. */
  90230. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90231. /**
  90232. * Method called to create the default rescale post process on each engine.
  90233. */
  90234. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90235. /** @hidden */
  90236. _shaderProcessor: IShaderProcessor;
  90237. /**
  90238. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90239. */
  90240. forcePOTTextures: boolean;
  90241. /**
  90242. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90243. */
  90244. isFullscreen: boolean;
  90245. /**
  90246. * Gets a boolean indicating if the pointer is currently locked
  90247. */
  90248. isPointerLock: boolean;
  90249. /**
  90250. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90251. */
  90252. cullBackFaces: boolean;
  90253. /**
  90254. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90255. */
  90256. renderEvenInBackground: boolean;
  90257. /**
  90258. * Gets or sets a boolean indicating that cache can be kept between frames
  90259. */
  90260. preventCacheWipeBetweenFrames: boolean;
  90261. /**
  90262. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90263. **/
  90264. enableOfflineSupport: boolean;
  90265. /**
  90266. * 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)
  90267. **/
  90268. disableManifestCheck: boolean;
  90269. /**
  90270. * Gets the list of created scenes
  90271. */
  90272. scenes: Scene[];
  90273. /**
  90274. * Event raised when a new scene is created
  90275. */
  90276. onNewSceneAddedObservable: Observable<Scene>;
  90277. /**
  90278. * Gets the list of created postprocesses
  90279. */
  90280. postProcesses: PostProcess[];
  90281. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90282. validateShaderPrograms: boolean;
  90283. /**
  90284. * Observable event triggered each time the rendering canvas is resized
  90285. */
  90286. onResizeObservable: Observable<Engine>;
  90287. /**
  90288. * Observable event triggered each time the canvas loses focus
  90289. */
  90290. onCanvasBlurObservable: Observable<Engine>;
  90291. /**
  90292. * Observable event triggered each time the canvas gains focus
  90293. */
  90294. onCanvasFocusObservable: Observable<Engine>;
  90295. /**
  90296. * Observable event triggered each time the canvas receives pointerout event
  90297. */
  90298. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90299. /**
  90300. * Observable event triggered before each texture is initialized
  90301. */
  90302. onBeforeTextureInitObservable: Observable<Texture>;
  90303. /**
  90304. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90305. */
  90306. disableUniformBuffers: boolean;
  90307. /** @hidden */
  90308. _uniformBuffers: UniformBuffer[];
  90309. /**
  90310. * Gets a boolean indicating that the engine supports uniform buffers
  90311. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90312. */
  90313. readonly supportsUniformBuffers: boolean;
  90314. /**
  90315. * Observable raised when the engine begins a new frame
  90316. */
  90317. onBeginFrameObservable: Observable<Engine>;
  90318. /**
  90319. * If set, will be used to request the next animation frame for the render loop
  90320. */
  90321. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90322. /**
  90323. * Observable raised when the engine ends the current frame
  90324. */
  90325. onEndFrameObservable: Observable<Engine>;
  90326. /**
  90327. * Observable raised when the engine is about to compile a shader
  90328. */
  90329. onBeforeShaderCompilationObservable: Observable<Engine>;
  90330. /**
  90331. * Observable raised when the engine has jsut compiled a shader
  90332. */
  90333. onAfterShaderCompilationObservable: Observable<Engine>;
  90334. /** @hidden */
  90335. _gl: WebGLRenderingContext;
  90336. private _renderingCanvas;
  90337. private _windowIsBackground;
  90338. private _webGLVersion;
  90339. protected _highPrecisionShadersAllowed: boolean;
  90340. /** @hidden */
  90341. readonly _shouldUseHighPrecisionShader: boolean;
  90342. /**
  90343. * Gets a boolean indicating that only power of 2 textures are supported
  90344. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90345. */
  90346. readonly needPOTTextures: boolean;
  90347. /** @hidden */
  90348. _badOS: boolean;
  90349. /** @hidden */
  90350. _badDesktopOS: boolean;
  90351. /**
  90352. * Gets the audio engine
  90353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90354. * @ignorenaming
  90355. */
  90356. static audioEngine: IAudioEngine;
  90357. /**
  90358. * Default AudioEngine factory responsible of creating the Audio Engine.
  90359. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90360. */
  90361. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90362. /**
  90363. * Default offline support factory responsible of creating a tool used to store data locally.
  90364. * By default, this will create a Database object if the workload has been embedded.
  90365. */
  90366. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90367. private _onFocus;
  90368. private _onBlur;
  90369. private _onCanvasPointerOut;
  90370. private _onCanvasBlur;
  90371. private _onCanvasFocus;
  90372. private _onFullscreenChange;
  90373. private _onPointerLockChange;
  90374. private _hardwareScalingLevel;
  90375. /** @hidden */
  90376. _caps: EngineCapabilities;
  90377. private _pointerLockRequested;
  90378. private _isStencilEnable;
  90379. private _colorWrite;
  90380. private _loadingScreen;
  90381. /** @hidden */
  90382. _drawCalls: PerfCounter;
  90383. private _glVersion;
  90384. private _glRenderer;
  90385. private _glVendor;
  90386. private _videoTextureSupported;
  90387. private _renderingQueueLaunched;
  90388. private _activeRenderLoops;
  90389. private _deterministicLockstep;
  90390. private _lockstepMaxSteps;
  90391. /**
  90392. * Observable signaled when a context lost event is raised
  90393. */
  90394. onContextLostObservable: Observable<Engine>;
  90395. /**
  90396. * Observable signaled when a context restored event is raised
  90397. */
  90398. onContextRestoredObservable: Observable<Engine>;
  90399. private _onContextLost;
  90400. private _onContextRestored;
  90401. private _contextWasLost;
  90402. /** @hidden */
  90403. _doNotHandleContextLost: boolean;
  90404. /**
  90405. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90407. */
  90408. doNotHandleContextLost: boolean;
  90409. private _performanceMonitor;
  90410. private _fps;
  90411. private _deltaTime;
  90412. /**
  90413. * Turn this value on if you want to pause FPS computation when in background
  90414. */
  90415. disablePerformanceMonitorInBackground: boolean;
  90416. /**
  90417. * Gets the performance monitor attached to this engine
  90418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90419. */
  90420. readonly performanceMonitor: PerformanceMonitor;
  90421. /**
  90422. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90423. */
  90424. disableVertexArrayObjects: boolean;
  90425. /** @hidden */
  90426. protected _depthCullingState: _DepthCullingState;
  90427. /** @hidden */
  90428. protected _stencilState: _StencilState;
  90429. /** @hidden */
  90430. protected _alphaState: _AlphaState;
  90431. /** @hidden */
  90432. protected _alphaMode: number;
  90433. /** @hidden */
  90434. _internalTexturesCache: InternalTexture[];
  90435. /** @hidden */
  90436. protected _activeChannel: number;
  90437. private _currentTextureChannel;
  90438. /** @hidden */
  90439. protected _boundTexturesCache: {
  90440. [key: string]: Nullable<InternalTexture>;
  90441. };
  90442. /** @hidden */
  90443. protected _currentEffect: Nullable<Effect>;
  90444. /** @hidden */
  90445. protected _currentProgram: Nullable<WebGLProgram>;
  90446. private _compiledEffects;
  90447. private _vertexAttribArraysEnabled;
  90448. /** @hidden */
  90449. protected _cachedViewport: Nullable<Viewport>;
  90450. private _cachedVertexArrayObject;
  90451. /** @hidden */
  90452. protected _cachedVertexBuffers: any;
  90453. /** @hidden */
  90454. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90455. /** @hidden */
  90456. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90457. /** @hidden */
  90458. _currentRenderTarget: Nullable<InternalTexture>;
  90459. private _uintIndicesCurrentlySet;
  90460. private _currentBoundBuffer;
  90461. /** @hidden */
  90462. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90463. private _currentBufferPointers;
  90464. private _currentInstanceLocations;
  90465. private _currentInstanceBuffers;
  90466. private _textureUnits;
  90467. /** @hidden */
  90468. _workingCanvas: Nullable<HTMLCanvasElement>;
  90469. /** @hidden */
  90470. _workingContext: Nullable<CanvasRenderingContext2D>;
  90471. private _rescalePostProcess;
  90472. private _dummyFramebuffer;
  90473. private _externalData;
  90474. /** @hidden */
  90475. _bindedRenderFunction: any;
  90476. private _vaoRecordInProgress;
  90477. private _mustWipeVertexAttributes;
  90478. private _emptyTexture;
  90479. private _emptyCubeTexture;
  90480. private _emptyTexture3D;
  90481. /** @hidden */
  90482. _frameHandler: number;
  90483. private _nextFreeTextureSlots;
  90484. private _maxSimultaneousTextures;
  90485. private _activeRequests;
  90486. private _texturesSupported;
  90487. /** @hidden */
  90488. _textureFormatInUse: Nullable<string>;
  90489. /**
  90490. * Gets the list of texture formats supported
  90491. */
  90492. readonly texturesSupported: Array<string>;
  90493. /**
  90494. * Gets the list of texture formats in use
  90495. */
  90496. readonly textureFormatInUse: Nullable<string>;
  90497. /**
  90498. * Gets the current viewport
  90499. */
  90500. readonly currentViewport: Nullable<Viewport>;
  90501. /**
  90502. * Gets the default empty texture
  90503. */
  90504. readonly emptyTexture: InternalTexture;
  90505. /**
  90506. * Gets the default empty 3D texture
  90507. */
  90508. readonly emptyTexture3D: InternalTexture;
  90509. /**
  90510. * Gets the default empty cube texture
  90511. */
  90512. readonly emptyCubeTexture: InternalTexture;
  90513. /**
  90514. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90515. */
  90516. readonly premultipliedAlpha: boolean;
  90517. /**
  90518. * Creates a new engine
  90519. * @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
  90520. * @param antialias defines enable antialiasing (default: false)
  90521. * @param options defines further options to be sent to the getContext() function
  90522. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90523. */
  90524. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90525. /**
  90526. * Initializes a webVR display and starts listening to display change events
  90527. * The onVRDisplayChangedObservable will be notified upon these changes
  90528. * @returns The onVRDisplayChangedObservable
  90529. */
  90530. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90531. /** @hidden */
  90532. _prepareVRComponent(): void;
  90533. /** @hidden */
  90534. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90535. /** @hidden */
  90536. _submitVRFrame(): void;
  90537. /**
  90538. * Call this function to leave webVR mode
  90539. * Will do nothing if webVR is not supported or if there is no webVR device
  90540. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90541. */
  90542. disableVR(): void;
  90543. /**
  90544. * Gets a boolean indicating that the system is in VR mode and is presenting
  90545. * @returns true if VR mode is engaged
  90546. */
  90547. isVRPresenting(): boolean;
  90548. /** @hidden */
  90549. _requestVRFrame(): void;
  90550. private _disableTouchAction;
  90551. private _rebuildInternalTextures;
  90552. private _rebuildEffects;
  90553. /**
  90554. * Gets a boolean indicating if all created effects are ready
  90555. * @returns true if all effects are ready
  90556. */
  90557. areAllEffectsReady(): boolean;
  90558. private _rebuildBuffers;
  90559. private _initGLContext;
  90560. /**
  90561. * Gets version of the current webGL context
  90562. */
  90563. readonly webGLVersion: number;
  90564. /**
  90565. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90566. */
  90567. readonly isStencilEnable: boolean;
  90568. /** @hidden */
  90569. _prepareWorkingCanvas(): void;
  90570. /**
  90571. * Reset the texture cache to empty state
  90572. */
  90573. resetTextureCache(): void;
  90574. /**
  90575. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90576. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90577. * @returns true if engine is in deterministic lock step mode
  90578. */
  90579. isDeterministicLockStep(): boolean;
  90580. /**
  90581. * Gets the max steps when engine is running in deterministic lock step
  90582. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90583. * @returns the max steps
  90584. */
  90585. getLockstepMaxSteps(): number;
  90586. /**
  90587. * Gets an object containing information about the current webGL context
  90588. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90589. */
  90590. getGlInfo(): {
  90591. vendor: string;
  90592. renderer: string;
  90593. version: string;
  90594. };
  90595. /**
  90596. * Gets current aspect ratio
  90597. * @param camera defines the camera to use to get the aspect ratio
  90598. * @param useScreen defines if screen size must be used (or the current render target if any)
  90599. * @returns a number defining the aspect ratio
  90600. */
  90601. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90602. /**
  90603. * Gets current screen aspect ratio
  90604. * @returns a number defining the aspect ratio
  90605. */
  90606. getScreenAspectRatio(): number;
  90607. /**
  90608. * Gets the current render width
  90609. * @param useScreen defines if screen size must be used (or the current render target if any)
  90610. * @returns a number defining the current render width
  90611. */
  90612. getRenderWidth(useScreen?: boolean): number;
  90613. /**
  90614. * Gets the current render height
  90615. * @param useScreen defines if screen size must be used (or the current render target if any)
  90616. * @returns a number defining the current render height
  90617. */
  90618. getRenderHeight(useScreen?: boolean): number;
  90619. /**
  90620. * Gets the HTML canvas attached with the current webGL context
  90621. * @returns a HTML canvas
  90622. */
  90623. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90624. /**
  90625. * Gets the client rect of the HTML canvas attached with the current webGL context
  90626. * @returns a client rectanglee
  90627. */
  90628. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90629. /**
  90630. * Defines the hardware scaling level.
  90631. * By default the hardware scaling level is computed from the window device ratio.
  90632. * 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.
  90633. * @param level defines the level to use
  90634. */
  90635. setHardwareScalingLevel(level: number): void;
  90636. /**
  90637. * Gets the current hardware scaling level.
  90638. * By default the hardware scaling level is computed from the window device ratio.
  90639. * 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.
  90640. * @returns a number indicating the current hardware scaling level
  90641. */
  90642. getHardwareScalingLevel(): number;
  90643. /**
  90644. * Gets the list of loaded textures
  90645. * @returns an array containing all loaded textures
  90646. */
  90647. getLoadedTexturesCache(): InternalTexture[];
  90648. /**
  90649. * Gets the object containing all engine capabilities
  90650. * @returns the EngineCapabilities object
  90651. */
  90652. getCaps(): EngineCapabilities;
  90653. /**
  90654. * Gets the current depth function
  90655. * @returns a number defining the depth function
  90656. */
  90657. getDepthFunction(): Nullable<number>;
  90658. /**
  90659. * Sets the current depth function
  90660. * @param depthFunc defines the function to use
  90661. */
  90662. setDepthFunction(depthFunc: number): void;
  90663. /**
  90664. * Sets the current depth function to GREATER
  90665. */
  90666. setDepthFunctionToGreater(): void;
  90667. /**
  90668. * Sets the current depth function to GEQUAL
  90669. */
  90670. setDepthFunctionToGreaterOrEqual(): void;
  90671. /**
  90672. * Sets the current depth function to LESS
  90673. */
  90674. setDepthFunctionToLess(): void;
  90675. private _cachedStencilBuffer;
  90676. private _cachedStencilFunction;
  90677. private _cachedStencilMask;
  90678. private _cachedStencilOperationPass;
  90679. private _cachedStencilOperationFail;
  90680. private _cachedStencilOperationDepthFail;
  90681. private _cachedStencilReference;
  90682. /**
  90683. * Caches the the state of the stencil buffer
  90684. */
  90685. cacheStencilState(): void;
  90686. /**
  90687. * Restores the state of the stencil buffer
  90688. */
  90689. restoreStencilState(): void;
  90690. /**
  90691. * Sets the current depth function to LEQUAL
  90692. */
  90693. setDepthFunctionToLessOrEqual(): void;
  90694. /**
  90695. * Gets a boolean indicating if stencil buffer is enabled
  90696. * @returns the current stencil buffer state
  90697. */
  90698. getStencilBuffer(): boolean;
  90699. /**
  90700. * Enable or disable the stencil buffer
  90701. * @param enable defines if the stencil buffer must be enabled or disabled
  90702. */
  90703. setStencilBuffer(enable: boolean): void;
  90704. /**
  90705. * Gets the current stencil mask
  90706. * @returns a number defining the new stencil mask to use
  90707. */
  90708. getStencilMask(): number;
  90709. /**
  90710. * Sets the current stencil mask
  90711. * @param mask defines the new stencil mask to use
  90712. */
  90713. setStencilMask(mask: number): void;
  90714. /**
  90715. * Gets the current stencil function
  90716. * @returns a number defining the stencil function to use
  90717. */
  90718. getStencilFunction(): number;
  90719. /**
  90720. * Gets the current stencil reference value
  90721. * @returns a number defining the stencil reference value to use
  90722. */
  90723. getStencilFunctionReference(): number;
  90724. /**
  90725. * Gets the current stencil mask
  90726. * @returns a number defining the stencil mask to use
  90727. */
  90728. getStencilFunctionMask(): number;
  90729. /**
  90730. * Sets the current stencil function
  90731. * @param stencilFunc defines the new stencil function to use
  90732. */
  90733. setStencilFunction(stencilFunc: number): void;
  90734. /**
  90735. * Sets the current stencil reference
  90736. * @param reference defines the new stencil reference to use
  90737. */
  90738. setStencilFunctionReference(reference: number): void;
  90739. /**
  90740. * Sets the current stencil mask
  90741. * @param mask defines the new stencil mask to use
  90742. */
  90743. setStencilFunctionMask(mask: number): void;
  90744. /**
  90745. * Gets the current stencil operation when stencil fails
  90746. * @returns a number defining stencil operation to use when stencil fails
  90747. */
  90748. getStencilOperationFail(): number;
  90749. /**
  90750. * Gets the current stencil operation when depth fails
  90751. * @returns a number defining stencil operation to use when depth fails
  90752. */
  90753. getStencilOperationDepthFail(): number;
  90754. /**
  90755. * Gets the current stencil operation when stencil passes
  90756. * @returns a number defining stencil operation to use when stencil passes
  90757. */
  90758. getStencilOperationPass(): number;
  90759. /**
  90760. * Sets the stencil operation to use when stencil fails
  90761. * @param operation defines the stencil operation to use when stencil fails
  90762. */
  90763. setStencilOperationFail(operation: number): void;
  90764. /**
  90765. * Sets the stencil operation to use when depth fails
  90766. * @param operation defines the stencil operation to use when depth fails
  90767. */
  90768. setStencilOperationDepthFail(operation: number): void;
  90769. /**
  90770. * Sets the stencil operation to use when stencil passes
  90771. * @param operation defines the stencil operation to use when stencil passes
  90772. */
  90773. setStencilOperationPass(operation: number): void;
  90774. /**
  90775. * Sets a boolean indicating if the dithering state is enabled or disabled
  90776. * @param value defines the dithering state
  90777. */
  90778. setDitheringState(value: boolean): void;
  90779. /**
  90780. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90781. * @param value defines the rasterizer state
  90782. */
  90783. setRasterizerState(value: boolean): void;
  90784. /**
  90785. * stop executing a render loop function and remove it from the execution array
  90786. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90787. */
  90788. stopRenderLoop(renderFunction?: () => void): void;
  90789. /** @hidden */
  90790. _renderLoop(): void;
  90791. /**
  90792. * Register and execute a render loop. The engine can have more than one render function
  90793. * @param renderFunction defines the function to continuously execute
  90794. */
  90795. runRenderLoop(renderFunction: () => void): void;
  90796. /**
  90797. * Toggle full screen mode
  90798. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90799. */
  90800. switchFullscreen(requestPointerLock: boolean): void;
  90801. /**
  90802. * Enters full screen mode
  90803. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90804. */
  90805. enterFullscreen(requestPointerLock: boolean): void;
  90806. /**
  90807. * Exits full screen mode
  90808. */
  90809. exitFullscreen(): void;
  90810. /**
  90811. * Enters Pointerlock mode
  90812. */
  90813. enterPointerlock(): void;
  90814. /**
  90815. * Exits Pointerlock mode
  90816. */
  90817. exitPointerlock(): void;
  90818. /**
  90819. * Clear the current render buffer or the current render target (if any is set up)
  90820. * @param color defines the color to use
  90821. * @param backBuffer defines if the back buffer must be cleared
  90822. * @param depth defines if the depth buffer must be cleared
  90823. * @param stencil defines if the stencil buffer must be cleared
  90824. */
  90825. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90826. /**
  90827. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90828. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90829. * @param y defines the y-coordinate of the corner of the clear rectangle
  90830. * @param width defines the width of the clear rectangle
  90831. * @param height defines the height of the clear rectangle
  90832. * @param clearColor defines the clear color
  90833. */
  90834. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90835. /**
  90836. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90837. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90838. * @param y defines the y-coordinate of the corner of the clear rectangle
  90839. * @param width defines the width of the clear rectangle
  90840. * @param height defines the height of the clear rectangle
  90841. */
  90842. enableScissor(x: number, y: number, width: number, height: number): void;
  90843. /**
  90844. * Disable previously set scissor test rectangle
  90845. */
  90846. disableScissor(): void;
  90847. private _viewportCached;
  90848. /** @hidden */
  90849. _viewport(x: number, y: number, width: number, height: number): void;
  90850. /**
  90851. * Set the WebGL's viewport
  90852. * @param viewport defines the viewport element to be used
  90853. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90854. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90855. */
  90856. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90857. /**
  90858. * Directly set the WebGL Viewport
  90859. * @param x defines the x coordinate of the viewport (in screen space)
  90860. * @param y defines the y coordinate of the viewport (in screen space)
  90861. * @param width defines the width of the viewport (in screen space)
  90862. * @param height defines the height of the viewport (in screen space)
  90863. * @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
  90864. */
  90865. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90866. /**
  90867. * Begin a new frame
  90868. */
  90869. beginFrame(): void;
  90870. /**
  90871. * Enf the current frame
  90872. */
  90873. endFrame(): void;
  90874. /**
  90875. * Resize the view according to the canvas' size
  90876. */
  90877. resize(): void;
  90878. /**
  90879. * Force a specific size of the canvas
  90880. * @param width defines the new canvas' width
  90881. * @param height defines the new canvas' height
  90882. */
  90883. setSize(width: number, height: number): void;
  90884. /**
  90885. * Binds the frame buffer to the specified texture.
  90886. * @param texture The texture to render to or null for the default canvas
  90887. * @param faceIndex The face of the texture to render to in case of cube texture
  90888. * @param requiredWidth The width of the target to render to
  90889. * @param requiredHeight The height of the target to render to
  90890. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90891. * @param depthStencilTexture The depth stencil texture to use to render
  90892. * @param lodLevel defines le lod level to bind to the frame buffer
  90893. */
  90894. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90895. /** @hidden */
  90896. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90897. /**
  90898. * Unbind the current render target texture from the webGL context
  90899. * @param texture defines the render target texture to unbind
  90900. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90901. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90902. */
  90903. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90904. /**
  90905. * Force the mipmap generation for the given render target texture
  90906. * @param texture defines the render target texture to use
  90907. */
  90908. generateMipMapsForCubemap(texture: InternalTexture): void;
  90909. /**
  90910. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90911. */
  90912. flushFramebuffer(): void;
  90913. /**
  90914. * Unbind the current render target and bind the default framebuffer
  90915. */
  90916. restoreDefaultFramebuffer(): void;
  90917. /**
  90918. * Create an uniform buffer
  90919. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90920. * @param elements defines the content of the uniform buffer
  90921. * @returns the webGL uniform buffer
  90922. */
  90923. createUniformBuffer(elements: FloatArray): DataBuffer;
  90924. /**
  90925. * Create a dynamic uniform buffer
  90926. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90927. * @param elements defines the content of the uniform buffer
  90928. * @returns the webGL uniform buffer
  90929. */
  90930. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  90931. /**
  90932. * Update an existing uniform buffer
  90933. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90934. * @param uniformBuffer defines the target uniform buffer
  90935. * @param elements defines the content to update
  90936. * @param offset defines the offset in the uniform buffer where update should start
  90937. * @param count defines the size of the data to update
  90938. */
  90939. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  90940. private _resetVertexBufferBinding;
  90941. /**
  90942. * Creates a vertex buffer
  90943. * @param data the data for the vertex buffer
  90944. * @returns the new WebGL static buffer
  90945. */
  90946. createVertexBuffer(data: DataArray): DataBuffer;
  90947. /**
  90948. * Creates a dynamic vertex buffer
  90949. * @param data the data for the dynamic vertex buffer
  90950. * @returns the new WebGL dynamic buffer
  90951. */
  90952. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  90953. /**
  90954. * Update a dynamic index buffer
  90955. * @param indexBuffer defines the target index buffer
  90956. * @param indices defines the data to update
  90957. * @param offset defines the offset in the target index buffer where update should start
  90958. */
  90959. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90960. /**
  90961. * Updates a dynamic vertex buffer.
  90962. * @param vertexBuffer the vertex buffer to update
  90963. * @param data the data used to update the vertex buffer
  90964. * @param byteOffset the byte offset of the data
  90965. * @param byteLength the byte length of the data
  90966. */
  90967. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  90968. private _resetIndexBufferBinding;
  90969. /**
  90970. * Creates a new index buffer
  90971. * @param indices defines the content of the index buffer
  90972. * @param updatable defines if the index buffer must be updatable
  90973. * @returns a new webGL buffer
  90974. */
  90975. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  90976. /**
  90977. * Bind a webGL buffer to the webGL context
  90978. * @param buffer defines the buffer to bind
  90979. */
  90980. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  90981. /**
  90982. * Bind an uniform buffer to the current webGL context
  90983. * @param buffer defines the buffer to bind
  90984. */
  90985. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  90986. /**
  90987. * Bind a buffer to the current webGL context at a given location
  90988. * @param buffer defines the buffer to bind
  90989. * @param location defines the index where to bind the buffer
  90990. */
  90991. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  90992. /**
  90993. * Bind a specific block at a given index in a specific shader program
  90994. * @param pipelineContext defines the pipeline context to use
  90995. * @param blockName defines the block name
  90996. * @param index defines the index where to bind the block
  90997. */
  90998. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  90999. private bindIndexBuffer;
  91000. private bindBuffer;
  91001. /**
  91002. * update the bound buffer with the given data
  91003. * @param data defines the data to update
  91004. */
  91005. updateArrayBuffer(data: Float32Array): void;
  91006. private _vertexAttribPointer;
  91007. private _bindIndexBufferWithCache;
  91008. private _bindVertexBuffersAttributes;
  91009. /**
  91010. * Records a vertex array object
  91011. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91012. * @param vertexBuffers defines the list of vertex buffers to store
  91013. * @param indexBuffer defines the index buffer to store
  91014. * @param effect defines the effect to store
  91015. * @returns the new vertex array object
  91016. */
  91017. recordVertexArrayObject(vertexBuffers: {
  91018. [key: string]: VertexBuffer;
  91019. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91020. /**
  91021. * Bind a specific vertex array object
  91022. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91023. * @param vertexArrayObject defines the vertex array object to bind
  91024. * @param indexBuffer defines the index buffer to bind
  91025. */
  91026. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91027. /**
  91028. * Bind webGl buffers directly to the webGL context
  91029. * @param vertexBuffer defines the vertex buffer to bind
  91030. * @param indexBuffer defines the index buffer to bind
  91031. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91032. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91033. * @param effect defines the effect associated with the vertex buffer
  91034. */
  91035. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91036. private _unbindVertexArrayObject;
  91037. /**
  91038. * Bind a list of vertex buffers to the webGL context
  91039. * @param vertexBuffers defines the list of vertex buffers to bind
  91040. * @param indexBuffer defines the index buffer to bind
  91041. * @param effect defines the effect associated with the vertex buffers
  91042. */
  91043. bindBuffers(vertexBuffers: {
  91044. [key: string]: Nullable<VertexBuffer>;
  91045. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91046. /**
  91047. * Unbind all instance attributes
  91048. */
  91049. unbindInstanceAttributes(): void;
  91050. /**
  91051. * Release and free the memory of a vertex array object
  91052. * @param vao defines the vertex array object to delete
  91053. */
  91054. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91055. /** @hidden */
  91056. _releaseBuffer(buffer: DataBuffer): boolean;
  91057. /**
  91058. * Creates a webGL buffer to use with instanciation
  91059. * @param capacity defines the size of the buffer
  91060. * @returns the webGL buffer
  91061. */
  91062. createInstancesBuffer(capacity: number): DataBuffer;
  91063. /**
  91064. * Delete a webGL buffer used with instanciation
  91065. * @param buffer defines the webGL buffer to delete
  91066. */
  91067. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91068. /**
  91069. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91070. * @param instancesBuffer defines the webGL buffer to update and bind
  91071. * @param data defines the data to store in the buffer
  91072. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91073. */
  91074. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91075. /**
  91076. * Apply all cached states (depth, culling, stencil and alpha)
  91077. */
  91078. applyStates(): void;
  91079. /**
  91080. * Send a draw order
  91081. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91082. * @param indexStart defines the starting index
  91083. * @param indexCount defines the number of index to draw
  91084. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91085. */
  91086. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91087. /**
  91088. * Draw a list of points
  91089. * @param verticesStart defines the index of first vertex to draw
  91090. * @param verticesCount defines the count of vertices to draw
  91091. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91092. */
  91093. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91094. /**
  91095. * Draw a list of unindexed primitives
  91096. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91097. * @param verticesStart defines the index of first vertex to draw
  91098. * @param verticesCount defines the count of vertices to draw
  91099. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91100. */
  91101. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91102. /**
  91103. * Draw a list of indexed primitives
  91104. * @param fillMode defines the primitive to use
  91105. * @param indexStart defines the starting index
  91106. * @param indexCount defines the number of index to draw
  91107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91108. */
  91109. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91110. /**
  91111. * Draw a list of unindexed primitives
  91112. * @param fillMode defines the primitive to use
  91113. * @param verticesStart defines the index of first vertex to draw
  91114. * @param verticesCount defines the count of vertices to draw
  91115. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91116. */
  91117. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91118. private _drawMode;
  91119. /** @hidden */
  91120. _releaseEffect(effect: Effect): void;
  91121. /** @hidden */
  91122. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91123. /**
  91124. * Create a new effect (used to store vertex/fragment shaders)
  91125. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91126. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91127. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91128. * @param samplers defines an array of string used to represent textures
  91129. * @param defines defines the string containing the defines to use to compile the shaders
  91130. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91131. * @param onCompiled defines a function to call when the effect creation is successful
  91132. * @param onError defines a function to call when the effect creation has failed
  91133. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91134. * @returns the new Effect
  91135. */
  91136. 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;
  91137. private _compileShader;
  91138. private _compileRawShader;
  91139. /**
  91140. * Directly creates a webGL program
  91141. * @param pipelineContext defines the pipeline context to attach to
  91142. * @param vertexCode defines the vertex shader code to use
  91143. * @param fragmentCode defines the fragment shader code to use
  91144. * @param context defines the webGL context to use (if not set, the current one will be used)
  91145. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91146. * @returns the new webGL program
  91147. */
  91148. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91149. /**
  91150. * Creates a webGL program
  91151. * @param pipelineContext defines the pipeline context to attach to
  91152. * @param vertexCode defines the vertex shader code to use
  91153. * @param fragmentCode defines the fragment shader code to use
  91154. * @param defines defines the string containing the defines to use to compile the shaders
  91155. * @param context defines the webGL context to use (if not set, the current one will be used)
  91156. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91157. * @returns the new webGL program
  91158. */
  91159. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91160. /**
  91161. * Creates a new pipeline context
  91162. * @returns the new pipeline
  91163. */
  91164. createPipelineContext(): WebGLPipelineContext;
  91165. private _createShaderProgram;
  91166. private _finalizePipelineContext;
  91167. /** @hidden */
  91168. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91169. /** @hidden */
  91170. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91171. /** @hidden */
  91172. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91173. /**
  91174. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91175. * @param pipelineContext defines the pipeline context to use
  91176. * @param uniformsNames defines the list of uniform names
  91177. * @returns an array of webGL uniform locations
  91178. */
  91179. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91180. /**
  91181. * Gets the lsit of active attributes for a given webGL program
  91182. * @param pipelineContext defines the pipeline context to use
  91183. * @param attributesNames defines the list of attribute names to get
  91184. * @returns an array of indices indicating the offset of each attribute
  91185. */
  91186. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91187. /**
  91188. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91189. * @param effect defines the effect to activate
  91190. */
  91191. enableEffect(effect: Nullable<Effect>): void;
  91192. /**
  91193. * Set the value of an uniform to an array of int32
  91194. * @param uniform defines the webGL uniform location where to store the value
  91195. * @param array defines the array of int32 to store
  91196. */
  91197. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91198. /**
  91199. * Set the value of an uniform to an array of int32 (stored as vec2)
  91200. * @param uniform defines the webGL uniform location where to store the value
  91201. * @param array defines the array of int32 to store
  91202. */
  91203. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91204. /**
  91205. * Set the value of an uniform to an array of int32 (stored as vec3)
  91206. * @param uniform defines the webGL uniform location where to store the value
  91207. * @param array defines the array of int32 to store
  91208. */
  91209. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91210. /**
  91211. * Set the value of an uniform to an array of int32 (stored as vec4)
  91212. * @param uniform defines the webGL uniform location where to store the value
  91213. * @param array defines the array of int32 to store
  91214. */
  91215. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91216. /**
  91217. * Set the value of an uniform to an array of float32
  91218. * @param uniform defines the webGL uniform location where to store the value
  91219. * @param array defines the array of float32 to store
  91220. */
  91221. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91222. /**
  91223. * Set the value of an uniform to an array of float32 (stored as vec2)
  91224. * @param uniform defines the webGL uniform location where to store the value
  91225. * @param array defines the array of float32 to store
  91226. */
  91227. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91228. /**
  91229. * Set the value of an uniform to an array of float32 (stored as vec3)
  91230. * @param uniform defines the webGL uniform location where to store the value
  91231. * @param array defines the array of float32 to store
  91232. */
  91233. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91234. /**
  91235. * Set the value of an uniform to an array of float32 (stored as vec4)
  91236. * @param uniform defines the webGL uniform location where to store the value
  91237. * @param array defines the array of float32 to store
  91238. */
  91239. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91240. /**
  91241. * Set the value of an uniform to an array of number
  91242. * @param uniform defines the webGL uniform location where to store the value
  91243. * @param array defines the array of number to store
  91244. */
  91245. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91246. /**
  91247. * Set the value of an uniform to an array of number (stored as vec2)
  91248. * @param uniform defines the webGL uniform location where to store the value
  91249. * @param array defines the array of number to store
  91250. */
  91251. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91252. /**
  91253. * Set the value of an uniform to an array of number (stored as vec3)
  91254. * @param uniform defines the webGL uniform location where to store the value
  91255. * @param array defines the array of number to store
  91256. */
  91257. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91258. /**
  91259. * Set the value of an uniform to an array of number (stored as vec4)
  91260. * @param uniform defines the webGL uniform location where to store the value
  91261. * @param array defines the array of number to store
  91262. */
  91263. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91264. /**
  91265. * Set the value of an uniform to an array of float32 (stored as matrices)
  91266. * @param uniform defines the webGL uniform location where to store the value
  91267. * @param matrices defines the array of float32 to store
  91268. */
  91269. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91270. /**
  91271. * Set the value of an uniform to a matrix
  91272. * @param uniform defines the webGL uniform location where to store the value
  91273. * @param matrix defines the matrix to store
  91274. */
  91275. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91276. /**
  91277. * Set the value of an uniform to a matrix (3x3)
  91278. * @param uniform defines the webGL uniform location where to store the value
  91279. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91280. */
  91281. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91282. /**
  91283. * Set the value of an uniform to a matrix (2x2)
  91284. * @param uniform defines the webGL uniform location where to store the value
  91285. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91286. */
  91287. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91288. /**
  91289. * Set the value of an uniform to a number (int)
  91290. * @param uniform defines the webGL uniform location where to store the value
  91291. * @param value defines the int number to store
  91292. */
  91293. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91294. /**
  91295. * Set the value of an uniform to a number (float)
  91296. * @param uniform defines the webGL uniform location where to store the value
  91297. * @param value defines the float number to store
  91298. */
  91299. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91300. /**
  91301. * Set the value of an uniform to a vec2
  91302. * @param uniform defines the webGL uniform location where to store the value
  91303. * @param x defines the 1st component of the value
  91304. * @param y defines the 2nd component of the value
  91305. */
  91306. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91307. /**
  91308. * Set the value of an uniform to a vec3
  91309. * @param uniform defines the webGL uniform location where to store the value
  91310. * @param x defines the 1st component of the value
  91311. * @param y defines the 2nd component of the value
  91312. * @param z defines the 3rd component of the value
  91313. */
  91314. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91315. /**
  91316. * Set the value of an uniform to a boolean
  91317. * @param uniform defines the webGL uniform location where to store the value
  91318. * @param bool defines the boolean to store
  91319. */
  91320. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91321. /**
  91322. * Set the value of an uniform to a vec4
  91323. * @param uniform defines the webGL uniform location where to store the value
  91324. * @param x defines the 1st component of the value
  91325. * @param y defines the 2nd component of the value
  91326. * @param z defines the 3rd component of the value
  91327. * @param w defines the 4th component of the value
  91328. */
  91329. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91330. /**
  91331. * Set the value of an uniform to a Color3
  91332. * @param uniform defines the webGL uniform location where to store the value
  91333. * @param color3 defines the color to store
  91334. */
  91335. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91336. /**
  91337. * Set the value of an uniform to a Color3 and an alpha value
  91338. * @param uniform defines the webGL uniform location where to store the value
  91339. * @param color3 defines the color to store
  91340. * @param alpha defines the alpha component to store
  91341. */
  91342. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91343. /**
  91344. * Sets a Color4 on a uniform variable
  91345. * @param uniform defines the uniform location
  91346. * @param color4 defines the value to be set
  91347. */
  91348. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91349. /**
  91350. * Set various states to the webGL context
  91351. * @param culling defines backface culling state
  91352. * @param zOffset defines the value to apply to zOffset (0 by default)
  91353. * @param force defines if states must be applied even if cache is up to date
  91354. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91355. */
  91356. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91357. /**
  91358. * Set the z offset to apply to current rendering
  91359. * @param value defines the offset to apply
  91360. */
  91361. setZOffset(value: number): void;
  91362. /**
  91363. * Gets the current value of the zOffset
  91364. * @returns the current zOffset state
  91365. */
  91366. getZOffset(): number;
  91367. /**
  91368. * Enable or disable depth buffering
  91369. * @param enable defines the state to set
  91370. */
  91371. setDepthBuffer(enable: boolean): void;
  91372. /**
  91373. * Gets a boolean indicating if depth writing is enabled
  91374. * @returns the current depth writing state
  91375. */
  91376. getDepthWrite(): boolean;
  91377. /**
  91378. * Enable or disable depth writing
  91379. * @param enable defines the state to set
  91380. */
  91381. setDepthWrite(enable: boolean): void;
  91382. /**
  91383. * Enable or disable color writing
  91384. * @param enable defines the state to set
  91385. */
  91386. setColorWrite(enable: boolean): void;
  91387. /**
  91388. * Gets a boolean indicating if color writing is enabled
  91389. * @returns the current color writing state
  91390. */
  91391. getColorWrite(): boolean;
  91392. /**
  91393. * Sets alpha constants used by some alpha blending modes
  91394. * @param r defines the red component
  91395. * @param g defines the green component
  91396. * @param b defines the blue component
  91397. * @param a defines the alpha component
  91398. */
  91399. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91400. /**
  91401. * Sets the current alpha mode
  91402. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91403. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91404. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91405. */
  91406. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91407. /**
  91408. * Gets the current alpha mode
  91409. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91410. * @returns the current alpha mode
  91411. */
  91412. getAlphaMode(): number;
  91413. /**
  91414. * Clears the list of texture accessible through engine.
  91415. * This can help preventing texture load conflict due to name collision.
  91416. */
  91417. clearInternalTexturesCache(): void;
  91418. /**
  91419. * Force the entire cache to be cleared
  91420. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91421. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91422. */
  91423. wipeCaches(bruteForce?: boolean): void;
  91424. /**
  91425. * Set the compressed texture format to use, based on the formats you have, and the formats
  91426. * supported by the hardware / browser.
  91427. *
  91428. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91429. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91430. * to API arguments needed to compressed textures. This puts the burden on the container
  91431. * generator to house the arcane code for determining these for current & future formats.
  91432. *
  91433. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91434. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91435. *
  91436. * Note: The result of this call is not taken into account when a texture is base64.
  91437. *
  91438. * @param formatsAvailable defines the list of those format families you have created
  91439. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91440. *
  91441. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91442. * @returns The extension selected.
  91443. */
  91444. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91445. /** @hidden */
  91446. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91447. min: number;
  91448. mag: number;
  91449. };
  91450. /** @hidden */
  91451. _createTexture(): WebGLTexture;
  91452. /**
  91453. * Usually called from Texture.ts.
  91454. * Passed information to create a WebGLTexture
  91455. * @param urlArg defines a value which contains one of the following:
  91456. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91457. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91458. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91459. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91460. * @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)
  91461. * @param scene needed for loading to the correct scene
  91462. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91463. * @param onLoad optional callback to be called upon successful completion
  91464. * @param onError optional callback to be called upon failure
  91465. * @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
  91466. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91467. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91468. * @param forcedExtension defines the extension to use to pick the right loader
  91469. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91470. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91471. */
  91472. 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;
  91473. /**
  91474. * @hidden
  91475. * Rescales a texture
  91476. * @param source input texutre
  91477. * @param destination destination texture
  91478. * @param scene scene to use to render the resize
  91479. * @param internalFormat format to use when resizing
  91480. * @param onComplete callback to be called when resize has completed
  91481. */
  91482. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91483. private _unpackFlipYCached;
  91484. /**
  91485. * In case you are sharing the context with other applications, it might
  91486. * be interested to not cache the unpack flip y state to ensure a consistent
  91487. * value would be set.
  91488. */
  91489. enableUnpackFlipYCached: boolean;
  91490. /** @hidden */
  91491. _unpackFlipY(value: boolean): void;
  91492. /** @hidden */
  91493. _getUnpackAlignement(): number;
  91494. /**
  91495. * Creates a dynamic texture
  91496. * @param width defines the width of the texture
  91497. * @param height defines the height of the texture
  91498. * @param generateMipMaps defines if the engine should generate the mip levels
  91499. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91500. * @returns the dynamic texture inside an InternalTexture
  91501. */
  91502. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91503. /**
  91504. * Update the sampling mode of a given texture
  91505. * @param samplingMode defines the required sampling mode
  91506. * @param texture defines the texture to update
  91507. */
  91508. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91509. /**
  91510. * Update the content of a dynamic texture
  91511. * @param texture defines the texture to update
  91512. * @param canvas defines the canvas containing the source
  91513. * @param invertY defines if data must be stored with Y axis inverted
  91514. * @param premulAlpha defines if alpha is stored as premultiplied
  91515. * @param format defines the format of the data
  91516. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91517. */
  91518. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91519. /**
  91520. * Update a video texture
  91521. * @param texture defines the texture to update
  91522. * @param video defines the video element to use
  91523. * @param invertY defines if data must be stored with Y axis inverted
  91524. */
  91525. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91526. /**
  91527. * Updates a depth texture Comparison Mode and Function.
  91528. * If the comparison Function is equal to 0, the mode will be set to none.
  91529. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91530. * @param texture The texture to set the comparison function for
  91531. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91532. */
  91533. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91534. /** @hidden */
  91535. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91536. width: number;
  91537. height: number;
  91538. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91539. /**
  91540. * Creates a depth stencil texture.
  91541. * This is only available in WebGL 2 or with the depth texture extension available.
  91542. * @param size The size of face edge in the texture.
  91543. * @param options The options defining the texture.
  91544. * @returns The texture
  91545. */
  91546. createDepthStencilTexture(size: number | {
  91547. width: number;
  91548. height: number;
  91549. }, options: DepthTextureCreationOptions): InternalTexture;
  91550. /**
  91551. * Creates a depth stencil texture.
  91552. * This is only available in WebGL 2 or with the depth texture extension available.
  91553. * @param size The size of face edge in the texture.
  91554. * @param options The options defining the texture.
  91555. * @returns The texture
  91556. */
  91557. private _createDepthStencilTexture;
  91558. /**
  91559. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91560. * @param renderTarget The render target to set the frame buffer for
  91561. */
  91562. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91563. /**
  91564. * Creates a new render target texture
  91565. * @param size defines the size of the texture
  91566. * @param options defines the options used to create the texture
  91567. * @returns a new render target texture stored in an InternalTexture
  91568. */
  91569. createRenderTargetTexture(size: number | {
  91570. width: number;
  91571. height: number;
  91572. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91573. /** @hidden */
  91574. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91575. /**
  91576. * Updates the sample count of a render target texture
  91577. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91578. * @param texture defines the texture to update
  91579. * @param samples defines the sample count to set
  91580. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91581. */
  91582. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91583. /** @hidden */
  91584. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91585. /** @hidden */
  91586. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  91587. /** @hidden */
  91588. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91589. /** @hidden */
  91590. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91591. /**
  91592. * @hidden
  91593. */
  91594. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91595. private _prepareWebGLTextureContinuation;
  91596. private _prepareWebGLTexture;
  91597. /** @hidden */
  91598. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91599. /** @hidden */
  91600. _releaseFramebufferObjects(texture: InternalTexture): void;
  91601. /** @hidden */
  91602. _releaseTexture(texture: InternalTexture): void;
  91603. private setProgram;
  91604. private _boundUniforms;
  91605. /**
  91606. * Binds an effect to the webGL context
  91607. * @param effect defines the effect to bind
  91608. */
  91609. bindSamplers(effect: Effect): void;
  91610. private _activateCurrentTexture;
  91611. /** @hidden */
  91612. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91613. /** @hidden */
  91614. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91615. /**
  91616. * Sets a texture to the webGL context from a postprocess
  91617. * @param channel defines the channel to use
  91618. * @param postProcess defines the source postprocess
  91619. */
  91620. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91621. /**
  91622. * Binds the output of the passed in post process to the texture channel specified
  91623. * @param channel The channel the texture should be bound to
  91624. * @param postProcess The post process which's output should be bound
  91625. */
  91626. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91627. /**
  91628. * Unbind all textures from the webGL context
  91629. */
  91630. unbindAllTextures(): void;
  91631. /**
  91632. * Sets a texture to the according uniform.
  91633. * @param channel The texture channel
  91634. * @param uniform The uniform to set
  91635. * @param texture The texture to apply
  91636. */
  91637. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91638. /**
  91639. * Sets a depth stencil texture from a render target to the according uniform.
  91640. * @param channel The texture channel
  91641. * @param uniform The uniform to set
  91642. * @param texture The render target texture containing the depth stencil texture to apply
  91643. */
  91644. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91645. private _bindSamplerUniformToChannel;
  91646. private _getTextureWrapMode;
  91647. private _setTexture;
  91648. /**
  91649. * Sets an array of texture to the webGL context
  91650. * @param channel defines the channel where the texture array must be set
  91651. * @param uniform defines the associated uniform location
  91652. * @param textures defines the array of textures to bind
  91653. */
  91654. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91655. /** @hidden */
  91656. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91657. private _setTextureParameterFloat;
  91658. private _setTextureParameterInteger;
  91659. /**
  91660. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91661. * @param x defines the x coordinate of the rectangle where pixels must be read
  91662. * @param y defines the y coordinate of the rectangle where pixels must be read
  91663. * @param width defines the width of the rectangle where pixels must be read
  91664. * @param height defines the height of the rectangle where pixels must be read
  91665. * @returns a Uint8Array containing RGBA colors
  91666. */
  91667. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91668. /**
  91669. * Add an externaly attached data from its key.
  91670. * This method call will fail and return false, if such key already exists.
  91671. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91672. * @param key the unique key that identifies the data
  91673. * @param data the data object to associate to the key for this Engine instance
  91674. * @return true if no such key were already present and the data was added successfully, false otherwise
  91675. */
  91676. addExternalData<T>(key: string, data: T): boolean;
  91677. /**
  91678. * Get an externaly attached data from its key
  91679. * @param key the unique key that identifies the data
  91680. * @return the associated data, if present (can be null), or undefined if not present
  91681. */
  91682. getExternalData<T>(key: string): T;
  91683. /**
  91684. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91685. * @param key the unique key that identifies the data
  91686. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91687. * @return the associated data, can be null if the factory returned null.
  91688. */
  91689. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91690. /**
  91691. * Remove an externaly attached data from the Engine instance
  91692. * @param key the unique key that identifies the data
  91693. * @return true if the data was successfully removed, false if it doesn't exist
  91694. */
  91695. removeExternalData(key: string): boolean;
  91696. /**
  91697. * Unbind all vertex attributes from the webGL context
  91698. */
  91699. unbindAllAttributes(): void;
  91700. /**
  91701. * 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
  91702. */
  91703. releaseEffects(): void;
  91704. /**
  91705. * Dispose and release all associated resources
  91706. */
  91707. dispose(): void;
  91708. /**
  91709. * Display the loading screen
  91710. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91711. */
  91712. displayLoadingUI(): void;
  91713. /**
  91714. * Hide the loading screen
  91715. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91716. */
  91717. hideLoadingUI(): void;
  91718. /**
  91719. * Gets the current loading screen object
  91720. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91721. */
  91722. /**
  91723. * Sets the current loading screen object
  91724. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91725. */
  91726. loadingScreen: ILoadingScreen;
  91727. /**
  91728. * Sets the current loading screen text
  91729. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91730. */
  91731. loadingUIText: string;
  91732. /**
  91733. * Sets the current loading screen background color
  91734. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91735. */
  91736. loadingUIBackgroundColor: string;
  91737. /**
  91738. * Attach a new callback raised when context lost event is fired
  91739. * @param callback defines the callback to call
  91740. */
  91741. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91742. /**
  91743. * Attach a new callback raised when context restored event is fired
  91744. * @param callback defines the callback to call
  91745. */
  91746. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91747. /**
  91748. * Gets the source code of the vertex shader associated with a specific webGL program
  91749. * @param program defines the program to use
  91750. * @returns a string containing the source code of the vertex shader associated with the program
  91751. */
  91752. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91753. /**
  91754. * Gets the source code of the fragment shader associated with a specific webGL program
  91755. * @param program defines the program to use
  91756. * @returns a string containing the source code of the fragment shader associated with the program
  91757. */
  91758. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91759. /**
  91760. * Get the current error code of the webGL context
  91761. * @returns the error code
  91762. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91763. */
  91764. getError(): number;
  91765. /**
  91766. * Gets the current framerate
  91767. * @returns a number representing the framerate
  91768. */
  91769. getFps(): number;
  91770. /**
  91771. * Gets the time spent between current and previous frame
  91772. * @returns a number representing the delta time in ms
  91773. */
  91774. getDeltaTime(): number;
  91775. private _measureFps;
  91776. /** @hidden */
  91777. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91778. private _canRenderToFloatFramebuffer;
  91779. private _canRenderToHalfFloatFramebuffer;
  91780. private _canRenderToFramebuffer;
  91781. /** @hidden */
  91782. _getWebGLTextureType(type: number): number;
  91783. /** @hidden */
  91784. _getInternalFormat(format: number): number;
  91785. /** @hidden */
  91786. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91787. /** @hidden */
  91788. _getRGBAMultiSampleBufferFormat(type: number): number;
  91789. /** @hidden */
  91790. _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;
  91791. /** @hidden */
  91792. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91793. /**
  91794. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91795. * @returns true if the engine can be created
  91796. * @ignorenaming
  91797. */
  91798. static isSupported(): boolean;
  91799. }
  91800. }
  91801. declare module BABYLON {
  91802. /**
  91803. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91804. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91805. */
  91806. export class EffectFallbacks {
  91807. private _defines;
  91808. private _currentRank;
  91809. private _maxRank;
  91810. private _mesh;
  91811. /**
  91812. * Removes the fallback from the bound mesh.
  91813. */
  91814. unBindMesh(): void;
  91815. /**
  91816. * Adds a fallback on the specified property.
  91817. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91818. * @param define The name of the define in the shader
  91819. */
  91820. addFallback(rank: number, define: string): void;
  91821. /**
  91822. * Sets the mesh to use CPU skinning when needing to fallback.
  91823. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91824. * @param mesh The mesh to use the fallbacks.
  91825. */
  91826. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91827. /**
  91828. * Checks to see if more fallbacks are still availible.
  91829. */
  91830. readonly isMoreFallbacks: boolean;
  91831. /**
  91832. * Removes the defines that should be removed when falling back.
  91833. * @param currentDefines defines the current define statements for the shader.
  91834. * @param effect defines the current effect we try to compile
  91835. * @returns The resulting defines with defines of the current rank removed.
  91836. */
  91837. reduce(currentDefines: string, effect: Effect): string;
  91838. }
  91839. /**
  91840. * Options to be used when creating an effect.
  91841. */
  91842. export class EffectCreationOptions {
  91843. /**
  91844. * Atrributes that will be used in the shader.
  91845. */
  91846. attributes: string[];
  91847. /**
  91848. * Uniform varible names that will be set in the shader.
  91849. */
  91850. uniformsNames: string[];
  91851. /**
  91852. * Uniform buffer varible names that will be set in the shader.
  91853. */
  91854. uniformBuffersNames: string[];
  91855. /**
  91856. * Sampler texture variable names that will be set in the shader.
  91857. */
  91858. samplers: string[];
  91859. /**
  91860. * Define statements that will be set in the shader.
  91861. */
  91862. defines: any;
  91863. /**
  91864. * Possible fallbacks for this effect to improve performance when needed.
  91865. */
  91866. fallbacks: Nullable<EffectFallbacks>;
  91867. /**
  91868. * Callback that will be called when the shader is compiled.
  91869. */
  91870. onCompiled: Nullable<(effect: Effect) => void>;
  91871. /**
  91872. * Callback that will be called if an error occurs during shader compilation.
  91873. */
  91874. onError: Nullable<(effect: Effect, errors: string) => void>;
  91875. /**
  91876. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91877. */
  91878. indexParameters: any;
  91879. /**
  91880. * Max number of lights that can be used in the shader.
  91881. */
  91882. maxSimultaneousLights: number;
  91883. /**
  91884. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91885. */
  91886. transformFeedbackVaryings: Nullable<string[]>;
  91887. }
  91888. /**
  91889. * Effect containing vertex and fragment shader that can be executed on an object.
  91890. */
  91891. export class Effect implements IDisposable {
  91892. /**
  91893. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91894. */
  91895. static ShadersRepository: string;
  91896. /**
  91897. * Name of the effect.
  91898. */
  91899. name: any;
  91900. /**
  91901. * String container all the define statements that should be set on the shader.
  91902. */
  91903. defines: string;
  91904. /**
  91905. * Callback that will be called when the shader is compiled.
  91906. */
  91907. onCompiled: Nullable<(effect: Effect) => void>;
  91908. /**
  91909. * Callback that will be called if an error occurs during shader compilation.
  91910. */
  91911. onError: Nullable<(effect: Effect, errors: string) => void>;
  91912. /**
  91913. * Callback that will be called when effect is bound.
  91914. */
  91915. onBind: Nullable<(effect: Effect) => void>;
  91916. /**
  91917. * Unique ID of the effect.
  91918. */
  91919. uniqueId: number;
  91920. /**
  91921. * Observable that will be called when the shader is compiled.
  91922. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91923. */
  91924. onCompileObservable: Observable<Effect>;
  91925. /**
  91926. * Observable that will be called if an error occurs during shader compilation.
  91927. */
  91928. onErrorObservable: Observable<Effect>;
  91929. /** @hidden */
  91930. _onBindObservable: Nullable<Observable<Effect>>;
  91931. /**
  91932. * Observable that will be called when effect is bound.
  91933. */
  91934. readonly onBindObservable: Observable<Effect>;
  91935. /** @hidden */
  91936. _bonesComputationForcedToCPU: boolean;
  91937. private static _uniqueIdSeed;
  91938. private _engine;
  91939. private _uniformBuffersNames;
  91940. private _uniformsNames;
  91941. private _samplerList;
  91942. private _samplers;
  91943. private _isReady;
  91944. private _compilationError;
  91945. private _attributesNames;
  91946. private _attributes;
  91947. private _uniforms;
  91948. /**
  91949. * Key for the effect.
  91950. * @hidden
  91951. */
  91952. _key: string;
  91953. private _indexParameters;
  91954. private _fallbacks;
  91955. private _vertexSourceCode;
  91956. private _fragmentSourceCode;
  91957. private _vertexSourceCodeOverride;
  91958. private _fragmentSourceCodeOverride;
  91959. private _transformFeedbackVaryings;
  91960. /**
  91961. * Compiled shader to webGL program.
  91962. * @hidden
  91963. */
  91964. _pipelineContext: Nullable<IPipelineContext>;
  91965. private _valueCache;
  91966. private static _baseCache;
  91967. /**
  91968. * Instantiates an effect.
  91969. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91970. * @param baseName Name of the effect.
  91971. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91972. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91973. * @param samplers List of sampler variables that will be passed to the shader.
  91974. * @param engine Engine to be used to render the effect
  91975. * @param defines Define statements to be added to the shader.
  91976. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91977. * @param onCompiled Callback that will be called when the shader is compiled.
  91978. * @param onError Callback that will be called if an error occurs during shader compilation.
  91979. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91980. */
  91981. 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);
  91982. private _useFinalCode;
  91983. /**
  91984. * Unique key for this effect
  91985. */
  91986. readonly key: string;
  91987. /**
  91988. * If the effect has been compiled and prepared.
  91989. * @returns if the effect is compiled and prepared.
  91990. */
  91991. isReady(): boolean;
  91992. /**
  91993. * The engine the effect was initialized with.
  91994. * @returns the engine.
  91995. */
  91996. getEngine(): Engine;
  91997. /**
  91998. * The pipeline context for this effect
  91999. * @returns the associated pipeline context
  92000. */
  92001. getPipelineContext(): Nullable<IPipelineContext>;
  92002. /**
  92003. * The set of names of attribute variables for the shader.
  92004. * @returns An array of attribute names.
  92005. */
  92006. getAttributesNames(): string[];
  92007. /**
  92008. * Returns the attribute at the given index.
  92009. * @param index The index of the attribute.
  92010. * @returns The location of the attribute.
  92011. */
  92012. getAttributeLocation(index: number): number;
  92013. /**
  92014. * Returns the attribute based on the name of the variable.
  92015. * @param name of the attribute to look up.
  92016. * @returns the attribute location.
  92017. */
  92018. getAttributeLocationByName(name: string): number;
  92019. /**
  92020. * The number of attributes.
  92021. * @returns the numnber of attributes.
  92022. */
  92023. getAttributesCount(): number;
  92024. /**
  92025. * Gets the index of a uniform variable.
  92026. * @param uniformName of the uniform to look up.
  92027. * @returns the index.
  92028. */
  92029. getUniformIndex(uniformName: string): number;
  92030. /**
  92031. * Returns the attribute based on the name of the variable.
  92032. * @param uniformName of the uniform to look up.
  92033. * @returns the location of the uniform.
  92034. */
  92035. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92036. /**
  92037. * Returns an array of sampler variable names
  92038. * @returns The array of sampler variable neames.
  92039. */
  92040. getSamplers(): string[];
  92041. /**
  92042. * The error from the last compilation.
  92043. * @returns the error string.
  92044. */
  92045. getCompilationError(): string;
  92046. /**
  92047. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92048. * @param func The callback to be used.
  92049. */
  92050. executeWhenCompiled(func: (effect: Effect) => void): void;
  92051. private _checkIsReady;
  92052. /** @hidden */
  92053. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92054. /** @hidden */
  92055. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92056. /** @hidden */
  92057. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92058. /**
  92059. * Recompiles the webGL program
  92060. * @param vertexSourceCode The source code for the vertex shader.
  92061. * @param fragmentSourceCode The source code for the fragment shader.
  92062. * @param onCompiled Callback called when completed.
  92063. * @param onError Callback called on error.
  92064. * @hidden
  92065. */
  92066. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92067. /**
  92068. * Prepares the effect
  92069. * @hidden
  92070. */
  92071. _prepareEffect(): void;
  92072. /**
  92073. * Checks if the effect is supported. (Must be called after compilation)
  92074. */
  92075. readonly isSupported: boolean;
  92076. /**
  92077. * Binds a texture to the engine to be used as output of the shader.
  92078. * @param channel Name of the output variable.
  92079. * @param texture Texture to bind.
  92080. * @hidden
  92081. */
  92082. _bindTexture(channel: string, texture: InternalTexture): void;
  92083. /**
  92084. * Sets a texture on the engine to be used in the shader.
  92085. * @param channel Name of the sampler variable.
  92086. * @param texture Texture to set.
  92087. */
  92088. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92089. /**
  92090. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92091. * @param channel Name of the sampler variable.
  92092. * @param texture Texture to set.
  92093. */
  92094. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92095. /**
  92096. * Sets an array of textures on the engine to be used in the shader.
  92097. * @param channel Name of the variable.
  92098. * @param textures Textures to set.
  92099. */
  92100. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92101. /**
  92102. * 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)
  92103. * @param channel Name of the sampler variable.
  92104. * @param postProcess Post process to get the input texture from.
  92105. */
  92106. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92107. /**
  92108. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92109. * 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)
  92110. * @param channel Name of the sampler variable.
  92111. * @param postProcess Post process to get the output texture from.
  92112. */
  92113. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92114. /** @hidden */
  92115. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92116. /** @hidden */
  92117. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92118. /** @hidden */
  92119. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92120. /** @hidden */
  92121. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92122. /**
  92123. * Binds a buffer to a uniform.
  92124. * @param buffer Buffer to bind.
  92125. * @param name Name of the uniform variable to bind to.
  92126. */
  92127. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92128. /**
  92129. * Binds block to a uniform.
  92130. * @param blockName Name of the block to bind.
  92131. * @param index Index to bind.
  92132. */
  92133. bindUniformBlock(blockName: string, index: number): void;
  92134. /**
  92135. * Sets an interger value on a uniform variable.
  92136. * @param uniformName Name of the variable.
  92137. * @param value Value to be set.
  92138. * @returns this effect.
  92139. */
  92140. setInt(uniformName: string, value: number): Effect;
  92141. /**
  92142. * Sets an int array on a uniform variable.
  92143. * @param uniformName Name of the variable.
  92144. * @param array array to be set.
  92145. * @returns this effect.
  92146. */
  92147. setIntArray(uniformName: string, array: Int32Array): Effect;
  92148. /**
  92149. * 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)
  92150. * @param uniformName Name of the variable.
  92151. * @param array array to be set.
  92152. * @returns this effect.
  92153. */
  92154. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92155. /**
  92156. * 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)
  92157. * @param uniformName Name of the variable.
  92158. * @param array array to be set.
  92159. * @returns this effect.
  92160. */
  92161. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92162. /**
  92163. * 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)
  92164. * @param uniformName Name of the variable.
  92165. * @param array array to be set.
  92166. * @returns this effect.
  92167. */
  92168. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92169. /**
  92170. * Sets an float array on a uniform variable.
  92171. * @param uniformName Name of the variable.
  92172. * @param array array to be set.
  92173. * @returns this effect.
  92174. */
  92175. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92176. /**
  92177. * 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)
  92178. * @param uniformName Name of the variable.
  92179. * @param array array to be set.
  92180. * @returns this effect.
  92181. */
  92182. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92183. /**
  92184. * 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)
  92185. * @param uniformName Name of the variable.
  92186. * @param array array to be set.
  92187. * @returns this effect.
  92188. */
  92189. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92190. /**
  92191. * 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)
  92192. * @param uniformName Name of the variable.
  92193. * @param array array to be set.
  92194. * @returns this effect.
  92195. */
  92196. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92197. /**
  92198. * Sets an array on a uniform variable.
  92199. * @param uniformName Name of the variable.
  92200. * @param array array to be set.
  92201. * @returns this effect.
  92202. */
  92203. setArray(uniformName: string, array: number[]): Effect;
  92204. /**
  92205. * 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)
  92206. * @param uniformName Name of the variable.
  92207. * @param array array to be set.
  92208. * @returns this effect.
  92209. */
  92210. setArray2(uniformName: string, array: number[]): Effect;
  92211. /**
  92212. * 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)
  92213. * @param uniformName Name of the variable.
  92214. * @param array array to be set.
  92215. * @returns this effect.
  92216. */
  92217. setArray3(uniformName: string, array: number[]): Effect;
  92218. /**
  92219. * 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)
  92220. * @param uniformName Name of the variable.
  92221. * @param array array to be set.
  92222. * @returns this effect.
  92223. */
  92224. setArray4(uniformName: string, array: number[]): Effect;
  92225. /**
  92226. * Sets matrices on a uniform variable.
  92227. * @param uniformName Name of the variable.
  92228. * @param matrices matrices to be set.
  92229. * @returns this effect.
  92230. */
  92231. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92232. /**
  92233. * Sets matrix on a uniform variable.
  92234. * @param uniformName Name of the variable.
  92235. * @param matrix matrix to be set.
  92236. * @returns this effect.
  92237. */
  92238. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92239. /**
  92240. * 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)
  92241. * @param uniformName Name of the variable.
  92242. * @param matrix matrix to be set.
  92243. * @returns this effect.
  92244. */
  92245. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92246. /**
  92247. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92248. * @param uniformName Name of the variable.
  92249. * @param matrix matrix to be set.
  92250. * @returns this effect.
  92251. */
  92252. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92253. /**
  92254. * Sets a float on a uniform variable.
  92255. * @param uniformName Name of the variable.
  92256. * @param value value to be set.
  92257. * @returns this effect.
  92258. */
  92259. setFloat(uniformName: string, value: number): Effect;
  92260. /**
  92261. * Sets a boolean on a uniform variable.
  92262. * @param uniformName Name of the variable.
  92263. * @param bool value to be set.
  92264. * @returns this effect.
  92265. */
  92266. setBool(uniformName: string, bool: boolean): Effect;
  92267. /**
  92268. * Sets a Vector2 on a uniform variable.
  92269. * @param uniformName Name of the variable.
  92270. * @param vector2 vector2 to be set.
  92271. * @returns this effect.
  92272. */
  92273. setVector2(uniformName: string, vector2: Vector2): Effect;
  92274. /**
  92275. * Sets a float2 on a uniform variable.
  92276. * @param uniformName Name of the variable.
  92277. * @param x First float in float2.
  92278. * @param y Second float in float2.
  92279. * @returns this effect.
  92280. */
  92281. setFloat2(uniformName: string, x: number, y: number): Effect;
  92282. /**
  92283. * Sets a Vector3 on a uniform variable.
  92284. * @param uniformName Name of the variable.
  92285. * @param vector3 Value to be set.
  92286. * @returns this effect.
  92287. */
  92288. setVector3(uniformName: string, vector3: Vector3): Effect;
  92289. /**
  92290. * Sets a float3 on a uniform variable.
  92291. * @param uniformName Name of the variable.
  92292. * @param x First float in float3.
  92293. * @param y Second float in float3.
  92294. * @param z Third float in float3.
  92295. * @returns this effect.
  92296. */
  92297. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92298. /**
  92299. * Sets a Vector4 on a uniform variable.
  92300. * @param uniformName Name of the variable.
  92301. * @param vector4 Value to be set.
  92302. * @returns this effect.
  92303. */
  92304. setVector4(uniformName: string, vector4: Vector4): Effect;
  92305. /**
  92306. * Sets a float4 on a uniform variable.
  92307. * @param uniformName Name of the variable.
  92308. * @param x First float in float4.
  92309. * @param y Second float in float4.
  92310. * @param z Third float in float4.
  92311. * @param w Fourth float in float4.
  92312. * @returns this effect.
  92313. */
  92314. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92315. /**
  92316. * Sets a Color3 on a uniform variable.
  92317. * @param uniformName Name of the variable.
  92318. * @param color3 Value to be set.
  92319. * @returns this effect.
  92320. */
  92321. setColor3(uniformName: string, color3: Color3): Effect;
  92322. /**
  92323. * Sets a Color4 on a uniform variable.
  92324. * @param uniformName Name of the variable.
  92325. * @param color3 Value to be set.
  92326. * @param alpha Alpha value to be set.
  92327. * @returns this effect.
  92328. */
  92329. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92330. /**
  92331. * Sets a Color4 on a uniform variable
  92332. * @param uniformName defines the name of the variable
  92333. * @param color4 defines the value to be set
  92334. * @returns this effect.
  92335. */
  92336. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92337. /** Release all associated resources */
  92338. dispose(): void;
  92339. /**
  92340. * This function will add a new shader to the shader store
  92341. * @param name the name of the shader
  92342. * @param pixelShader optional pixel shader content
  92343. * @param vertexShader optional vertex shader content
  92344. */
  92345. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92346. /**
  92347. * Store of each shader (The can be looked up using effect.key)
  92348. */
  92349. static ShadersStore: {
  92350. [key: string]: string;
  92351. };
  92352. /**
  92353. * Store of each included file for a shader (The can be looked up using effect.key)
  92354. */
  92355. static IncludesShadersStore: {
  92356. [key: string]: string;
  92357. };
  92358. /**
  92359. * Resets the cache of effects.
  92360. */
  92361. static ResetCache(): void;
  92362. }
  92363. }
  92364. declare module BABYLON {
  92365. /**
  92366. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92367. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92368. * 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;
  92369. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92370. */
  92371. export class ColorCurves {
  92372. private _dirty;
  92373. private _tempColor;
  92374. private _globalCurve;
  92375. private _highlightsCurve;
  92376. private _midtonesCurve;
  92377. private _shadowsCurve;
  92378. private _positiveCurve;
  92379. private _negativeCurve;
  92380. private _globalHue;
  92381. private _globalDensity;
  92382. private _globalSaturation;
  92383. private _globalExposure;
  92384. /**
  92385. * Gets the global Hue value.
  92386. * 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).
  92387. */
  92388. /**
  92389. * Sets the global Hue value.
  92390. * 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).
  92391. */
  92392. globalHue: number;
  92393. /**
  92394. * Gets the global Density value.
  92395. * 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.
  92396. * Values less than zero provide a filter of opposite hue.
  92397. */
  92398. /**
  92399. * Sets the global Density value.
  92400. * 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.
  92401. * Values less than zero provide a filter of opposite hue.
  92402. */
  92403. globalDensity: number;
  92404. /**
  92405. * Gets the global Saturation value.
  92406. * 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.
  92407. */
  92408. /**
  92409. * Sets the global Saturation value.
  92410. * 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.
  92411. */
  92412. globalSaturation: number;
  92413. /**
  92414. * Gets the global Exposure value.
  92415. * 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.
  92416. */
  92417. /**
  92418. * Sets the global Exposure value.
  92419. * 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.
  92420. */
  92421. globalExposure: number;
  92422. private _highlightsHue;
  92423. private _highlightsDensity;
  92424. private _highlightsSaturation;
  92425. private _highlightsExposure;
  92426. /**
  92427. * Gets the highlights Hue value.
  92428. * 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).
  92429. */
  92430. /**
  92431. * Sets the highlights Hue value.
  92432. * 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).
  92433. */
  92434. highlightsHue: number;
  92435. /**
  92436. * Gets the highlights Density value.
  92437. * 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.
  92438. * Values less than zero provide a filter of opposite hue.
  92439. */
  92440. /**
  92441. * Sets the highlights Density value.
  92442. * 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.
  92443. * Values less than zero provide a filter of opposite hue.
  92444. */
  92445. highlightsDensity: number;
  92446. /**
  92447. * Gets the highlights Saturation value.
  92448. * 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.
  92449. */
  92450. /**
  92451. * Sets the highlights Saturation value.
  92452. * 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.
  92453. */
  92454. highlightsSaturation: number;
  92455. /**
  92456. * Gets the highlights Exposure value.
  92457. * 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.
  92458. */
  92459. /**
  92460. * Sets the highlights Exposure value.
  92461. * 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.
  92462. */
  92463. highlightsExposure: number;
  92464. private _midtonesHue;
  92465. private _midtonesDensity;
  92466. private _midtonesSaturation;
  92467. private _midtonesExposure;
  92468. /**
  92469. * Gets the midtones Hue value.
  92470. * 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).
  92471. */
  92472. /**
  92473. * Sets the midtones Hue value.
  92474. * 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).
  92475. */
  92476. midtonesHue: number;
  92477. /**
  92478. * Gets the midtones Density value.
  92479. * 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.
  92480. * Values less than zero provide a filter of opposite hue.
  92481. */
  92482. /**
  92483. * Sets the midtones Density value.
  92484. * 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.
  92485. * Values less than zero provide a filter of opposite hue.
  92486. */
  92487. midtonesDensity: number;
  92488. /**
  92489. * Gets the midtones Saturation value.
  92490. * 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.
  92491. */
  92492. /**
  92493. * Sets the midtones Saturation value.
  92494. * 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.
  92495. */
  92496. midtonesSaturation: number;
  92497. /**
  92498. * Gets the midtones Exposure value.
  92499. * 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.
  92500. */
  92501. /**
  92502. * Sets the midtones Exposure value.
  92503. * 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.
  92504. */
  92505. midtonesExposure: number;
  92506. private _shadowsHue;
  92507. private _shadowsDensity;
  92508. private _shadowsSaturation;
  92509. private _shadowsExposure;
  92510. /**
  92511. * Gets the shadows Hue value.
  92512. * 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).
  92513. */
  92514. /**
  92515. * Sets the shadows Hue value.
  92516. * 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).
  92517. */
  92518. shadowsHue: number;
  92519. /**
  92520. * Gets the shadows Density value.
  92521. * 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.
  92522. * Values less than zero provide a filter of opposite hue.
  92523. */
  92524. /**
  92525. * Sets the shadows Density value.
  92526. * 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.
  92527. * Values less than zero provide a filter of opposite hue.
  92528. */
  92529. shadowsDensity: number;
  92530. /**
  92531. * Gets the shadows Saturation value.
  92532. * 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.
  92533. */
  92534. /**
  92535. * Sets the shadows Saturation value.
  92536. * 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.
  92537. */
  92538. shadowsSaturation: number;
  92539. /**
  92540. * Gets the shadows Exposure value.
  92541. * 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.
  92542. */
  92543. /**
  92544. * Sets the shadows Exposure value.
  92545. * 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.
  92546. */
  92547. shadowsExposure: number;
  92548. /**
  92549. * Returns the class name
  92550. * @returns The class name
  92551. */
  92552. getClassName(): string;
  92553. /**
  92554. * Binds the color curves to the shader.
  92555. * @param colorCurves The color curve to bind
  92556. * @param effect The effect to bind to
  92557. * @param positiveUniform The positive uniform shader parameter
  92558. * @param neutralUniform The neutral uniform shader parameter
  92559. * @param negativeUniform The negative uniform shader parameter
  92560. */
  92561. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92562. /**
  92563. * Prepare the list of uniforms associated with the ColorCurves effects.
  92564. * @param uniformsList The list of uniforms used in the effect
  92565. */
  92566. static PrepareUniforms(uniformsList: string[]): void;
  92567. /**
  92568. * Returns color grading data based on a hue, density, saturation and exposure value.
  92569. * @param filterHue The hue of the color filter.
  92570. * @param filterDensity The density of the color filter.
  92571. * @param saturation The saturation.
  92572. * @param exposure The exposure.
  92573. * @param result The result data container.
  92574. */
  92575. private getColorGradingDataToRef;
  92576. /**
  92577. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92578. * @param value The input slider value in range [-100,100].
  92579. * @returns Adjusted value.
  92580. */
  92581. private static applyColorGradingSliderNonlinear;
  92582. /**
  92583. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92584. * @param hue The hue (H) input.
  92585. * @param saturation The saturation (S) input.
  92586. * @param brightness The brightness (B) input.
  92587. * @result An RGBA color represented as Vector4.
  92588. */
  92589. private static fromHSBToRef;
  92590. /**
  92591. * Returns a value clamped between min and max
  92592. * @param value The value to clamp
  92593. * @param min The minimum of value
  92594. * @param max The maximum of value
  92595. * @returns The clamped value.
  92596. */
  92597. private static clamp;
  92598. /**
  92599. * Clones the current color curve instance.
  92600. * @return The cloned curves
  92601. */
  92602. clone(): ColorCurves;
  92603. /**
  92604. * Serializes the current color curve instance to a json representation.
  92605. * @return a JSON representation
  92606. */
  92607. serialize(): any;
  92608. /**
  92609. * Parses the color curve from a json representation.
  92610. * @param source the JSON source to parse
  92611. * @return The parsed curves
  92612. */
  92613. static Parse(source: any): ColorCurves;
  92614. }
  92615. }
  92616. declare module BABYLON {
  92617. /**
  92618. * Interface to follow in your material defines to integrate easily the
  92619. * Image proccessing functions.
  92620. * @hidden
  92621. */
  92622. export interface IImageProcessingConfigurationDefines {
  92623. IMAGEPROCESSING: boolean;
  92624. VIGNETTE: boolean;
  92625. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92626. VIGNETTEBLENDMODEOPAQUE: boolean;
  92627. TONEMAPPING: boolean;
  92628. TONEMAPPING_ACES: boolean;
  92629. CONTRAST: boolean;
  92630. EXPOSURE: boolean;
  92631. COLORCURVES: boolean;
  92632. COLORGRADING: boolean;
  92633. COLORGRADING3D: boolean;
  92634. SAMPLER3DGREENDEPTH: boolean;
  92635. SAMPLER3DBGRMAP: boolean;
  92636. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92637. }
  92638. /**
  92639. * @hidden
  92640. */
  92641. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92642. IMAGEPROCESSING: boolean;
  92643. VIGNETTE: boolean;
  92644. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92645. VIGNETTEBLENDMODEOPAQUE: boolean;
  92646. TONEMAPPING: boolean;
  92647. TONEMAPPING_ACES: boolean;
  92648. CONTRAST: boolean;
  92649. COLORCURVES: boolean;
  92650. COLORGRADING: boolean;
  92651. COLORGRADING3D: boolean;
  92652. SAMPLER3DGREENDEPTH: boolean;
  92653. SAMPLER3DBGRMAP: boolean;
  92654. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92655. EXPOSURE: boolean;
  92656. constructor();
  92657. }
  92658. /**
  92659. * This groups together the common properties used for image processing either in direct forward pass
  92660. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92661. * or not.
  92662. */
  92663. export class ImageProcessingConfiguration {
  92664. /**
  92665. * Default tone mapping applied in BabylonJS.
  92666. */
  92667. static readonly TONEMAPPING_STANDARD: number;
  92668. /**
  92669. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92670. * to other engines rendering to increase portability.
  92671. */
  92672. static readonly TONEMAPPING_ACES: number;
  92673. /**
  92674. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92675. */
  92676. colorCurves: Nullable<ColorCurves>;
  92677. private _colorCurvesEnabled;
  92678. /**
  92679. * Gets wether the color curves effect is enabled.
  92680. */
  92681. /**
  92682. * Sets wether the color curves effect is enabled.
  92683. */
  92684. colorCurvesEnabled: boolean;
  92685. private _colorGradingTexture;
  92686. /**
  92687. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92688. */
  92689. /**
  92690. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92691. */
  92692. colorGradingTexture: Nullable<BaseTexture>;
  92693. private _colorGradingEnabled;
  92694. /**
  92695. * Gets wether the color grading effect is enabled.
  92696. */
  92697. /**
  92698. * Sets wether the color grading effect is enabled.
  92699. */
  92700. colorGradingEnabled: boolean;
  92701. private _colorGradingWithGreenDepth;
  92702. /**
  92703. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92704. */
  92705. /**
  92706. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92707. */
  92708. colorGradingWithGreenDepth: boolean;
  92709. private _colorGradingBGR;
  92710. /**
  92711. * Gets wether the color grading texture contains BGR values.
  92712. */
  92713. /**
  92714. * Sets wether the color grading texture contains BGR values.
  92715. */
  92716. colorGradingBGR: boolean;
  92717. /** @hidden */
  92718. _exposure: number;
  92719. /**
  92720. * Gets the Exposure used in the effect.
  92721. */
  92722. /**
  92723. * Sets the Exposure used in the effect.
  92724. */
  92725. exposure: number;
  92726. private _toneMappingEnabled;
  92727. /**
  92728. * Gets wether the tone mapping effect is enabled.
  92729. */
  92730. /**
  92731. * Sets wether the tone mapping effect is enabled.
  92732. */
  92733. toneMappingEnabled: boolean;
  92734. private _toneMappingType;
  92735. /**
  92736. * Gets the type of tone mapping effect.
  92737. */
  92738. /**
  92739. * Sets the type of tone mapping effect used in BabylonJS.
  92740. */
  92741. toneMappingType: number;
  92742. protected _contrast: number;
  92743. /**
  92744. * Gets the contrast used in the effect.
  92745. */
  92746. /**
  92747. * Sets the contrast used in the effect.
  92748. */
  92749. contrast: number;
  92750. /**
  92751. * Vignette stretch size.
  92752. */
  92753. vignetteStretch: number;
  92754. /**
  92755. * Vignette centre X Offset.
  92756. */
  92757. vignetteCentreX: number;
  92758. /**
  92759. * Vignette centre Y Offset.
  92760. */
  92761. vignetteCentreY: number;
  92762. /**
  92763. * Vignette weight or intensity of the vignette effect.
  92764. */
  92765. vignetteWeight: number;
  92766. /**
  92767. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92768. * if vignetteEnabled is set to true.
  92769. */
  92770. vignetteColor: Color4;
  92771. /**
  92772. * Camera field of view used by the Vignette effect.
  92773. */
  92774. vignetteCameraFov: number;
  92775. private _vignetteBlendMode;
  92776. /**
  92777. * Gets the vignette blend mode allowing different kind of effect.
  92778. */
  92779. /**
  92780. * Sets the vignette blend mode allowing different kind of effect.
  92781. */
  92782. vignetteBlendMode: number;
  92783. private _vignetteEnabled;
  92784. /**
  92785. * Gets wether the vignette effect is enabled.
  92786. */
  92787. /**
  92788. * Sets wether the vignette effect is enabled.
  92789. */
  92790. vignetteEnabled: boolean;
  92791. private _applyByPostProcess;
  92792. /**
  92793. * Gets wether the image processing is applied through a post process or not.
  92794. */
  92795. /**
  92796. * Sets wether the image processing is applied through a post process or not.
  92797. */
  92798. applyByPostProcess: boolean;
  92799. private _isEnabled;
  92800. /**
  92801. * Gets wether the image processing is enabled or not.
  92802. */
  92803. /**
  92804. * Sets wether the image processing is enabled or not.
  92805. */
  92806. isEnabled: boolean;
  92807. /**
  92808. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92809. */
  92810. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92811. /**
  92812. * Method called each time the image processing information changes requires to recompile the effect.
  92813. */
  92814. protected _updateParameters(): void;
  92815. /**
  92816. * Gets the current class name.
  92817. * @return "ImageProcessingConfiguration"
  92818. */
  92819. getClassName(): string;
  92820. /**
  92821. * Prepare the list of uniforms associated with the Image Processing effects.
  92822. * @param uniforms The list of uniforms used in the effect
  92823. * @param defines the list of defines currently in use
  92824. */
  92825. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92826. /**
  92827. * Prepare the list of samplers associated with the Image Processing effects.
  92828. * @param samplersList The list of uniforms used in the effect
  92829. * @param defines the list of defines currently in use
  92830. */
  92831. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92832. /**
  92833. * Prepare the list of defines associated to the shader.
  92834. * @param defines the list of defines to complete
  92835. * @param forPostProcess Define if we are currently in post process mode or not
  92836. */
  92837. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92838. /**
  92839. * Returns true if all the image processing information are ready.
  92840. * @returns True if ready, otherwise, false
  92841. */
  92842. isReady(): boolean;
  92843. /**
  92844. * Binds the image processing to the shader.
  92845. * @param effect The effect to bind to
  92846. * @param aspectRatio Define the current aspect ratio of the effect
  92847. */
  92848. bind(effect: Effect, aspectRatio?: number): void;
  92849. /**
  92850. * Clones the current image processing instance.
  92851. * @return The cloned image processing
  92852. */
  92853. clone(): ImageProcessingConfiguration;
  92854. /**
  92855. * Serializes the current image processing instance to a json representation.
  92856. * @return a JSON representation
  92857. */
  92858. serialize(): any;
  92859. /**
  92860. * Parses the image processing from a json representation.
  92861. * @param source the JSON source to parse
  92862. * @return The parsed image processing
  92863. */
  92864. static Parse(source: any): ImageProcessingConfiguration;
  92865. private static _VIGNETTEMODE_MULTIPLY;
  92866. private static _VIGNETTEMODE_OPAQUE;
  92867. /**
  92868. * Used to apply the vignette as a mix with the pixel color.
  92869. */
  92870. static readonly VIGNETTEMODE_MULTIPLY: number;
  92871. /**
  92872. * Used to apply the vignette as a replacement of the pixel color.
  92873. */
  92874. static readonly VIGNETTEMODE_OPAQUE: number;
  92875. }
  92876. }
  92877. declare module BABYLON {
  92878. /**
  92879. * This represents all the required information to add a fresnel effect on a material:
  92880. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92881. */
  92882. export class FresnelParameters {
  92883. private _isEnabled;
  92884. /**
  92885. * Define if the fresnel effect is enable or not.
  92886. */
  92887. isEnabled: boolean;
  92888. /**
  92889. * Define the color used on edges (grazing angle)
  92890. */
  92891. leftColor: Color3;
  92892. /**
  92893. * Define the color used on center
  92894. */
  92895. rightColor: Color3;
  92896. /**
  92897. * Define bias applied to computed fresnel term
  92898. */
  92899. bias: number;
  92900. /**
  92901. * Defined the power exponent applied to fresnel term
  92902. */
  92903. power: number;
  92904. /**
  92905. * Clones the current fresnel and its valuues
  92906. * @returns a clone fresnel configuration
  92907. */
  92908. clone(): FresnelParameters;
  92909. /**
  92910. * Serializes the current fresnel parameters to a JSON representation.
  92911. * @return the JSON serialization
  92912. */
  92913. serialize(): any;
  92914. /**
  92915. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92916. * @param parsedFresnelParameters Define the JSON representation
  92917. * @returns the parsed parameters
  92918. */
  92919. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92920. }
  92921. }
  92922. declare module BABYLON {
  92923. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92924. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92925. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92926. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92927. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92928. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92929. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92930. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92931. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92932. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92933. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92934. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92935. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92936. /**
  92937. * Decorator used to define property that can be serialized as reference to a camera
  92938. * @param sourceName defines the name of the property to decorate
  92939. */
  92940. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92941. /**
  92942. * Class used to help serialization objects
  92943. */
  92944. export class SerializationHelper {
  92945. /** @hidden */
  92946. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92947. /** @hidden */
  92948. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92949. /** @hidden */
  92950. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92951. /** @hidden */
  92952. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92953. /**
  92954. * Appends the serialized animations from the source animations
  92955. * @param source Source containing the animations
  92956. * @param destination Target to store the animations
  92957. */
  92958. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92959. /**
  92960. * Static function used to serialized a specific entity
  92961. * @param entity defines the entity to serialize
  92962. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92963. * @returns a JSON compatible object representing the serialization of the entity
  92964. */
  92965. static Serialize<T>(entity: T, serializationObject?: any): any;
  92966. /**
  92967. * Creates a new entity from a serialization data object
  92968. * @param creationFunction defines a function used to instanciated the new entity
  92969. * @param source defines the source serialization data
  92970. * @param scene defines the hosting scene
  92971. * @param rootUrl defines the root url for resources
  92972. * @returns a new entity
  92973. */
  92974. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92975. /**
  92976. * Clones an object
  92977. * @param creationFunction defines the function used to instanciate the new object
  92978. * @param source defines the source object
  92979. * @returns the cloned object
  92980. */
  92981. static Clone<T>(creationFunction: () => T, source: T): T;
  92982. /**
  92983. * Instanciates a new object based on a source one (some data will be shared between both object)
  92984. * @param creationFunction defines the function used to instanciate the new object
  92985. * @param source defines the source object
  92986. * @returns the new object
  92987. */
  92988. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92989. }
  92990. }
  92991. declare module BABYLON {
  92992. /**
  92993. * This is the base class of all the camera used in the application.
  92994. * @see http://doc.babylonjs.com/features/cameras
  92995. */
  92996. export class Camera extends Node {
  92997. /** @hidden */
  92998. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92999. /**
  93000. * This is the default projection mode used by the cameras.
  93001. * It helps recreating a feeling of perspective and better appreciate depth.
  93002. * This is the best way to simulate real life cameras.
  93003. */
  93004. static readonly PERSPECTIVE_CAMERA: number;
  93005. /**
  93006. * This helps creating camera with an orthographic mode.
  93007. * 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.
  93008. */
  93009. static readonly ORTHOGRAPHIC_CAMERA: number;
  93010. /**
  93011. * This is the default FOV mode for perspective cameras.
  93012. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93013. */
  93014. static readonly FOVMODE_VERTICAL_FIXED: number;
  93015. /**
  93016. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93017. */
  93018. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93019. /**
  93020. * This specifies ther is no need for a camera rig.
  93021. * Basically only one eye is rendered corresponding to the camera.
  93022. */
  93023. static readonly RIG_MODE_NONE: number;
  93024. /**
  93025. * Simulates a camera Rig with one blue eye and one red eye.
  93026. * This can be use with 3d blue and red glasses.
  93027. */
  93028. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93029. /**
  93030. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93031. */
  93032. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93033. /**
  93034. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93035. */
  93036. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93037. /**
  93038. * Defines that both eyes of the camera will be rendered over under each other.
  93039. */
  93040. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93041. /**
  93042. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93043. */
  93044. static readonly RIG_MODE_VR: number;
  93045. /**
  93046. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93047. */
  93048. static readonly RIG_MODE_WEBVR: number;
  93049. /**
  93050. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93051. */
  93052. static readonly RIG_MODE_CUSTOM: number;
  93053. /**
  93054. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93055. */
  93056. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93057. /**
  93058. * Define the input manager associated with the camera.
  93059. */
  93060. inputs: CameraInputsManager<Camera>;
  93061. /** @hidden */
  93062. _position: Vector3;
  93063. /**
  93064. * Define the current local position of the camera in the scene
  93065. */
  93066. position: Vector3;
  93067. /**
  93068. * The vector the camera should consider as up.
  93069. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93070. */
  93071. upVector: Vector3;
  93072. /**
  93073. * Define the current limit on the left side for an orthographic camera
  93074. * In scene unit
  93075. */
  93076. orthoLeft: Nullable<number>;
  93077. /**
  93078. * Define the current limit on the right side for an orthographic camera
  93079. * In scene unit
  93080. */
  93081. orthoRight: Nullable<number>;
  93082. /**
  93083. * Define the current limit on the bottom side for an orthographic camera
  93084. * In scene unit
  93085. */
  93086. orthoBottom: Nullable<number>;
  93087. /**
  93088. * Define the current limit on the top side for an orthographic camera
  93089. * In scene unit
  93090. */
  93091. orthoTop: Nullable<number>;
  93092. /**
  93093. * Field Of View is set in Radians. (default is 0.8)
  93094. */
  93095. fov: number;
  93096. /**
  93097. * Define the minimum distance the camera can see from.
  93098. * This is important to note that the depth buffer are not infinite and the closer it starts
  93099. * the more your scene might encounter depth fighting issue.
  93100. */
  93101. minZ: number;
  93102. /**
  93103. * Define the maximum distance the camera can see to.
  93104. * This is important to note that the depth buffer are not infinite and the further it end
  93105. * the more your scene might encounter depth fighting issue.
  93106. */
  93107. maxZ: number;
  93108. /**
  93109. * Define the default inertia of the camera.
  93110. * This helps giving a smooth feeling to the camera movement.
  93111. */
  93112. inertia: number;
  93113. /**
  93114. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  93115. */
  93116. mode: number;
  93117. /**
  93118. * Define wether the camera is intermediate.
  93119. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93120. */
  93121. isIntermediate: boolean;
  93122. /**
  93123. * Define the viewport of the camera.
  93124. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93125. */
  93126. viewport: Viewport;
  93127. /**
  93128. * Restricts the camera to viewing objects with the same layerMask.
  93129. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93130. */
  93131. layerMask: number;
  93132. /**
  93133. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93134. */
  93135. fovMode: number;
  93136. /**
  93137. * Rig mode of the camera.
  93138. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93139. * This is normally controlled byt the camera themselves as internal use.
  93140. */
  93141. cameraRigMode: number;
  93142. /**
  93143. * Defines the distance between both "eyes" in case of a RIG
  93144. */
  93145. interaxialDistance: number;
  93146. /**
  93147. * Defines if stereoscopic rendering is done side by side or over under.
  93148. */
  93149. isStereoscopicSideBySide: boolean;
  93150. /**
  93151. * 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
  93152. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93153. * else in the scene.
  93154. */
  93155. customRenderTargets: RenderTargetTexture[];
  93156. /**
  93157. * When set, the camera will render to this render target instead of the default canvas
  93158. */
  93159. outputRenderTarget: Nullable<RenderTargetTexture>;
  93160. /**
  93161. * Observable triggered when the camera view matrix has changed.
  93162. */
  93163. onViewMatrixChangedObservable: Observable<Camera>;
  93164. /**
  93165. * Observable triggered when the camera Projection matrix has changed.
  93166. */
  93167. onProjectionMatrixChangedObservable: Observable<Camera>;
  93168. /**
  93169. * Observable triggered when the inputs have been processed.
  93170. */
  93171. onAfterCheckInputsObservable: Observable<Camera>;
  93172. /**
  93173. * Observable triggered when reset has been called and applied to the camera.
  93174. */
  93175. onRestoreStateObservable: Observable<Camera>;
  93176. /** @hidden */
  93177. _cameraRigParams: any;
  93178. /** @hidden */
  93179. _rigCameras: Camera[];
  93180. /** @hidden */
  93181. _rigPostProcess: Nullable<PostProcess>;
  93182. protected _webvrViewMatrix: Matrix;
  93183. /** @hidden */
  93184. _skipRendering: boolean;
  93185. /** @hidden */
  93186. _projectionMatrix: Matrix;
  93187. /** @hidden */
  93188. _postProcesses: Nullable<PostProcess>[];
  93189. /** @hidden */
  93190. _activeMeshes: SmartArray<AbstractMesh>;
  93191. protected _globalPosition: Vector3;
  93192. /** @hidden */
  93193. _computedViewMatrix: Matrix;
  93194. private _doNotComputeProjectionMatrix;
  93195. private _transformMatrix;
  93196. private _frustumPlanes;
  93197. private _refreshFrustumPlanes;
  93198. private _storedFov;
  93199. private _stateStored;
  93200. /**
  93201. * Instantiates a new camera object.
  93202. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93203. * @see http://doc.babylonjs.com/features/cameras
  93204. * @param name Defines the name of the camera in the scene
  93205. * @param position Defines the position of the camera
  93206. * @param scene Defines the scene the camera belongs too
  93207. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93208. */
  93209. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93210. /**
  93211. * Store current camera state (fov, position, etc..)
  93212. * @returns the camera
  93213. */
  93214. storeState(): Camera;
  93215. /**
  93216. * Restores the camera state values if it has been stored. You must call storeState() first
  93217. */
  93218. protected _restoreStateValues(): boolean;
  93219. /**
  93220. * Restored camera state. You must call storeState() first.
  93221. * @returns true if restored and false otherwise
  93222. */
  93223. restoreState(): boolean;
  93224. /**
  93225. * Gets the class name of the camera.
  93226. * @returns the class name
  93227. */
  93228. getClassName(): string;
  93229. /** @hidden */
  93230. readonly _isCamera: boolean;
  93231. /**
  93232. * Gets a string representation of the camera useful for debug purpose.
  93233. * @param fullDetails Defines that a more verboe level of logging is required
  93234. * @returns the string representation
  93235. */
  93236. toString(fullDetails?: boolean): string;
  93237. /**
  93238. * Gets the current world space position of the camera.
  93239. */
  93240. readonly globalPosition: Vector3;
  93241. /**
  93242. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93243. * @returns the active meshe list
  93244. */
  93245. getActiveMeshes(): SmartArray<AbstractMesh>;
  93246. /**
  93247. * Check wether a mesh is part of the current active mesh list of the camera
  93248. * @param mesh Defines the mesh to check
  93249. * @returns true if active, false otherwise
  93250. */
  93251. isActiveMesh(mesh: Mesh): boolean;
  93252. /**
  93253. * Is this camera ready to be used/rendered
  93254. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93255. * @return true if the camera is ready
  93256. */
  93257. isReady(completeCheck?: boolean): boolean;
  93258. /** @hidden */
  93259. _initCache(): void;
  93260. /** @hidden */
  93261. _updateCache(ignoreParentClass?: boolean): void;
  93262. /** @hidden */
  93263. _isSynchronized(): boolean;
  93264. /** @hidden */
  93265. _isSynchronizedViewMatrix(): boolean;
  93266. /** @hidden */
  93267. _isSynchronizedProjectionMatrix(): boolean;
  93268. /**
  93269. * Attach the input controls to a specific dom element to get the input from.
  93270. * @param element Defines the element the controls should be listened from
  93271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93272. */
  93273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93274. /**
  93275. * Detach the current controls from the specified dom element.
  93276. * @param element Defines the element to stop listening the inputs from
  93277. */
  93278. detachControl(element: HTMLElement): void;
  93279. /**
  93280. * Update the camera state according to the different inputs gathered during the frame.
  93281. */
  93282. update(): void;
  93283. /** @hidden */
  93284. _checkInputs(): void;
  93285. /** @hidden */
  93286. readonly rigCameras: Camera[];
  93287. /**
  93288. * Gets the post process used by the rig cameras
  93289. */
  93290. readonly rigPostProcess: Nullable<PostProcess>;
  93291. /**
  93292. * Internal, gets the first post proces.
  93293. * @returns the first post process to be run on this camera.
  93294. */
  93295. _getFirstPostProcess(): Nullable<PostProcess>;
  93296. private _cascadePostProcessesToRigCams;
  93297. /**
  93298. * Attach a post process to the camera.
  93299. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93300. * @param postProcess The post process to attach to the camera
  93301. * @param insertAt The position of the post process in case several of them are in use in the scene
  93302. * @returns the position the post process has been inserted at
  93303. */
  93304. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93305. /**
  93306. * Detach a post process to the camera.
  93307. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93308. * @param postProcess The post process to detach from the camera
  93309. */
  93310. detachPostProcess(postProcess: PostProcess): void;
  93311. /**
  93312. * Gets the current world matrix of the camera
  93313. */
  93314. getWorldMatrix(): Matrix;
  93315. /** @hidden */
  93316. _getViewMatrix(): Matrix;
  93317. /**
  93318. * Gets the current view matrix of the camera.
  93319. * @param force forces the camera to recompute the matrix without looking at the cached state
  93320. * @returns the view matrix
  93321. */
  93322. getViewMatrix(force?: boolean): Matrix;
  93323. /**
  93324. * Freeze the projection matrix.
  93325. * It will prevent the cache check of the camera projection compute and can speed up perf
  93326. * if no parameter of the camera are meant to change
  93327. * @param projection Defines manually a projection if necessary
  93328. */
  93329. freezeProjectionMatrix(projection?: Matrix): void;
  93330. /**
  93331. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93332. */
  93333. unfreezeProjectionMatrix(): void;
  93334. /**
  93335. * Gets the current projection matrix of the camera.
  93336. * @param force forces the camera to recompute the matrix without looking at the cached state
  93337. * @returns the projection matrix
  93338. */
  93339. getProjectionMatrix(force?: boolean): Matrix;
  93340. /**
  93341. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93342. * @returns a Matrix
  93343. */
  93344. getTransformationMatrix(): Matrix;
  93345. private _updateFrustumPlanes;
  93346. /**
  93347. * Checks if a cullable object (mesh...) is in the camera frustum
  93348. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93349. * @param target The object to check
  93350. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93351. * @returns true if the object is in frustum otherwise false
  93352. */
  93353. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93354. /**
  93355. * Checks if a cullable object (mesh...) is in the camera frustum
  93356. * Unlike isInFrustum this cheks the full bounding box
  93357. * @param target The object to check
  93358. * @returns true if the object is in frustum otherwise false
  93359. */
  93360. isCompletelyInFrustum(target: ICullable): boolean;
  93361. /**
  93362. * Gets a ray in the forward direction from the camera.
  93363. * @param length Defines the length of the ray to create
  93364. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93365. * @param origin Defines the start point of the ray which defaults to the camera position
  93366. * @returns the forward ray
  93367. */
  93368. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93369. /**
  93370. * Releases resources associated with this node.
  93371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93373. */
  93374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93375. /** @hidden */
  93376. _isLeftCamera: boolean;
  93377. /**
  93378. * Gets the left camera of a rig setup in case of Rigged Camera
  93379. */
  93380. readonly isLeftCamera: boolean;
  93381. /** @hidden */
  93382. _isRightCamera: boolean;
  93383. /**
  93384. * Gets the right camera of a rig setup in case of Rigged Camera
  93385. */
  93386. readonly isRightCamera: boolean;
  93387. /**
  93388. * Gets the left camera of a rig setup in case of Rigged Camera
  93389. */
  93390. readonly leftCamera: Nullable<FreeCamera>;
  93391. /**
  93392. * Gets the right camera of a rig setup in case of Rigged Camera
  93393. */
  93394. readonly rightCamera: Nullable<FreeCamera>;
  93395. /**
  93396. * Gets the left camera target of a rig setup in case of Rigged Camera
  93397. * @returns the target position
  93398. */
  93399. getLeftTarget(): Nullable<Vector3>;
  93400. /**
  93401. * Gets the right camera target of a rig setup in case of Rigged Camera
  93402. * @returns the target position
  93403. */
  93404. getRightTarget(): Nullable<Vector3>;
  93405. /**
  93406. * @hidden
  93407. */
  93408. setCameraRigMode(mode: number, rigParams: any): void;
  93409. /** @hidden */
  93410. static _setStereoscopicRigMode(camera: Camera): void;
  93411. /** @hidden */
  93412. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93413. /** @hidden */
  93414. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93415. /** @hidden */
  93416. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93417. /** @hidden */
  93418. _getVRProjectionMatrix(): Matrix;
  93419. protected _updateCameraRotationMatrix(): void;
  93420. protected _updateWebVRCameraRotationMatrix(): void;
  93421. /**
  93422. * This function MUST be overwritten by the different WebVR cameras available.
  93423. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93424. * @hidden
  93425. */
  93426. _getWebVRProjectionMatrix(): Matrix;
  93427. /**
  93428. * This function MUST be overwritten by the different WebVR cameras available.
  93429. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93430. * @hidden
  93431. */
  93432. _getWebVRViewMatrix(): Matrix;
  93433. /** @hidden */
  93434. setCameraRigParameter(name: string, value: any): void;
  93435. /**
  93436. * needs to be overridden by children so sub has required properties to be copied
  93437. * @hidden
  93438. */
  93439. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93440. /**
  93441. * May need to be overridden by children
  93442. * @hidden
  93443. */
  93444. _updateRigCameras(): void;
  93445. /** @hidden */
  93446. _setupInputs(): void;
  93447. /**
  93448. * Serialiaze the camera setup to a json represention
  93449. * @returns the JSON representation
  93450. */
  93451. serialize(): any;
  93452. /**
  93453. * Clones the current camera.
  93454. * @param name The cloned camera name
  93455. * @returns the cloned camera
  93456. */
  93457. clone(name: string): Camera;
  93458. /**
  93459. * Gets the direction of the camera relative to a given local axis.
  93460. * @param localAxis Defines the reference axis to provide a relative direction.
  93461. * @return the direction
  93462. */
  93463. getDirection(localAxis: Vector3): Vector3;
  93464. /**
  93465. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93466. * @param localAxis Defines the reference axis to provide a relative direction.
  93467. * @param result Defines the vector to store the result in
  93468. */
  93469. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93470. /**
  93471. * Gets a camera constructor for a given camera type
  93472. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93473. * @param name The name of the camera the result will be able to instantiate
  93474. * @param scene The scene the result will construct the camera in
  93475. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93476. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93477. * @returns a factory method to construc the camera
  93478. */
  93479. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93480. /**
  93481. * Compute the world matrix of the camera.
  93482. * @returns the camera workd matrix
  93483. */
  93484. computeWorldMatrix(): Matrix;
  93485. /**
  93486. * Parse a JSON and creates the camera from the parsed information
  93487. * @param parsedCamera The JSON to parse
  93488. * @param scene The scene to instantiate the camera in
  93489. * @returns the newly constructed camera
  93490. */
  93491. static Parse(parsedCamera: any, scene: Scene): Camera;
  93492. }
  93493. }
  93494. declare module BABYLON {
  93495. /**
  93496. * Interface for any object that can request an animation frame
  93497. */
  93498. export interface ICustomAnimationFrameRequester {
  93499. /**
  93500. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93501. */
  93502. renderFunction?: Function;
  93503. /**
  93504. * Called to request the next frame to render to
  93505. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93506. */
  93507. requestAnimationFrame: Function;
  93508. /**
  93509. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93510. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93511. */
  93512. requestID?: number;
  93513. }
  93514. /**
  93515. * Interface containing an array of animations
  93516. */
  93517. export interface IAnimatable {
  93518. /**
  93519. * Array of animations
  93520. */
  93521. animations: Nullable<Array<Animation>>;
  93522. }
  93523. /** Interface used by value gradients (color, factor, ...) */
  93524. export interface IValueGradient {
  93525. /**
  93526. * Gets or sets the gradient value (between 0 and 1)
  93527. */
  93528. gradient: number;
  93529. }
  93530. /** Class used to store color4 gradient */
  93531. export class ColorGradient implements IValueGradient {
  93532. /**
  93533. * Gets or sets the gradient value (between 0 and 1)
  93534. */
  93535. gradient: number;
  93536. /**
  93537. * Gets or sets first associated color
  93538. */
  93539. color1: Color4;
  93540. /**
  93541. * Gets or sets second associated color
  93542. */
  93543. color2?: Color4;
  93544. /**
  93545. * Will get a color picked randomly between color1 and color2.
  93546. * If color2 is undefined then color1 will be used
  93547. * @param result defines the target Color4 to store the result in
  93548. */
  93549. getColorToRef(result: Color4): void;
  93550. }
  93551. /** Class used to store color 3 gradient */
  93552. export class Color3Gradient implements IValueGradient {
  93553. /**
  93554. * Gets or sets the gradient value (between 0 and 1)
  93555. */
  93556. gradient: number;
  93557. /**
  93558. * Gets or sets the associated color
  93559. */
  93560. color: Color3;
  93561. }
  93562. /** Class used to store factor gradient */
  93563. export class FactorGradient implements IValueGradient {
  93564. /**
  93565. * Gets or sets the gradient value (between 0 and 1)
  93566. */
  93567. gradient: number;
  93568. /**
  93569. * Gets or sets first associated factor
  93570. */
  93571. factor1: number;
  93572. /**
  93573. * Gets or sets second associated factor
  93574. */
  93575. factor2?: number;
  93576. /**
  93577. * Will get a number picked randomly between factor1 and factor2.
  93578. * If factor2 is undefined then factor1 will be used
  93579. * @returns the picked number
  93580. */
  93581. getFactor(): number;
  93582. }
  93583. /**
  93584. * @ignore
  93585. * Application error to support additional information when loading a file
  93586. */
  93587. export class LoadFileError extends Error {
  93588. /** defines the optional web request */
  93589. request?: WebRequest | undefined;
  93590. private static _setPrototypeOf;
  93591. /**
  93592. * Creates a new LoadFileError
  93593. * @param message defines the message of the error
  93594. * @param request defines the optional web request
  93595. */
  93596. constructor(message: string,
  93597. /** defines the optional web request */
  93598. request?: WebRequest | undefined);
  93599. }
  93600. /**
  93601. * Class used to define a retry strategy when error happens while loading assets
  93602. */
  93603. export class RetryStrategy {
  93604. /**
  93605. * Function used to defines an exponential back off strategy
  93606. * @param maxRetries defines the maximum number of retries (3 by default)
  93607. * @param baseInterval defines the interval between retries
  93608. * @returns the strategy function to use
  93609. */
  93610. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93611. }
  93612. /**
  93613. * File request interface
  93614. */
  93615. export interface IFileRequest {
  93616. /**
  93617. * Raised when the request is complete (success or error).
  93618. */
  93619. onCompleteObservable: Observable<IFileRequest>;
  93620. /**
  93621. * Aborts the request for a file.
  93622. */
  93623. abort: () => void;
  93624. }
  93625. /**
  93626. * Class containing a set of static utilities functions
  93627. */
  93628. export class Tools {
  93629. /**
  93630. * Gets or sets the base URL to use to load assets
  93631. */
  93632. static BaseUrl: string;
  93633. /**
  93634. * Enable/Disable Custom HTTP Request Headers globally.
  93635. * default = false
  93636. * @see CustomRequestHeaders
  93637. */
  93638. static UseCustomRequestHeaders: boolean;
  93639. /**
  93640. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93641. * i.e. when loading files, where the server/service expects an Authorization header
  93642. */
  93643. static CustomRequestHeaders: {
  93644. [key: string]: string;
  93645. };
  93646. /**
  93647. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93648. */
  93649. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93650. /**
  93651. * Default behaviour for cors in the application.
  93652. * It can be a string if the expected behavior is identical in the entire app.
  93653. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93654. */
  93655. static CorsBehavior: string | ((url: string | string[]) => string);
  93656. /**
  93657. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93658. * @ignorenaming
  93659. */
  93660. static UseFallbackTexture: boolean;
  93661. /**
  93662. * Use this object to register external classes like custom textures or material
  93663. * to allow the laoders to instantiate them
  93664. */
  93665. static RegisteredExternalClasses: {
  93666. [key: string]: Object;
  93667. };
  93668. /**
  93669. * Texture content used if a texture cannot loaded
  93670. * @ignorenaming
  93671. */
  93672. static fallbackTexture: string;
  93673. /**
  93674. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93675. * @param u defines the coordinate on X axis
  93676. * @param v defines the coordinate on Y axis
  93677. * @param width defines the width of the source data
  93678. * @param height defines the height of the source data
  93679. * @param pixels defines the source byte array
  93680. * @param color defines the output color
  93681. */
  93682. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93683. /**
  93684. * Interpolates between a and b via alpha
  93685. * @param a The lower value (returned when alpha = 0)
  93686. * @param b The upper value (returned when alpha = 1)
  93687. * @param alpha The interpolation-factor
  93688. * @return The mixed value
  93689. */
  93690. static Mix(a: number, b: number, alpha: number): number;
  93691. /**
  93692. * Tries to instantiate a new object from a given class name
  93693. * @param className defines the class name to instantiate
  93694. * @returns the new object or null if the system was not able to do the instantiation
  93695. */
  93696. static Instantiate(className: string): any;
  93697. /**
  93698. * Provides a slice function that will work even on IE
  93699. * @param data defines the array to slice
  93700. * @param start defines the start of the data (optional)
  93701. * @param end defines the end of the data (optional)
  93702. * @returns the new sliced array
  93703. */
  93704. static Slice<T>(data: T, start?: number, end?: number): T;
  93705. /**
  93706. * Polyfill for setImmediate
  93707. * @param action defines the action to execute after the current execution block
  93708. */
  93709. static SetImmediate(action: () => void): void;
  93710. /**
  93711. * Function indicating if a number is an exponent of 2
  93712. * @param value defines the value to test
  93713. * @returns true if the value is an exponent of 2
  93714. */
  93715. static IsExponentOfTwo(value: number): boolean;
  93716. private static _tmpFloatArray;
  93717. /**
  93718. * Returns the nearest 32-bit single precision float representation of a Number
  93719. * @param value A Number. If the parameter is of a different type, it will get converted
  93720. * to a number or to NaN if it cannot be converted
  93721. * @returns number
  93722. */
  93723. static FloatRound(value: number): number;
  93724. /**
  93725. * Find the next highest power of two.
  93726. * @param x Number to start search from.
  93727. * @return Next highest power of two.
  93728. */
  93729. static CeilingPOT(x: number): number;
  93730. /**
  93731. * Find the next lowest power of two.
  93732. * @param x Number to start search from.
  93733. * @return Next lowest power of two.
  93734. */
  93735. static FloorPOT(x: number): number;
  93736. /**
  93737. * Find the nearest power of two.
  93738. * @param x Number to start search from.
  93739. * @return Next nearest power of two.
  93740. */
  93741. static NearestPOT(x: number): number;
  93742. /**
  93743. * Get the closest exponent of two
  93744. * @param value defines the value to approximate
  93745. * @param max defines the maximum value to return
  93746. * @param mode defines how to define the closest value
  93747. * @returns closest exponent of two of the given value
  93748. */
  93749. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93750. /**
  93751. * Extracts the filename from a path
  93752. * @param path defines the path to use
  93753. * @returns the filename
  93754. */
  93755. static GetFilename(path: string): string;
  93756. /**
  93757. * Extracts the "folder" part of a path (everything before the filename).
  93758. * @param uri The URI to extract the info from
  93759. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93760. * @returns The "folder" part of the path
  93761. */
  93762. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93763. /**
  93764. * Extracts text content from a DOM element hierarchy
  93765. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93766. */
  93767. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93768. /**
  93769. * Convert an angle in radians to degrees
  93770. * @param angle defines the angle to convert
  93771. * @returns the angle in degrees
  93772. */
  93773. static ToDegrees(angle: number): number;
  93774. /**
  93775. * Convert an angle in degrees to radians
  93776. * @param angle defines the angle to convert
  93777. * @returns the angle in radians
  93778. */
  93779. static ToRadians(angle: number): number;
  93780. /**
  93781. * Encode a buffer to a base64 string
  93782. * @param buffer defines the buffer to encode
  93783. * @returns the encoded string
  93784. */
  93785. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93786. /**
  93787. * Extracts minimum and maximum values from a list of indexed positions
  93788. * @param positions defines the positions to use
  93789. * @param indices defines the indices to the positions
  93790. * @param indexStart defines the start index
  93791. * @param indexCount defines the end index
  93792. * @param bias defines bias value to add to the result
  93793. * @return minimum and maximum values
  93794. */
  93795. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93796. minimum: Vector3;
  93797. maximum: Vector3;
  93798. };
  93799. /**
  93800. * Extracts minimum and maximum values from a list of positions
  93801. * @param positions defines the positions to use
  93802. * @param start defines the start index in the positions array
  93803. * @param count defines the number of positions to handle
  93804. * @param bias defines bias value to add to the result
  93805. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93806. * @return minimum and maximum values
  93807. */
  93808. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93809. minimum: Vector3;
  93810. maximum: Vector3;
  93811. };
  93812. /**
  93813. * Returns an array if obj is not an array
  93814. * @param obj defines the object to evaluate as an array
  93815. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93816. * @returns either obj directly if obj is an array or a new array containing obj
  93817. */
  93818. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93819. /**
  93820. * Gets the pointer prefix to use
  93821. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93822. */
  93823. static GetPointerPrefix(): string;
  93824. /**
  93825. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93826. * @param func - the function to be called
  93827. * @param requester - the object that will request the next frame. Falls back to window.
  93828. * @returns frame number
  93829. */
  93830. static QueueNewFrame(func: () => void, requester?: any): number;
  93831. /**
  93832. * Ask the browser to promote the current element to fullscreen rendering mode
  93833. * @param element defines the DOM element to promote
  93834. */
  93835. static RequestFullscreen(element: HTMLElement): void;
  93836. /**
  93837. * Asks the browser to exit fullscreen mode
  93838. */
  93839. static ExitFullscreen(): void;
  93840. /**
  93841. * Ask the browser to promote the current element to pointerlock mode
  93842. * @param element defines the DOM element to promote
  93843. */
  93844. static RequestPointerlock(element: HTMLElement): void;
  93845. /**
  93846. * Asks the browser to exit pointerlock mode
  93847. */
  93848. static ExitPointerlock(): void;
  93849. /**
  93850. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93851. * @param url define the url we are trying
  93852. * @param element define the dom element where to configure the cors policy
  93853. */
  93854. static SetCorsBehavior(url: string | string[], element: {
  93855. crossOrigin: string | null;
  93856. }): void;
  93857. /**
  93858. * Removes unwanted characters from an url
  93859. * @param url defines the url to clean
  93860. * @returns the cleaned url
  93861. */
  93862. static CleanUrl(url: string): string;
  93863. /**
  93864. * Gets or sets a function used to pre-process url before using them to load assets
  93865. */
  93866. static PreprocessUrl: (url: string) => string;
  93867. /**
  93868. * Loads an image as an HTMLImageElement.
  93869. * @param input url string, ArrayBuffer, or Blob to load
  93870. * @param onLoad callback called when the image successfully loads
  93871. * @param onError callback called when the image fails to load
  93872. * @param offlineProvider offline provider for caching
  93873. * @returns the HTMLImageElement of the loaded image
  93874. */
  93875. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93876. /**
  93877. * Loads a file
  93878. * @param url url string, ArrayBuffer, or Blob to load
  93879. * @param onSuccess callback called when the file successfully loads
  93880. * @param onProgress callback called while file is loading (if the server supports this mode)
  93881. * @param offlineProvider defines the offline provider for caching
  93882. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93883. * @param onError callback called when the file fails to load
  93884. * @returns a file request object
  93885. */
  93886. 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;
  93887. /**
  93888. * Load a script (identified by an url). When the url returns, the
  93889. * content of this file is added into a new script element, attached to the DOM (body element)
  93890. * @param scriptUrl defines the url of the script to laod
  93891. * @param onSuccess defines the callback called when the script is loaded
  93892. * @param onError defines the callback to call if an error occurs
  93893. * @param scriptId defines the id of the script element
  93894. */
  93895. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93896. /**
  93897. * Load an asynchronous script (identified by an url). When the url returns, the
  93898. * content of this file is added into a new script element, attached to the DOM (body element)
  93899. * @param scriptUrl defines the url of the script to laod
  93900. * @param scriptId defines the id of the script element
  93901. * @returns a promise request object
  93902. */
  93903. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  93904. /**
  93905. * Loads a file from a blob
  93906. * @param fileToLoad defines the blob to use
  93907. * @param callback defines the callback to call when data is loaded
  93908. * @param progressCallback defines the callback to call during loading process
  93909. * @returns a file request object
  93910. */
  93911. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93912. /**
  93913. * Loads a file
  93914. * @param fileToLoad defines the file to load
  93915. * @param callback defines the callback to call when data is loaded
  93916. * @param progressCallBack defines the callback to call during loading process
  93917. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  93918. * @returns a file request object
  93919. */
  93920. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  93921. /**
  93922. * Creates a data url from a given string content
  93923. * @param content defines the content to convert
  93924. * @returns the new data url link
  93925. */
  93926. static FileAsURL(content: string): string;
  93927. /**
  93928. * Format the given number to a specific decimal format
  93929. * @param value defines the number to format
  93930. * @param decimals defines the number of decimals to use
  93931. * @returns the formatted string
  93932. */
  93933. static Format(value: number, decimals?: number): string;
  93934. /**
  93935. * Checks if a given vector is inside a specific range
  93936. * @param v defines the vector to test
  93937. * @param min defines the minimum range
  93938. * @param max defines the maximum range
  93939. */
  93940. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  93941. /**
  93942. * Tries to copy an object by duplicating every property
  93943. * @param source defines the source object
  93944. * @param destination defines the target object
  93945. * @param doNotCopyList defines a list of properties to avoid
  93946. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93947. */
  93948. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  93949. /**
  93950. * Gets a boolean indicating if the given object has no own property
  93951. * @param obj defines the object to test
  93952. * @returns true if object has no own property
  93953. */
  93954. static IsEmpty(obj: any): boolean;
  93955. /**
  93956. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  93957. * @param str Source string
  93958. * @param suffix Suffix to search for in the source string
  93959. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93960. */
  93961. static EndsWith(str: string, suffix: string): boolean;
  93962. /**
  93963. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  93964. * @param str Source string
  93965. * @param suffix Suffix to search for in the source string
  93966. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93967. */
  93968. static StartsWith(str: string, suffix: string): boolean;
  93969. /**
  93970. * Function used to register events at window level
  93971. * @param events defines the events to register
  93972. */
  93973. static RegisterTopRootEvents(events: {
  93974. name: string;
  93975. handler: Nullable<(e: FocusEvent) => any>;
  93976. }[]): void;
  93977. /**
  93978. * Function used to unregister events from window level
  93979. * @param events defines the events to unregister
  93980. */
  93981. static UnregisterTopRootEvents(events: {
  93982. name: string;
  93983. handler: Nullable<(e: FocusEvent) => any>;
  93984. }[]): void;
  93985. /**
  93986. * @ignore
  93987. */
  93988. static _ScreenshotCanvas: HTMLCanvasElement;
  93989. /**
  93990. * Dumps the current bound framebuffer
  93991. * @param width defines the rendering width
  93992. * @param height defines the rendering height
  93993. * @param engine defines the hosting engine
  93994. * @param successCallback defines the callback triggered once the data are available
  93995. * @param mimeType defines the mime type of the result
  93996. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  93997. */
  93998. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93999. /**
  94000. * Converts the canvas data to blob.
  94001. * This acts as a polyfill for browsers not supporting the to blob function.
  94002. * @param canvas Defines the canvas to extract the data from
  94003. * @param successCallback Defines the callback triggered once the data are available
  94004. * @param mimeType Defines the mime type of the result
  94005. */
  94006. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94007. /**
  94008. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94009. * @param successCallback defines the callback triggered once the data are available
  94010. * @param mimeType defines the mime type of the result
  94011. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94012. */
  94013. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94014. /**
  94015. * Downloads a blob in the browser
  94016. * @param blob defines the blob to download
  94017. * @param fileName defines the name of the downloaded file
  94018. */
  94019. static Download(blob: Blob, fileName: string): void;
  94020. /**
  94021. * Captures a screenshot of the current rendering
  94022. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94023. * @param engine defines the rendering engine
  94024. * @param camera defines the source camera
  94025. * @param size This parameter can be set to a single number or to an object with the
  94026. * following (optional) properties: precision, width, height. If a single number is passed,
  94027. * it will be used for both width and height. If an object is passed, the screenshot size
  94028. * will be derived from the parameters. The precision property is a multiplier allowing
  94029. * rendering at a higher or lower resolution
  94030. * @param successCallback defines the callback receives a single parameter which contains the
  94031. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94032. * src parameter of an <img> to display it
  94033. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94034. * Check your browser for supported MIME types
  94035. */
  94036. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94037. /**
  94038. * Generates an image screenshot from the specified camera.
  94039. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94040. * @param engine The engine to use for rendering
  94041. * @param camera The camera to use for rendering
  94042. * @param size This parameter can be set to a single number or to an object with the
  94043. * following (optional) properties: precision, width, height. If a single number is passed,
  94044. * it will be used for both width and height. If an object is passed, the screenshot size
  94045. * will be derived from the parameters. The precision property is a multiplier allowing
  94046. * rendering at a higher or lower resolution
  94047. * @param successCallback The callback receives a single parameter which contains the
  94048. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94049. * src parameter of an <img> to display it
  94050. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94051. * Check your browser for supported MIME types
  94052. * @param samples Texture samples (default: 1)
  94053. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94054. * @param fileName A name for for the downloaded file.
  94055. */
  94056. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94057. /**
  94058. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94059. * Be aware Math.random() could cause collisions, but:
  94060. * "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"
  94061. * @returns a pseudo random id
  94062. */
  94063. static RandomId(): string;
  94064. /**
  94065. * Test if the given uri is a base64 string
  94066. * @param uri The uri to test
  94067. * @return True if the uri is a base64 string or false otherwise
  94068. */
  94069. static IsBase64(uri: string): boolean;
  94070. /**
  94071. * Decode the given base64 uri.
  94072. * @param uri The uri to decode
  94073. * @return The decoded base64 data.
  94074. */
  94075. static DecodeBase64(uri: string): ArrayBuffer;
  94076. /**
  94077. * Gets the absolute url.
  94078. * @param url the input url
  94079. * @return the absolute url
  94080. */
  94081. static GetAbsoluteUrl(url: string): string;
  94082. /**
  94083. * No log
  94084. */
  94085. static readonly NoneLogLevel: number;
  94086. /**
  94087. * Only message logs
  94088. */
  94089. static readonly MessageLogLevel: number;
  94090. /**
  94091. * Only warning logs
  94092. */
  94093. static readonly WarningLogLevel: number;
  94094. /**
  94095. * Only error logs
  94096. */
  94097. static readonly ErrorLogLevel: number;
  94098. /**
  94099. * All logs
  94100. */
  94101. static readonly AllLogLevel: number;
  94102. /**
  94103. * Gets a value indicating the number of loading errors
  94104. * @ignorenaming
  94105. */
  94106. static readonly errorsCount: number;
  94107. /**
  94108. * Callback called when a new log is added
  94109. */
  94110. static OnNewCacheEntry: (entry: string) => void;
  94111. /**
  94112. * Log a message to the console
  94113. * @param message defines the message to log
  94114. */
  94115. static Log(message: string): void;
  94116. /**
  94117. * Write a warning message to the console
  94118. * @param message defines the message to log
  94119. */
  94120. static Warn(message: string): void;
  94121. /**
  94122. * Write an error message to the console
  94123. * @param message defines the message to log
  94124. */
  94125. static Error(message: string): void;
  94126. /**
  94127. * Gets current log cache (list of logs)
  94128. */
  94129. static readonly LogCache: string;
  94130. /**
  94131. * Clears the log cache
  94132. */
  94133. static ClearLogCache(): void;
  94134. /**
  94135. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94136. */
  94137. static LogLevels: number;
  94138. /**
  94139. * Checks if the loaded document was accessed via `file:`-Protocol.
  94140. * @returns boolean
  94141. */
  94142. static IsFileURL(): boolean;
  94143. /**
  94144. * Checks if the window object exists
  94145. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94146. */
  94147. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94148. /**
  94149. * No performance log
  94150. */
  94151. static readonly PerformanceNoneLogLevel: number;
  94152. /**
  94153. * Use user marks to log performance
  94154. */
  94155. static readonly PerformanceUserMarkLogLevel: number;
  94156. /**
  94157. * Log performance to the console
  94158. */
  94159. static readonly PerformanceConsoleLogLevel: number;
  94160. private static _performance;
  94161. /**
  94162. * Sets the current performance log level
  94163. */
  94164. static PerformanceLogLevel: number;
  94165. private static _StartPerformanceCounterDisabled;
  94166. private static _EndPerformanceCounterDisabled;
  94167. private static _StartUserMark;
  94168. private static _EndUserMark;
  94169. private static _StartPerformanceConsole;
  94170. private static _EndPerformanceConsole;
  94171. /**
  94172. * Starts a performance counter
  94173. */
  94174. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94175. /**
  94176. * Ends a specific performance coutner
  94177. */
  94178. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94179. /**
  94180. * Gets either window.performance.now() if supported or Date.now() else
  94181. */
  94182. static readonly Now: number;
  94183. /**
  94184. * This method will return the name of the class used to create the instance of the given object.
  94185. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94186. * @param object the object to get the class name from
  94187. * @param isType defines if the object is actually a type
  94188. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94189. */
  94190. static GetClassName(object: any, isType?: boolean): string;
  94191. /**
  94192. * Gets the first element of an array satisfying a given predicate
  94193. * @param array defines the array to browse
  94194. * @param predicate defines the predicate to use
  94195. * @returns null if not found or the element
  94196. */
  94197. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94198. /**
  94199. * This method will return the name of the full name of the class, including its owning module (if any).
  94200. * 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).
  94201. * @param object the object to get the class name from
  94202. * @param isType defines if the object is actually a type
  94203. * @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.
  94204. * @ignorenaming
  94205. */
  94206. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94207. /**
  94208. * Returns a promise that resolves after the given amount of time.
  94209. * @param delay Number of milliseconds to delay
  94210. * @returns Promise that resolves after the given amount of time
  94211. */
  94212. static DelayAsync(delay: number): Promise<void>;
  94213. /**
  94214. * Gets the current gradient from an array of IValueGradient
  94215. * @param ratio defines the current ratio to get
  94216. * @param gradients defines the array of IValueGradient
  94217. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94218. */
  94219. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94220. }
  94221. /**
  94222. * This class is used to track a performance counter which is number based.
  94223. * The user has access to many properties which give statistics of different nature.
  94224. *
  94225. * The implementer can track two kinds of Performance Counter: time and count.
  94226. * 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.
  94227. * 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.
  94228. */
  94229. export class PerfCounter {
  94230. /**
  94231. * Gets or sets a global boolean to turn on and off all the counters
  94232. */
  94233. static Enabled: boolean;
  94234. /**
  94235. * Returns the smallest value ever
  94236. */
  94237. readonly min: number;
  94238. /**
  94239. * Returns the biggest value ever
  94240. */
  94241. readonly max: number;
  94242. /**
  94243. * Returns the average value since the performance counter is running
  94244. */
  94245. readonly average: number;
  94246. /**
  94247. * Returns the average value of the last second the counter was monitored
  94248. */
  94249. readonly lastSecAverage: number;
  94250. /**
  94251. * Returns the current value
  94252. */
  94253. readonly current: number;
  94254. /**
  94255. * Gets the accumulated total
  94256. */
  94257. readonly total: number;
  94258. /**
  94259. * Gets the total value count
  94260. */
  94261. readonly count: number;
  94262. /**
  94263. * Creates a new counter
  94264. */
  94265. constructor();
  94266. /**
  94267. * Call this method to start monitoring a new frame.
  94268. * 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.
  94269. */
  94270. fetchNewFrame(): void;
  94271. /**
  94272. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94273. * @param newCount the count value to add to the monitored count
  94274. * @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.
  94275. */
  94276. addCount(newCount: number, fetchResult: boolean): void;
  94277. /**
  94278. * Start monitoring this performance counter
  94279. */
  94280. beginMonitoring(): void;
  94281. /**
  94282. * Compute the time lapsed since the previous beginMonitoring() call.
  94283. * @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
  94284. */
  94285. endMonitoring(newFrame?: boolean): void;
  94286. private _fetchResult;
  94287. private _startMonitoringTime;
  94288. private _min;
  94289. private _max;
  94290. private _average;
  94291. private _current;
  94292. private _totalValueCount;
  94293. private _totalAccumulated;
  94294. private _lastSecAverage;
  94295. private _lastSecAccumulated;
  94296. private _lastSecTime;
  94297. private _lastSecValueCount;
  94298. }
  94299. /**
  94300. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94301. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94302. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94303. * @param name The name of the class, case should be preserved
  94304. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94305. */
  94306. export function className(name: string, module?: string): (target: Object) => void;
  94307. /**
  94308. * An implementation of a loop for asynchronous functions.
  94309. */
  94310. export class AsyncLoop {
  94311. /**
  94312. * Defines the number of iterations for the loop
  94313. */
  94314. iterations: number;
  94315. /**
  94316. * Defines the current index of the loop.
  94317. */
  94318. index: number;
  94319. private _done;
  94320. private _fn;
  94321. private _successCallback;
  94322. /**
  94323. * Constructor.
  94324. * @param iterations the number of iterations.
  94325. * @param func the function to run each iteration
  94326. * @param successCallback the callback that will be called upon succesful execution
  94327. * @param offset starting offset.
  94328. */
  94329. constructor(
  94330. /**
  94331. * Defines the number of iterations for the loop
  94332. */
  94333. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94334. /**
  94335. * Execute the next iteration. Must be called after the last iteration was finished.
  94336. */
  94337. executeNext(): void;
  94338. /**
  94339. * Break the loop and run the success callback.
  94340. */
  94341. breakLoop(): void;
  94342. /**
  94343. * Create and run an async loop.
  94344. * @param iterations the number of iterations.
  94345. * @param fn the function to run each iteration
  94346. * @param successCallback the callback that will be called upon succesful execution
  94347. * @param offset starting offset.
  94348. * @returns the created async loop object
  94349. */
  94350. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94351. /**
  94352. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94353. * @param iterations total number of iterations
  94354. * @param syncedIterations number of synchronous iterations in each async iteration.
  94355. * @param fn the function to call each iteration.
  94356. * @param callback a success call back that will be called when iterating stops.
  94357. * @param breakFunction a break condition (optional)
  94358. * @param timeout timeout settings for the setTimeout function. default - 0.
  94359. * @returns the created async loop object
  94360. */
  94361. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94362. }
  94363. }
  94364. declare module BABYLON {
  94365. /** @hidden */
  94366. export interface ICollisionCoordinator {
  94367. createCollider(): Collider;
  94368. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94369. init(scene: Scene): void;
  94370. }
  94371. /** @hidden */
  94372. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94373. private _scene;
  94374. private _scaledPosition;
  94375. private _scaledVelocity;
  94376. private _finalPosition;
  94377. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94378. createCollider(): Collider;
  94379. init(scene: Scene): void;
  94380. private _collideWithWorld;
  94381. }
  94382. }
  94383. declare module BABYLON {
  94384. /**
  94385. * Class used to manage all inputs for the scene.
  94386. */
  94387. export class InputManager {
  94388. /** The distance in pixel that you have to move to prevent some events */
  94389. static DragMovementThreshold: number;
  94390. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94391. static LongPressDelay: number;
  94392. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94393. static DoubleClickDelay: number;
  94394. /** If you need to check double click without raising a single click at first click, enable this flag */
  94395. static ExclusiveDoubleClickMode: boolean;
  94396. private _wheelEventName;
  94397. private _onPointerMove;
  94398. private _onPointerDown;
  94399. private _onPointerUp;
  94400. private _initClickEvent;
  94401. private _initActionManager;
  94402. private _delayedSimpleClick;
  94403. private _delayedSimpleClickTimeout;
  94404. private _previousDelayedSimpleClickTimeout;
  94405. private _meshPickProceed;
  94406. private _previousButtonPressed;
  94407. private _currentPickResult;
  94408. private _previousPickResult;
  94409. private _totalPointersPressed;
  94410. private _doubleClickOccured;
  94411. private _pointerOverMesh;
  94412. private _pickedDownMesh;
  94413. private _pickedUpMesh;
  94414. private _pointerX;
  94415. private _pointerY;
  94416. private _unTranslatedPointerX;
  94417. private _unTranslatedPointerY;
  94418. private _startingPointerPosition;
  94419. private _previousStartingPointerPosition;
  94420. private _startingPointerTime;
  94421. private _previousStartingPointerTime;
  94422. private _pointerCaptures;
  94423. private _onKeyDown;
  94424. private _onKeyUp;
  94425. private _onCanvasFocusObserver;
  94426. private _onCanvasBlurObserver;
  94427. private _scene;
  94428. /**
  94429. * Creates a new InputManager
  94430. * @param scene defines the hosting scene
  94431. */
  94432. constructor(scene: Scene);
  94433. /**
  94434. * Gets the mesh that is currently under the pointer
  94435. */
  94436. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94437. /**
  94438. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94439. */
  94440. readonly unTranslatedPointer: Vector2;
  94441. /**
  94442. * Gets or sets the current on-screen X position of the pointer
  94443. */
  94444. pointerX: number;
  94445. /**
  94446. * Gets or sets the current on-screen Y position of the pointer
  94447. */
  94448. pointerY: number;
  94449. private _updatePointerPosition;
  94450. private _processPointerMove;
  94451. private _setRayOnPointerInfo;
  94452. private _checkPrePointerObservable;
  94453. /**
  94454. * Use this method to simulate a pointer move on a mesh
  94455. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94456. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94457. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94458. */
  94459. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94460. /**
  94461. * Use this method to simulate a pointer down on a mesh
  94462. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94463. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94464. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94465. */
  94466. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94467. private _processPointerDown;
  94468. /** @hidden */
  94469. _isPointerSwiping(): boolean;
  94470. /**
  94471. * Use this method to simulate a pointer up on a mesh
  94472. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94473. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94474. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94475. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94476. */
  94477. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94478. private _processPointerUp;
  94479. /**
  94480. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94481. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94482. * @returns true if the pointer was captured
  94483. */
  94484. isPointerCaptured(pointerId?: number): boolean;
  94485. /**
  94486. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94487. * @param attachUp defines if you want to attach events to pointerup
  94488. * @param attachDown defines if you want to attach events to pointerdown
  94489. * @param attachMove defines if you want to attach events to pointermove
  94490. */
  94491. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94492. /**
  94493. * Detaches all event handlers
  94494. */
  94495. detachControl(): void;
  94496. /**
  94497. * Force the value of meshUnderPointer
  94498. * @param mesh defines the mesh to use
  94499. */
  94500. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94501. /**
  94502. * Gets the mesh under the pointer
  94503. * @returns a Mesh or null if no mesh is under the pointer
  94504. */
  94505. getPointerOverMesh(): Nullable<AbstractMesh>;
  94506. }
  94507. }
  94508. declare module BABYLON {
  94509. /**
  94510. * This class defines the direct association between an animation and a target
  94511. */
  94512. export class TargetedAnimation {
  94513. /**
  94514. * Animation to perform
  94515. */
  94516. animation: Animation;
  94517. /**
  94518. * Target to animate
  94519. */
  94520. target: any;
  94521. /**
  94522. * Serialize the object
  94523. * @returns the JSON object representing the current entity
  94524. */
  94525. serialize(): any;
  94526. }
  94527. /**
  94528. * Use this class to create coordinated animations on multiple targets
  94529. */
  94530. export class AnimationGroup implements IDisposable {
  94531. /** The name of the animation group */
  94532. name: string;
  94533. private _scene;
  94534. private _targetedAnimations;
  94535. private _animatables;
  94536. private _from;
  94537. private _to;
  94538. private _isStarted;
  94539. private _isPaused;
  94540. private _speedRatio;
  94541. private _loopAnimation;
  94542. /**
  94543. * Gets or sets the unique id of the node
  94544. */
  94545. uniqueId: number;
  94546. /**
  94547. * This observable will notify when one animation have ended
  94548. */
  94549. onAnimationEndObservable: Observable<TargetedAnimation>;
  94550. /**
  94551. * Observer raised when one animation loops
  94552. */
  94553. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94554. /**
  94555. * This observable will notify when all animations have ended.
  94556. */
  94557. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94558. /**
  94559. * This observable will notify when all animations have paused.
  94560. */
  94561. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94562. /**
  94563. * This observable will notify when all animations are playing.
  94564. */
  94565. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94566. /**
  94567. * Gets the first frame
  94568. */
  94569. readonly from: number;
  94570. /**
  94571. * Gets the last frame
  94572. */
  94573. readonly to: number;
  94574. /**
  94575. * Define if the animations are started
  94576. */
  94577. readonly isStarted: boolean;
  94578. /**
  94579. * Gets a value indicating that the current group is playing
  94580. */
  94581. readonly isPlaying: boolean;
  94582. /**
  94583. * Gets or sets the speed ratio to use for all animations
  94584. */
  94585. /**
  94586. * Gets or sets the speed ratio to use for all animations
  94587. */
  94588. speedRatio: number;
  94589. /**
  94590. * Gets or sets if all animations should loop or not
  94591. */
  94592. loopAnimation: boolean;
  94593. /**
  94594. * Gets the targeted animations for this animation group
  94595. */
  94596. readonly targetedAnimations: Array<TargetedAnimation>;
  94597. /**
  94598. * returning the list of animatables controlled by this animation group.
  94599. */
  94600. readonly animatables: Array<Animatable>;
  94601. /**
  94602. * Instantiates a new Animation Group.
  94603. * This helps managing several animations at once.
  94604. * @see http://doc.babylonjs.com/how_to/group
  94605. * @param name Defines the name of the group
  94606. * @param scene Defines the scene the group belongs to
  94607. */
  94608. constructor(
  94609. /** The name of the animation group */
  94610. name: string, scene?: Nullable<Scene>);
  94611. /**
  94612. * Add an animation (with its target) in the group
  94613. * @param animation defines the animation we want to add
  94614. * @param target defines the target of the animation
  94615. * @returns the TargetedAnimation object
  94616. */
  94617. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94618. /**
  94619. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94620. * It can add constant keys at begin or end
  94621. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94622. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94623. * @returns the animation group
  94624. */
  94625. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94626. /**
  94627. * Start all animations on given targets
  94628. * @param loop defines if animations must loop
  94629. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94630. * @param from defines the from key (optional)
  94631. * @param to defines the to key (optional)
  94632. * @returns the current animation group
  94633. */
  94634. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94635. /**
  94636. * Pause all animations
  94637. * @returns the animation group
  94638. */
  94639. pause(): AnimationGroup;
  94640. /**
  94641. * Play all animations to initial state
  94642. * This function will start() the animations if they were not started or will restart() them if they were paused
  94643. * @param loop defines if animations must loop
  94644. * @returns the animation group
  94645. */
  94646. play(loop?: boolean): AnimationGroup;
  94647. /**
  94648. * Reset all animations to initial state
  94649. * @returns the animation group
  94650. */
  94651. reset(): AnimationGroup;
  94652. /**
  94653. * Restart animations from key 0
  94654. * @returns the animation group
  94655. */
  94656. restart(): AnimationGroup;
  94657. /**
  94658. * Stop all animations
  94659. * @returns the animation group
  94660. */
  94661. stop(): AnimationGroup;
  94662. /**
  94663. * Set animation weight for all animatables
  94664. * @param weight defines the weight to use
  94665. * @return the animationGroup
  94666. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94667. */
  94668. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94669. /**
  94670. * Synchronize and normalize all animatables with a source animatable
  94671. * @param root defines the root animatable to synchronize with
  94672. * @return the animationGroup
  94673. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94674. */
  94675. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94676. /**
  94677. * Goes to a specific frame in this animation group
  94678. * @param frame the frame number to go to
  94679. * @return the animationGroup
  94680. */
  94681. goToFrame(frame: number): AnimationGroup;
  94682. /**
  94683. * Dispose all associated resources
  94684. */
  94685. dispose(): void;
  94686. private _checkAnimationGroupEnded;
  94687. /**
  94688. * Clone the current animation group and returns a copy
  94689. * @param newName defines the name of the new group
  94690. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94691. * @returns the new aniamtion group
  94692. */
  94693. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94694. /**
  94695. * Serializes the animationGroup to an object
  94696. * @returns Serialized object
  94697. */
  94698. serialize(): any;
  94699. /**
  94700. * Returns a new AnimationGroup object parsed from the source provided.
  94701. * @param parsedAnimationGroup defines the source
  94702. * @param scene defines the scene that will receive the animationGroup
  94703. * @returns a new AnimationGroup
  94704. */
  94705. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94706. /**
  94707. * Returns the string "AnimationGroup"
  94708. * @returns "AnimationGroup"
  94709. */
  94710. getClassName(): string;
  94711. /**
  94712. * Creates a detailled string about the object
  94713. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94714. * @returns a string representing the object
  94715. */
  94716. toString(fullDetails?: boolean): string;
  94717. }
  94718. }
  94719. declare module BABYLON {
  94720. /**
  94721. * Define an interface for all classes that will hold resources
  94722. */
  94723. export interface IDisposable {
  94724. /**
  94725. * Releases all held resources
  94726. */
  94727. dispose(): void;
  94728. }
  94729. /** Interface defining initialization parameters for Scene class */
  94730. export interface SceneOptions {
  94731. /**
  94732. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94733. * It will improve performance when the number of geometries becomes important.
  94734. */
  94735. useGeometryUniqueIdsMap?: boolean;
  94736. /**
  94737. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94738. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94739. */
  94740. useMaterialMeshMap?: boolean;
  94741. /**
  94742. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94743. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94744. */
  94745. useClonedMeshhMap?: boolean;
  94746. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94747. virtual?: boolean;
  94748. }
  94749. /**
  94750. * Represents a scene to be rendered by the engine.
  94751. * @see http://doc.babylonjs.com/features/scene
  94752. */
  94753. export class Scene extends AbstractScene implements IAnimatable {
  94754. private static _uniqueIdCounter;
  94755. /** The fog is deactivated */
  94756. static readonly FOGMODE_NONE: number;
  94757. /** The fog density is following an exponential function */
  94758. static readonly FOGMODE_EXP: number;
  94759. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94760. static readonly FOGMODE_EXP2: number;
  94761. /** The fog density is following a linear function. */
  94762. static readonly FOGMODE_LINEAR: number;
  94763. /**
  94764. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94765. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94766. */
  94767. static MinDeltaTime: number;
  94768. /**
  94769. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94770. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94771. */
  94772. static MaxDeltaTime: number;
  94773. /**
  94774. * Factory used to create the default material.
  94775. * @param name The name of the material to create
  94776. * @param scene The scene to create the material for
  94777. * @returns The default material
  94778. */
  94779. static DefaultMaterialFactory(scene: Scene): Material;
  94780. /**
  94781. * Factory used to create the a collision coordinator.
  94782. * @returns The collision coordinator
  94783. */
  94784. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94785. /** @hidden */
  94786. _inputManager: InputManager;
  94787. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94788. cameraToUseForPointers: Nullable<Camera>;
  94789. /** @hidden */
  94790. readonly _isScene: boolean;
  94791. /**
  94792. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94793. */
  94794. autoClear: boolean;
  94795. /**
  94796. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94797. */
  94798. autoClearDepthAndStencil: boolean;
  94799. /**
  94800. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94801. */
  94802. clearColor: Color4;
  94803. /**
  94804. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94805. */
  94806. ambientColor: Color3;
  94807. /**
  94808. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94809. * It should only be one of the following (if not the default embedded one):
  94810. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94811. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94812. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94813. * The material properties need to be setup according to the type of texture in use.
  94814. */
  94815. environmentBRDFTexture: BaseTexture;
  94816. /** @hidden */
  94817. protected _environmentTexture: Nullable<BaseTexture>;
  94818. /**
  94819. * Texture used in all pbr material as the reflection texture.
  94820. * As in the majority of the scene they are the same (exception for multi room and so on),
  94821. * this is easier to reference from here than from all the materials.
  94822. */
  94823. /**
  94824. * Texture used in all pbr material as the reflection texture.
  94825. * As in the majority of the scene they are the same (exception for multi room and so on),
  94826. * this is easier to set here than in all the materials.
  94827. */
  94828. environmentTexture: Nullable<BaseTexture>;
  94829. /** @hidden */
  94830. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94831. /**
  94832. * Default image processing configuration used either in the rendering
  94833. * Forward main pass or through the imageProcessingPostProcess if present.
  94834. * As in the majority of the scene they are the same (exception for multi camera),
  94835. * this is easier to reference from here than from all the materials and post process.
  94836. *
  94837. * No setter as we it is a shared configuration, you can set the values instead.
  94838. */
  94839. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94840. private _forceWireframe;
  94841. /**
  94842. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94843. */
  94844. forceWireframe: boolean;
  94845. private _forcePointsCloud;
  94846. /**
  94847. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94848. */
  94849. forcePointsCloud: boolean;
  94850. /**
  94851. * Gets or sets the active clipplane 1
  94852. */
  94853. clipPlane: Nullable<Plane>;
  94854. /**
  94855. * Gets or sets the active clipplane 2
  94856. */
  94857. clipPlane2: Nullable<Plane>;
  94858. /**
  94859. * Gets or sets the active clipplane 3
  94860. */
  94861. clipPlane3: Nullable<Plane>;
  94862. /**
  94863. * Gets or sets the active clipplane 4
  94864. */
  94865. clipPlane4: Nullable<Plane>;
  94866. /**
  94867. * Gets or sets a boolean indicating if animations are enabled
  94868. */
  94869. animationsEnabled: boolean;
  94870. private _animationPropertiesOverride;
  94871. /**
  94872. * Gets or sets the animation properties override
  94873. */
  94874. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94875. /**
  94876. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94877. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94878. */
  94879. useConstantAnimationDeltaTime: boolean;
  94880. /**
  94881. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94882. * Please note that it requires to run a ray cast through the scene on every frame
  94883. */
  94884. constantlyUpdateMeshUnderPointer: boolean;
  94885. /**
  94886. * Defines the HTML cursor to use when hovering over interactive elements
  94887. */
  94888. hoverCursor: string;
  94889. /**
  94890. * Defines the HTML default cursor to use (empty by default)
  94891. */
  94892. defaultCursor: string;
  94893. /**
  94894. * This is used to call preventDefault() on pointer down
  94895. * in order to block unwanted artifacts like system double clicks
  94896. */
  94897. preventDefaultOnPointerDown: boolean;
  94898. /**
  94899. * This is used to call preventDefault() on pointer up
  94900. * in order to block unwanted artifacts like system double clicks
  94901. */
  94902. preventDefaultOnPointerUp: boolean;
  94903. /**
  94904. * Gets or sets user defined metadata
  94905. */
  94906. metadata: any;
  94907. /**
  94908. * For internal use only. Please do not use.
  94909. */
  94910. reservedDataStore: any;
  94911. /**
  94912. * Gets the name of the plugin used to load this scene (null by default)
  94913. */
  94914. loadingPluginName: string;
  94915. /**
  94916. * Use this array to add regular expressions used to disable offline support for specific urls
  94917. */
  94918. disableOfflineSupportExceptionRules: RegExp[];
  94919. /**
  94920. * An event triggered when the scene is disposed.
  94921. */
  94922. onDisposeObservable: Observable<Scene>;
  94923. private _onDisposeObserver;
  94924. /** Sets a function to be executed when this scene is disposed. */
  94925. onDispose: () => void;
  94926. /**
  94927. * An event triggered before rendering the scene (right after animations and physics)
  94928. */
  94929. onBeforeRenderObservable: Observable<Scene>;
  94930. private _onBeforeRenderObserver;
  94931. /** Sets a function to be executed before rendering this scene */
  94932. beforeRender: Nullable<() => void>;
  94933. /**
  94934. * An event triggered after rendering the scene
  94935. */
  94936. onAfterRenderObservable: Observable<Scene>;
  94937. /**
  94938. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  94939. */
  94940. onAfterRenderCameraObservable: Observable<Camera>;
  94941. private _onAfterRenderObserver;
  94942. /** Sets a function to be executed after rendering this scene */
  94943. afterRender: Nullable<() => void>;
  94944. /**
  94945. * An event triggered before animating the scene
  94946. */
  94947. onBeforeAnimationsObservable: Observable<Scene>;
  94948. /**
  94949. * An event triggered after animations processing
  94950. */
  94951. onAfterAnimationsObservable: Observable<Scene>;
  94952. /**
  94953. * An event triggered before draw calls are ready to be sent
  94954. */
  94955. onBeforeDrawPhaseObservable: Observable<Scene>;
  94956. /**
  94957. * An event triggered after draw calls have been sent
  94958. */
  94959. onAfterDrawPhaseObservable: Observable<Scene>;
  94960. /**
  94961. * An event triggered when the scene is ready
  94962. */
  94963. onReadyObservable: Observable<Scene>;
  94964. /**
  94965. * An event triggered before rendering a camera
  94966. */
  94967. onBeforeCameraRenderObservable: Observable<Camera>;
  94968. private _onBeforeCameraRenderObserver;
  94969. /** Sets a function to be executed before rendering a camera*/
  94970. beforeCameraRender: () => void;
  94971. /**
  94972. * An event triggered after rendering a camera
  94973. */
  94974. onAfterCameraRenderObservable: Observable<Camera>;
  94975. private _onAfterCameraRenderObserver;
  94976. /** Sets a function to be executed after rendering a camera*/
  94977. afterCameraRender: () => void;
  94978. /**
  94979. * An event triggered when active meshes evaluation is about to start
  94980. */
  94981. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  94982. /**
  94983. * An event triggered when active meshes evaluation is done
  94984. */
  94985. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  94986. /**
  94987. * An event triggered when particles rendering is about to start
  94988. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94989. */
  94990. onBeforeParticlesRenderingObservable: Observable<Scene>;
  94991. /**
  94992. * An event triggered when particles rendering is done
  94993. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94994. */
  94995. onAfterParticlesRenderingObservable: Observable<Scene>;
  94996. /**
  94997. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  94998. */
  94999. onDataLoadedObservable: Observable<Scene>;
  95000. /**
  95001. * An event triggered when a camera is created
  95002. */
  95003. onNewCameraAddedObservable: Observable<Camera>;
  95004. /**
  95005. * An event triggered when a camera is removed
  95006. */
  95007. onCameraRemovedObservable: Observable<Camera>;
  95008. /**
  95009. * An event triggered when a light is created
  95010. */
  95011. onNewLightAddedObservable: Observable<Light>;
  95012. /**
  95013. * An event triggered when a light is removed
  95014. */
  95015. onLightRemovedObservable: Observable<Light>;
  95016. /**
  95017. * An event triggered when a geometry is created
  95018. */
  95019. onNewGeometryAddedObservable: Observable<Geometry>;
  95020. /**
  95021. * An event triggered when a geometry is removed
  95022. */
  95023. onGeometryRemovedObservable: Observable<Geometry>;
  95024. /**
  95025. * An event triggered when a transform node is created
  95026. */
  95027. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95028. /**
  95029. * An event triggered when a transform node is removed
  95030. */
  95031. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95032. /**
  95033. * An event triggered when a mesh is created
  95034. */
  95035. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95036. /**
  95037. * An event triggered when a mesh is removed
  95038. */
  95039. onMeshRemovedObservable: Observable<AbstractMesh>;
  95040. /**
  95041. * An event triggered when a skeleton is created
  95042. */
  95043. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95044. /**
  95045. * An event triggered when a skeleton is removed
  95046. */
  95047. onSkeletonRemovedObservable: Observable<Skeleton>;
  95048. /**
  95049. * An event triggered when a material is created
  95050. */
  95051. onNewMaterialAddedObservable: Observable<Material>;
  95052. /**
  95053. * An event triggered when a material is removed
  95054. */
  95055. onMaterialRemovedObservable: Observable<Material>;
  95056. /**
  95057. * An event triggered when a texture is created
  95058. */
  95059. onNewTextureAddedObservable: Observable<BaseTexture>;
  95060. /**
  95061. * An event triggered when a texture is removed
  95062. */
  95063. onTextureRemovedObservable: Observable<BaseTexture>;
  95064. /**
  95065. * An event triggered when render targets are about to be rendered
  95066. * Can happen multiple times per frame.
  95067. */
  95068. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95069. /**
  95070. * An event triggered when render targets were rendered.
  95071. * Can happen multiple times per frame.
  95072. */
  95073. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95074. /**
  95075. * An event triggered before calculating deterministic simulation step
  95076. */
  95077. onBeforeStepObservable: Observable<Scene>;
  95078. /**
  95079. * An event triggered after calculating deterministic simulation step
  95080. */
  95081. onAfterStepObservable: Observable<Scene>;
  95082. /**
  95083. * An event triggered when the activeCamera property is updated
  95084. */
  95085. onActiveCameraChanged: Observable<Scene>;
  95086. /**
  95087. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95088. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95089. * 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)
  95090. */
  95091. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95092. /**
  95093. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95094. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95095. * 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)
  95096. */
  95097. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95098. /**
  95099. * This Observable will when a mesh has been imported into the scene.
  95100. */
  95101. onMeshImportedObservable: Observable<AbstractMesh>;
  95102. /**
  95103. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95104. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95105. */
  95106. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95107. /** @hidden */
  95108. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95109. /**
  95110. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95111. */
  95112. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95113. /**
  95114. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95115. */
  95116. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95117. /**
  95118. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95119. */
  95120. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95121. /** Callback called when a pointer move is detected */
  95122. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95123. /** Callback called when a pointer down is detected */
  95124. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95125. /** Callback called when a pointer up is detected */
  95126. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95127. /** Callback called when a pointer pick is detected */
  95128. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95129. /**
  95130. * 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).
  95131. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95132. */
  95133. onPrePointerObservable: Observable<PointerInfoPre>;
  95134. /**
  95135. * Observable event triggered each time an input event is received from the rendering canvas
  95136. */
  95137. onPointerObservable: Observable<PointerInfo>;
  95138. /**
  95139. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95140. */
  95141. readonly unTranslatedPointer: Vector2;
  95142. /**
  95143. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95144. */
  95145. static DragMovementThreshold: number;
  95146. /**
  95147. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95148. */
  95149. static LongPressDelay: number;
  95150. /**
  95151. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95152. */
  95153. static DoubleClickDelay: number;
  95154. /** If you need to check double click without raising a single click at first click, enable this flag */
  95155. static ExclusiveDoubleClickMode: boolean;
  95156. /** @hidden */
  95157. _mirroredCameraPosition: Nullable<Vector3>;
  95158. /**
  95159. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95160. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95161. */
  95162. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95163. /**
  95164. * Observable event triggered each time an keyboard event is received from the hosting window
  95165. */
  95166. onKeyboardObservable: Observable<KeyboardInfo>;
  95167. private _useRightHandedSystem;
  95168. /**
  95169. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95170. */
  95171. useRightHandedSystem: boolean;
  95172. private _timeAccumulator;
  95173. private _currentStepId;
  95174. private _currentInternalStep;
  95175. /**
  95176. * Sets the step Id used by deterministic lock step
  95177. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95178. * @param newStepId defines the step Id
  95179. */
  95180. setStepId(newStepId: number): void;
  95181. /**
  95182. * Gets the step Id used by deterministic lock step
  95183. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95184. * @returns the step Id
  95185. */
  95186. getStepId(): number;
  95187. /**
  95188. * Gets the internal step used by deterministic lock step
  95189. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95190. * @returns the internal step
  95191. */
  95192. getInternalStep(): number;
  95193. private _fogEnabled;
  95194. /**
  95195. * Gets or sets a boolean indicating if fog is enabled on this scene
  95196. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95197. * (Default is true)
  95198. */
  95199. fogEnabled: boolean;
  95200. private _fogMode;
  95201. /**
  95202. * Gets or sets the fog mode to use
  95203. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95204. * | mode | value |
  95205. * | --- | --- |
  95206. * | FOGMODE_NONE | 0 |
  95207. * | FOGMODE_EXP | 1 |
  95208. * | FOGMODE_EXP2 | 2 |
  95209. * | FOGMODE_LINEAR | 3 |
  95210. */
  95211. fogMode: number;
  95212. /**
  95213. * Gets or sets the fog color to use
  95214. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95215. * (Default is Color3(0.2, 0.2, 0.3))
  95216. */
  95217. fogColor: Color3;
  95218. /**
  95219. * Gets or sets the fog density to use
  95220. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95221. * (Default is 0.1)
  95222. */
  95223. fogDensity: number;
  95224. /**
  95225. * Gets or sets the fog start distance to use
  95226. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95227. * (Default is 0)
  95228. */
  95229. fogStart: number;
  95230. /**
  95231. * Gets or sets the fog end distance to use
  95232. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95233. * (Default is 1000)
  95234. */
  95235. fogEnd: number;
  95236. private _shadowsEnabled;
  95237. /**
  95238. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95239. */
  95240. shadowsEnabled: boolean;
  95241. private _lightsEnabled;
  95242. /**
  95243. * Gets or sets a boolean indicating if lights are enabled on this scene
  95244. */
  95245. lightsEnabled: boolean;
  95246. /** All of the active cameras added to this scene. */
  95247. activeCameras: Camera[];
  95248. /** @hidden */
  95249. _activeCamera: Nullable<Camera>;
  95250. /** Gets or sets the current active camera */
  95251. activeCamera: Nullable<Camera>;
  95252. private _defaultMaterial;
  95253. /** The default material used on meshes when no material is affected */
  95254. /** The default material used on meshes when no material is affected */
  95255. defaultMaterial: Material;
  95256. private _texturesEnabled;
  95257. /**
  95258. * Gets or sets a boolean indicating if textures are enabled on this scene
  95259. */
  95260. texturesEnabled: boolean;
  95261. /**
  95262. * Gets or sets a boolean indicating if particles are enabled on this scene
  95263. */
  95264. particlesEnabled: boolean;
  95265. /**
  95266. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95267. */
  95268. spritesEnabled: boolean;
  95269. private _skeletonsEnabled;
  95270. /**
  95271. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95272. */
  95273. skeletonsEnabled: boolean;
  95274. /**
  95275. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95276. */
  95277. lensFlaresEnabled: boolean;
  95278. /**
  95279. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95280. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95281. */
  95282. collisionsEnabled: boolean;
  95283. private _collisionCoordinator;
  95284. /** @hidden */
  95285. readonly collisionCoordinator: ICollisionCoordinator;
  95286. /**
  95287. * Defines the gravity applied to this scene (used only for collisions)
  95288. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95289. */
  95290. gravity: Vector3;
  95291. /**
  95292. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95293. */
  95294. postProcessesEnabled: boolean;
  95295. /**
  95296. * The list of postprocesses added to the scene
  95297. */
  95298. postProcesses: PostProcess[];
  95299. /**
  95300. * Gets the current postprocess manager
  95301. */
  95302. postProcessManager: PostProcessManager;
  95303. /**
  95304. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95305. */
  95306. renderTargetsEnabled: boolean;
  95307. /**
  95308. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95309. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95310. */
  95311. dumpNextRenderTargets: boolean;
  95312. /**
  95313. * The list of user defined render targets added to the scene
  95314. */
  95315. customRenderTargets: RenderTargetTexture[];
  95316. /**
  95317. * Defines if texture loading must be delayed
  95318. * If true, textures will only be loaded when they need to be rendered
  95319. */
  95320. useDelayedTextureLoading: boolean;
  95321. /**
  95322. * Gets the list of meshes imported to the scene through SceneLoader
  95323. */
  95324. importedMeshesFiles: String[];
  95325. /**
  95326. * Gets or sets a boolean indicating if probes are enabled on this scene
  95327. */
  95328. probesEnabled: boolean;
  95329. /**
  95330. * Gets or sets the current offline provider to use to store scene data
  95331. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95332. */
  95333. offlineProvider: IOfflineProvider;
  95334. /**
  95335. * Gets or sets the action manager associated with the scene
  95336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95337. */
  95338. actionManager: AbstractActionManager;
  95339. private _meshesForIntersections;
  95340. /**
  95341. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95342. */
  95343. proceduralTexturesEnabled: boolean;
  95344. private _engine;
  95345. private _totalVertices;
  95346. /** @hidden */
  95347. _activeIndices: PerfCounter;
  95348. /** @hidden */
  95349. _activeParticles: PerfCounter;
  95350. /** @hidden */
  95351. _activeBones: PerfCounter;
  95352. private _animationRatio;
  95353. /** @hidden */
  95354. _animationTimeLast: number;
  95355. /** @hidden */
  95356. _animationTime: number;
  95357. /**
  95358. * Gets or sets a general scale for animation speed
  95359. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95360. */
  95361. animationTimeScale: number;
  95362. /** @hidden */
  95363. _cachedMaterial: Nullable<Material>;
  95364. /** @hidden */
  95365. _cachedEffect: Nullable<Effect>;
  95366. /** @hidden */
  95367. _cachedVisibility: Nullable<number>;
  95368. private _renderId;
  95369. private _frameId;
  95370. private _executeWhenReadyTimeoutId;
  95371. private _intermediateRendering;
  95372. private _viewUpdateFlag;
  95373. private _projectionUpdateFlag;
  95374. /** @hidden */
  95375. _toBeDisposed: Nullable<IDisposable>[];
  95376. private _activeRequests;
  95377. /** @hidden */
  95378. _pendingData: any[];
  95379. private _isDisposed;
  95380. /**
  95381. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95382. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95383. */
  95384. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95385. private _activeMeshes;
  95386. private _processedMaterials;
  95387. private _renderTargets;
  95388. /** @hidden */
  95389. _activeParticleSystems: SmartArray<IParticleSystem>;
  95390. private _activeSkeletons;
  95391. private _softwareSkinnedMeshes;
  95392. private _renderingManager;
  95393. /** @hidden */
  95394. _activeAnimatables: Animatable[];
  95395. private _transformMatrix;
  95396. private _sceneUbo;
  95397. /** @hidden */
  95398. _viewMatrix: Matrix;
  95399. private _projectionMatrix;
  95400. /** @hidden */
  95401. _forcedViewPosition: Nullable<Vector3>;
  95402. /** @hidden */
  95403. _frustumPlanes: Plane[];
  95404. /**
  95405. * Gets the list of frustum planes (built from the active camera)
  95406. */
  95407. readonly frustumPlanes: Plane[];
  95408. /**
  95409. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95410. * This is useful if there are more lights that the maximum simulteanous authorized
  95411. */
  95412. requireLightSorting: boolean;
  95413. /** @hidden */
  95414. readonly useMaterialMeshMap: boolean;
  95415. /** @hidden */
  95416. readonly useClonedMeshhMap: boolean;
  95417. private _externalData;
  95418. private _uid;
  95419. /**
  95420. * @hidden
  95421. * Backing store of defined scene components.
  95422. */
  95423. _components: ISceneComponent[];
  95424. /**
  95425. * @hidden
  95426. * Backing store of defined scene components.
  95427. */
  95428. _serializableComponents: ISceneSerializableComponent[];
  95429. /**
  95430. * List of components to register on the next registration step.
  95431. */
  95432. private _transientComponents;
  95433. /**
  95434. * Registers the transient components if needed.
  95435. */
  95436. private _registerTransientComponents;
  95437. /**
  95438. * @hidden
  95439. * Add a component to the scene.
  95440. * Note that the ccomponent could be registered on th next frame if this is called after
  95441. * the register component stage.
  95442. * @param component Defines the component to add to the scene
  95443. */
  95444. _addComponent(component: ISceneComponent): void;
  95445. /**
  95446. * @hidden
  95447. * Gets a component from the scene.
  95448. * @param name defines the name of the component to retrieve
  95449. * @returns the component or null if not present
  95450. */
  95451. _getComponent(name: string): Nullable<ISceneComponent>;
  95452. /**
  95453. * @hidden
  95454. * Defines the actions happening before camera updates.
  95455. */
  95456. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95457. /**
  95458. * @hidden
  95459. * Defines the actions happening before clear the canvas.
  95460. */
  95461. _beforeClearStage: Stage<SimpleStageAction>;
  95462. /**
  95463. * @hidden
  95464. * Defines the actions when collecting render targets for the frame.
  95465. */
  95466. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95467. /**
  95468. * @hidden
  95469. * Defines the actions happening for one camera in the frame.
  95470. */
  95471. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95472. /**
  95473. * @hidden
  95474. * Defines the actions happening during the per mesh ready checks.
  95475. */
  95476. _isReadyForMeshStage: Stage<MeshStageAction>;
  95477. /**
  95478. * @hidden
  95479. * Defines the actions happening before evaluate active mesh checks.
  95480. */
  95481. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95482. /**
  95483. * @hidden
  95484. * Defines the actions happening during the evaluate sub mesh checks.
  95485. */
  95486. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95487. /**
  95488. * @hidden
  95489. * Defines the actions happening during the active mesh stage.
  95490. */
  95491. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95492. /**
  95493. * @hidden
  95494. * Defines the actions happening during the per camera render target step.
  95495. */
  95496. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95497. /**
  95498. * @hidden
  95499. * Defines the actions happening just before the active camera is drawing.
  95500. */
  95501. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95502. /**
  95503. * @hidden
  95504. * Defines the actions happening just before a render target is drawing.
  95505. */
  95506. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95507. /**
  95508. * @hidden
  95509. * Defines the actions happening just before a rendering group is drawing.
  95510. */
  95511. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95512. /**
  95513. * @hidden
  95514. * Defines the actions happening just before a mesh is drawing.
  95515. */
  95516. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95517. /**
  95518. * @hidden
  95519. * Defines the actions happening just after a mesh has been drawn.
  95520. */
  95521. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95522. /**
  95523. * @hidden
  95524. * Defines the actions happening just after a rendering group has been drawn.
  95525. */
  95526. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95527. /**
  95528. * @hidden
  95529. * Defines the actions happening just after the active camera has been drawn.
  95530. */
  95531. _afterCameraDrawStage: Stage<CameraStageAction>;
  95532. /**
  95533. * @hidden
  95534. * Defines the actions happening just after a render target has been drawn.
  95535. */
  95536. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95537. /**
  95538. * @hidden
  95539. * Defines the actions happening just after rendering all cameras and computing intersections.
  95540. */
  95541. _afterRenderStage: Stage<SimpleStageAction>;
  95542. /**
  95543. * @hidden
  95544. * Defines the actions happening when a pointer move event happens.
  95545. */
  95546. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95547. /**
  95548. * @hidden
  95549. * Defines the actions happening when a pointer down event happens.
  95550. */
  95551. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95552. /**
  95553. * @hidden
  95554. * Defines the actions happening when a pointer up event happens.
  95555. */
  95556. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95557. /**
  95558. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95559. */
  95560. private geometriesByUniqueId;
  95561. /**
  95562. * Creates a new Scene
  95563. * @param engine defines the engine to use to render this scene
  95564. * @param options defines the scene options
  95565. */
  95566. constructor(engine: Engine, options?: SceneOptions);
  95567. /**
  95568. * Gets a string idenfifying the name of the class
  95569. * @returns "Scene" string
  95570. */
  95571. getClassName(): string;
  95572. private _defaultMeshCandidates;
  95573. /**
  95574. * @hidden
  95575. */
  95576. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95577. private _defaultSubMeshCandidates;
  95578. /**
  95579. * @hidden
  95580. */
  95581. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95582. /**
  95583. * Sets the default candidate providers for the scene.
  95584. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95585. * and getCollidingSubMeshCandidates to their default function
  95586. */
  95587. setDefaultCandidateProviders(): void;
  95588. /**
  95589. * Gets the mesh that is currently under the pointer
  95590. */
  95591. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95592. /**
  95593. * Gets or sets the current on-screen X position of the pointer
  95594. */
  95595. pointerX: number;
  95596. /**
  95597. * Gets or sets the current on-screen Y position of the pointer
  95598. */
  95599. pointerY: number;
  95600. /**
  95601. * Gets the cached material (ie. the latest rendered one)
  95602. * @returns the cached material
  95603. */
  95604. getCachedMaterial(): Nullable<Material>;
  95605. /**
  95606. * Gets the cached effect (ie. the latest rendered one)
  95607. * @returns the cached effect
  95608. */
  95609. getCachedEffect(): Nullable<Effect>;
  95610. /**
  95611. * Gets the cached visibility state (ie. the latest rendered one)
  95612. * @returns the cached visibility state
  95613. */
  95614. getCachedVisibility(): Nullable<number>;
  95615. /**
  95616. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95617. * @param material defines the current material
  95618. * @param effect defines the current effect
  95619. * @param visibility defines the current visibility state
  95620. * @returns true if one parameter is not cached
  95621. */
  95622. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95623. /**
  95624. * Gets the engine associated with the scene
  95625. * @returns an Engine
  95626. */
  95627. getEngine(): Engine;
  95628. /**
  95629. * Gets the total number of vertices rendered per frame
  95630. * @returns the total number of vertices rendered per frame
  95631. */
  95632. getTotalVertices(): number;
  95633. /**
  95634. * Gets the performance counter for total vertices
  95635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95636. */
  95637. readonly totalVerticesPerfCounter: PerfCounter;
  95638. /**
  95639. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95640. * @returns the total number of active indices rendered per frame
  95641. */
  95642. getActiveIndices(): number;
  95643. /**
  95644. * Gets the performance counter for active indices
  95645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95646. */
  95647. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95648. /**
  95649. * Gets the total number of active particles rendered per frame
  95650. * @returns the total number of active particles rendered per frame
  95651. */
  95652. getActiveParticles(): number;
  95653. /**
  95654. * Gets the performance counter for active particles
  95655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95656. */
  95657. readonly activeParticlesPerfCounter: PerfCounter;
  95658. /**
  95659. * Gets the total number of active bones rendered per frame
  95660. * @returns the total number of active bones rendered per frame
  95661. */
  95662. getActiveBones(): number;
  95663. /**
  95664. * Gets the performance counter for active bones
  95665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95666. */
  95667. readonly activeBonesPerfCounter: PerfCounter;
  95668. /**
  95669. * Gets the array of active meshes
  95670. * @returns an array of AbstractMesh
  95671. */
  95672. getActiveMeshes(): SmartArray<AbstractMesh>;
  95673. /**
  95674. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95675. * @returns a number
  95676. */
  95677. getAnimationRatio(): number;
  95678. /**
  95679. * Gets an unique Id for the current render phase
  95680. * @returns a number
  95681. */
  95682. getRenderId(): number;
  95683. /**
  95684. * Gets an unique Id for the current frame
  95685. * @returns a number
  95686. */
  95687. getFrameId(): number;
  95688. /** Call this function if you want to manually increment the render Id*/
  95689. incrementRenderId(): void;
  95690. private _createUbo;
  95691. /**
  95692. * Use this method to simulate a pointer move on a mesh
  95693. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95694. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95695. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95696. * @returns the current scene
  95697. */
  95698. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95699. /**
  95700. * Use this method to simulate a pointer down on a mesh
  95701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95704. * @returns the current scene
  95705. */
  95706. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95707. /**
  95708. * Use this method to simulate a pointer up on a mesh
  95709. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95710. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95711. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95712. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95713. * @returns the current scene
  95714. */
  95715. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95716. /**
  95717. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95718. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95719. * @returns true if the pointer was captured
  95720. */
  95721. isPointerCaptured(pointerId?: number): boolean;
  95722. /**
  95723. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95724. * @param attachUp defines if you want to attach events to pointerup
  95725. * @param attachDown defines if you want to attach events to pointerdown
  95726. * @param attachMove defines if you want to attach events to pointermove
  95727. */
  95728. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95729. /** Detaches all event handlers*/
  95730. detachControl(): void;
  95731. /**
  95732. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95733. * Delay loaded resources are not taking in account
  95734. * @return true if all required resources are ready
  95735. */
  95736. isReady(): boolean;
  95737. /** Resets all cached information relative to material (including effect and visibility) */
  95738. resetCachedMaterial(): void;
  95739. /**
  95740. * Registers a function to be called before every frame render
  95741. * @param func defines the function to register
  95742. */
  95743. registerBeforeRender(func: () => void): void;
  95744. /**
  95745. * Unregisters a function called before every frame render
  95746. * @param func defines the function to unregister
  95747. */
  95748. unregisterBeforeRender(func: () => void): void;
  95749. /**
  95750. * Registers a function to be called after every frame render
  95751. * @param func defines the function to register
  95752. */
  95753. registerAfterRender(func: () => void): void;
  95754. /**
  95755. * Unregisters a function called after every frame render
  95756. * @param func defines the function to unregister
  95757. */
  95758. unregisterAfterRender(func: () => void): void;
  95759. private _executeOnceBeforeRender;
  95760. /**
  95761. * The provided function will run before render once and will be disposed afterwards.
  95762. * A timeout delay can be provided so that the function will be executed in N ms.
  95763. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95764. * @param func The function to be executed.
  95765. * @param timeout optional delay in ms
  95766. */
  95767. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95768. /** @hidden */
  95769. _addPendingData(data: any): void;
  95770. /** @hidden */
  95771. _removePendingData(data: any): void;
  95772. /**
  95773. * Returns the number of items waiting to be loaded
  95774. * @returns the number of items waiting to be loaded
  95775. */
  95776. getWaitingItemsCount(): number;
  95777. /**
  95778. * Returns a boolean indicating if the scene is still loading data
  95779. */
  95780. readonly isLoading: boolean;
  95781. /**
  95782. * Registers a function to be executed when the scene is ready
  95783. * @param {Function} func - the function to be executed
  95784. */
  95785. executeWhenReady(func: () => void): void;
  95786. /**
  95787. * Returns a promise that resolves when the scene is ready
  95788. * @returns A promise that resolves when the scene is ready
  95789. */
  95790. whenReadyAsync(): Promise<void>;
  95791. /** @hidden */
  95792. _checkIsReady(): void;
  95793. /**
  95794. * Gets all animatable attached to the scene
  95795. */
  95796. readonly animatables: Animatable[];
  95797. /**
  95798. * Resets the last animation time frame.
  95799. * Useful to override when animations start running when loading a scene for the first time.
  95800. */
  95801. resetLastAnimationTimeFrame(): void;
  95802. /**
  95803. * Gets the current view matrix
  95804. * @returns a Matrix
  95805. */
  95806. getViewMatrix(): Matrix;
  95807. /**
  95808. * Gets the current projection matrix
  95809. * @returns a Matrix
  95810. */
  95811. getProjectionMatrix(): Matrix;
  95812. /**
  95813. * Gets the current transform matrix
  95814. * @returns a Matrix made of View * Projection
  95815. */
  95816. getTransformMatrix(): Matrix;
  95817. /**
  95818. * Sets the current transform matrix
  95819. * @param viewL defines the View matrix to use
  95820. * @param projectionL defines the Projection matrix to use
  95821. * @param viewR defines the right View matrix to use (if provided)
  95822. * @param projectionR defines the right Projection matrix to use (if provided)
  95823. */
  95824. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95825. /**
  95826. * Gets the uniform buffer used to store scene data
  95827. * @returns a UniformBuffer
  95828. */
  95829. getSceneUniformBuffer(): UniformBuffer;
  95830. /**
  95831. * Gets an unique (relatively to the current scene) Id
  95832. * @returns an unique number for the scene
  95833. */
  95834. getUniqueId(): number;
  95835. /**
  95836. * Add a mesh to the list of scene's meshes
  95837. * @param newMesh defines the mesh to add
  95838. * @param recursive if all child meshes should also be added to the scene
  95839. */
  95840. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95841. /**
  95842. * Remove a mesh for the list of scene's meshes
  95843. * @param toRemove defines the mesh to remove
  95844. * @param recursive if all child meshes should also be removed from the scene
  95845. * @returns the index where the mesh was in the mesh list
  95846. */
  95847. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95848. /**
  95849. * Add a transform node to the list of scene's transform nodes
  95850. * @param newTransformNode defines the transform node to add
  95851. */
  95852. addTransformNode(newTransformNode: TransformNode): void;
  95853. /**
  95854. * Remove a transform node for the list of scene's transform nodes
  95855. * @param toRemove defines the transform node to remove
  95856. * @returns the index where the transform node was in the transform node list
  95857. */
  95858. removeTransformNode(toRemove: TransformNode): number;
  95859. /**
  95860. * Remove a skeleton for the list of scene's skeletons
  95861. * @param toRemove defines the skeleton to remove
  95862. * @returns the index where the skeleton was in the skeleton list
  95863. */
  95864. removeSkeleton(toRemove: Skeleton): number;
  95865. /**
  95866. * Remove a morph target for the list of scene's morph targets
  95867. * @param toRemove defines the morph target to remove
  95868. * @returns the index where the morph target was in the morph target list
  95869. */
  95870. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95871. /**
  95872. * Remove a light for the list of scene's lights
  95873. * @param toRemove defines the light to remove
  95874. * @returns the index where the light was in the light list
  95875. */
  95876. removeLight(toRemove: Light): number;
  95877. /**
  95878. * Remove a camera for the list of scene's cameras
  95879. * @param toRemove defines the camera to remove
  95880. * @returns the index where the camera was in the camera list
  95881. */
  95882. removeCamera(toRemove: Camera): number;
  95883. /**
  95884. * Remove a particle system for the list of scene's particle systems
  95885. * @param toRemove defines the particle system to remove
  95886. * @returns the index where the particle system was in the particle system list
  95887. */
  95888. removeParticleSystem(toRemove: IParticleSystem): number;
  95889. /**
  95890. * Remove a animation for the list of scene's animations
  95891. * @param toRemove defines the animation to remove
  95892. * @returns the index where the animation was in the animation list
  95893. */
  95894. removeAnimation(toRemove: Animation): number;
  95895. /**
  95896. * Will stop the animation of the given target
  95897. * @param target - the target
  95898. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95899. * @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)
  95900. */
  95901. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95902. /**
  95903. * Removes the given animation group from this scene.
  95904. * @param toRemove The animation group to remove
  95905. * @returns The index of the removed animation group
  95906. */
  95907. removeAnimationGroup(toRemove: AnimationGroup): number;
  95908. /**
  95909. * Removes the given multi-material from this scene.
  95910. * @param toRemove The multi-material to remove
  95911. * @returns The index of the removed multi-material
  95912. */
  95913. removeMultiMaterial(toRemove: MultiMaterial): number;
  95914. /**
  95915. * Removes the given material from this scene.
  95916. * @param toRemove The material to remove
  95917. * @returns The index of the removed material
  95918. */
  95919. removeMaterial(toRemove: Material): number;
  95920. /**
  95921. * Removes the given action manager from this scene.
  95922. * @param toRemove The action manager to remove
  95923. * @returns The index of the removed action manager
  95924. */
  95925. removeActionManager(toRemove: AbstractActionManager): number;
  95926. /**
  95927. * Removes the given texture from this scene.
  95928. * @param toRemove The texture to remove
  95929. * @returns The index of the removed texture
  95930. */
  95931. removeTexture(toRemove: BaseTexture): number;
  95932. /**
  95933. * Adds the given light to this scene
  95934. * @param newLight The light to add
  95935. */
  95936. addLight(newLight: Light): void;
  95937. /**
  95938. * Sorts the list list based on light priorities
  95939. */
  95940. sortLightsByPriority(): void;
  95941. /**
  95942. * Adds the given camera to this scene
  95943. * @param newCamera The camera to add
  95944. */
  95945. addCamera(newCamera: Camera): void;
  95946. /**
  95947. * Adds the given skeleton to this scene
  95948. * @param newSkeleton The skeleton to add
  95949. */
  95950. addSkeleton(newSkeleton: Skeleton): void;
  95951. /**
  95952. * Adds the given particle system to this scene
  95953. * @param newParticleSystem The particle system to add
  95954. */
  95955. addParticleSystem(newParticleSystem: IParticleSystem): void;
  95956. /**
  95957. * Adds the given animation to this scene
  95958. * @param newAnimation The animation to add
  95959. */
  95960. addAnimation(newAnimation: Animation): void;
  95961. /**
  95962. * Adds the given animation group to this scene.
  95963. * @param newAnimationGroup The animation group to add
  95964. */
  95965. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  95966. /**
  95967. * Adds the given multi-material to this scene
  95968. * @param newMultiMaterial The multi-material to add
  95969. */
  95970. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  95971. /**
  95972. * Adds the given material to this scene
  95973. * @param newMaterial The material to add
  95974. */
  95975. addMaterial(newMaterial: Material): void;
  95976. /**
  95977. * Adds the given morph target to this scene
  95978. * @param newMorphTargetManager The morph target to add
  95979. */
  95980. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  95981. /**
  95982. * Adds the given geometry to this scene
  95983. * @param newGeometry The geometry to add
  95984. */
  95985. addGeometry(newGeometry: Geometry): void;
  95986. /**
  95987. * Adds the given action manager to this scene
  95988. * @param newActionManager The action manager to add
  95989. */
  95990. addActionManager(newActionManager: AbstractActionManager): void;
  95991. /**
  95992. * Adds the given texture to this scene.
  95993. * @param newTexture The texture to add
  95994. */
  95995. addTexture(newTexture: BaseTexture): void;
  95996. /**
  95997. * Switch active camera
  95998. * @param newCamera defines the new active camera
  95999. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96000. */
  96001. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96002. /**
  96003. * sets the active camera of the scene using its ID
  96004. * @param id defines the camera's ID
  96005. * @return the new active camera or null if none found.
  96006. */
  96007. setActiveCameraByID(id: string): Nullable<Camera>;
  96008. /**
  96009. * sets the active camera of the scene using its name
  96010. * @param name defines the camera's name
  96011. * @returns the new active camera or null if none found.
  96012. */
  96013. setActiveCameraByName(name: string): Nullable<Camera>;
  96014. /**
  96015. * get an animation group using its name
  96016. * @param name defines the material's name
  96017. * @return the animation group or null if none found.
  96018. */
  96019. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96020. /**
  96021. * Get a material using its unique id
  96022. * @param uniqueId defines the material's unique id
  96023. * @return the material or null if none found.
  96024. */
  96025. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96026. /**
  96027. * get a material using its id
  96028. * @param id defines the material's ID
  96029. * @return the material or null if none found.
  96030. */
  96031. getMaterialByID(id: string): Nullable<Material>;
  96032. /**
  96033. * Gets a material using its name
  96034. * @param name defines the material's name
  96035. * @return the material or null if none found.
  96036. */
  96037. getMaterialByName(name: string): Nullable<Material>;
  96038. /**
  96039. * Gets a camera using its id
  96040. * @param id defines the id to look for
  96041. * @returns the camera or null if not found
  96042. */
  96043. getCameraByID(id: string): Nullable<Camera>;
  96044. /**
  96045. * Gets a camera using its unique id
  96046. * @param uniqueId defines the unique id to look for
  96047. * @returns the camera or null if not found
  96048. */
  96049. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96050. /**
  96051. * Gets a camera using its name
  96052. * @param name defines the camera's name
  96053. * @return the camera or null if none found.
  96054. */
  96055. getCameraByName(name: string): Nullable<Camera>;
  96056. /**
  96057. * Gets a bone using its id
  96058. * @param id defines the bone's id
  96059. * @return the bone or null if not found
  96060. */
  96061. getBoneByID(id: string): Nullable<Bone>;
  96062. /**
  96063. * Gets a bone using its id
  96064. * @param name defines the bone's name
  96065. * @return the bone or null if not found
  96066. */
  96067. getBoneByName(name: string): Nullable<Bone>;
  96068. /**
  96069. * Gets a light node using its name
  96070. * @param name defines the the light's name
  96071. * @return the light or null if none found.
  96072. */
  96073. getLightByName(name: string): Nullable<Light>;
  96074. /**
  96075. * Gets a light node using its id
  96076. * @param id defines the light's id
  96077. * @return the light or null if none found.
  96078. */
  96079. getLightByID(id: string): Nullable<Light>;
  96080. /**
  96081. * Gets a light node using its scene-generated unique ID
  96082. * @param uniqueId defines the light's unique id
  96083. * @return the light or null if none found.
  96084. */
  96085. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96086. /**
  96087. * Gets a particle system by id
  96088. * @param id defines the particle system id
  96089. * @return the corresponding system or null if none found
  96090. */
  96091. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96092. /**
  96093. * Gets a geometry using its ID
  96094. * @param id defines the geometry's id
  96095. * @return the geometry or null if none found.
  96096. */
  96097. getGeometryByID(id: string): Nullable<Geometry>;
  96098. private _getGeometryByUniqueID;
  96099. /**
  96100. * Add a new geometry to this scene
  96101. * @param geometry defines the geometry to be added to the scene.
  96102. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96103. * @return a boolean defining if the geometry was added or not
  96104. */
  96105. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96106. /**
  96107. * Removes an existing geometry
  96108. * @param geometry defines the geometry to be removed from the scene
  96109. * @return a boolean defining if the geometry was removed or not
  96110. */
  96111. removeGeometry(geometry: Geometry): boolean;
  96112. /**
  96113. * Gets the list of geometries attached to the scene
  96114. * @returns an array of Geometry
  96115. */
  96116. getGeometries(): Geometry[];
  96117. /**
  96118. * Gets the first added mesh found of a given ID
  96119. * @param id defines the id to search for
  96120. * @return the mesh found or null if not found at all
  96121. */
  96122. getMeshByID(id: string): Nullable<AbstractMesh>;
  96123. /**
  96124. * Gets a list of meshes using their id
  96125. * @param id defines the id to search for
  96126. * @returns a list of meshes
  96127. */
  96128. getMeshesByID(id: string): Array<AbstractMesh>;
  96129. /**
  96130. * Gets the first added transform node found of a given ID
  96131. * @param id defines the id to search for
  96132. * @return the found transform node or null if not found at all.
  96133. */
  96134. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96135. /**
  96136. * Gets a transform node with its auto-generated unique id
  96137. * @param uniqueId efines the unique id to search for
  96138. * @return the found transform node or null if not found at all.
  96139. */
  96140. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96141. /**
  96142. * Gets a list of transform nodes using their id
  96143. * @param id defines the id to search for
  96144. * @returns a list of transform nodes
  96145. */
  96146. getTransformNodesByID(id: string): Array<TransformNode>;
  96147. /**
  96148. * Gets a mesh with its auto-generated unique id
  96149. * @param uniqueId defines the unique id to search for
  96150. * @return the found mesh or null if not found at all.
  96151. */
  96152. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96153. /**
  96154. * Gets a the last added mesh using a given id
  96155. * @param id defines the id to search for
  96156. * @return the found mesh or null if not found at all.
  96157. */
  96158. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96159. /**
  96160. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96161. * @param id defines the id to search for
  96162. * @return the found node or null if not found at all
  96163. */
  96164. getLastEntryByID(id: string): Nullable<Node>;
  96165. /**
  96166. * Gets a node (Mesh, Camera, Light) using a given id
  96167. * @param id defines the id to search for
  96168. * @return the found node or null if not found at all
  96169. */
  96170. getNodeByID(id: string): Nullable<Node>;
  96171. /**
  96172. * Gets a node (Mesh, Camera, Light) using a given name
  96173. * @param name defines the name to search for
  96174. * @return the found node or null if not found at all.
  96175. */
  96176. getNodeByName(name: string): Nullable<Node>;
  96177. /**
  96178. * Gets a mesh using a given name
  96179. * @param name defines the name to search for
  96180. * @return the found mesh or null if not found at all.
  96181. */
  96182. getMeshByName(name: string): Nullable<AbstractMesh>;
  96183. /**
  96184. * Gets a transform node using a given name
  96185. * @param name defines the name to search for
  96186. * @return the found transform node or null if not found at all.
  96187. */
  96188. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96189. /**
  96190. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96191. * @param id defines the id to search for
  96192. * @return the found skeleton or null if not found at all.
  96193. */
  96194. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96195. /**
  96196. * Gets a skeleton using a given auto generated unique id
  96197. * @param uniqueId defines the unique id to search for
  96198. * @return the found skeleton or null if not found at all.
  96199. */
  96200. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96201. /**
  96202. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96203. * @param id defines the id to search for
  96204. * @return the found skeleton or null if not found at all.
  96205. */
  96206. getSkeletonById(id: string): Nullable<Skeleton>;
  96207. /**
  96208. * Gets a skeleton using a given name
  96209. * @param name defines the name to search for
  96210. * @return the found skeleton or null if not found at all.
  96211. */
  96212. getSkeletonByName(name: string): Nullable<Skeleton>;
  96213. /**
  96214. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96215. * @param id defines the id to search for
  96216. * @return the found morph target manager or null if not found at all.
  96217. */
  96218. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96219. /**
  96220. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96221. * @param id defines the id to search for
  96222. * @return the found morph target or null if not found at all.
  96223. */
  96224. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96225. /**
  96226. * Gets a boolean indicating if the given mesh is active
  96227. * @param mesh defines the mesh to look for
  96228. * @returns true if the mesh is in the active list
  96229. */
  96230. isActiveMesh(mesh: AbstractMesh): boolean;
  96231. /**
  96232. * Return a unique id as a string which can serve as an identifier for the scene
  96233. */
  96234. readonly uid: string;
  96235. /**
  96236. * Add an externaly attached data from its key.
  96237. * This method call will fail and return false, if such key already exists.
  96238. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96239. * @param key the unique key that identifies the data
  96240. * @param data the data object to associate to the key for this Engine instance
  96241. * @return true if no such key were already present and the data was added successfully, false otherwise
  96242. */
  96243. addExternalData<T>(key: string, data: T): boolean;
  96244. /**
  96245. * Get an externaly attached data from its key
  96246. * @param key the unique key that identifies the data
  96247. * @return the associated data, if present (can be null), or undefined if not present
  96248. */
  96249. getExternalData<T>(key: string): Nullable<T>;
  96250. /**
  96251. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96252. * @param key the unique key that identifies the data
  96253. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96254. * @return the associated data, can be null if the factory returned null.
  96255. */
  96256. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96257. /**
  96258. * Remove an externaly attached data from the Engine instance
  96259. * @param key the unique key that identifies the data
  96260. * @return true if the data was successfully removed, false if it doesn't exist
  96261. */
  96262. removeExternalData(key: string): boolean;
  96263. private _evaluateSubMesh;
  96264. /**
  96265. * Clear the processed materials smart array preventing retention point in material dispose.
  96266. */
  96267. freeProcessedMaterials(): void;
  96268. private _preventFreeActiveMeshesAndRenderingGroups;
  96269. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96270. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96271. * when disposing several meshes in a row or a hierarchy of meshes.
  96272. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96273. */
  96274. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96275. /**
  96276. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96277. */
  96278. freeActiveMeshes(): void;
  96279. /**
  96280. * Clear the info related to rendering groups preventing retention points during dispose.
  96281. */
  96282. freeRenderingGroups(): void;
  96283. /** @hidden */
  96284. _isInIntermediateRendering(): boolean;
  96285. /**
  96286. * Lambda returning the list of potentially active meshes.
  96287. */
  96288. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96289. /**
  96290. * Lambda returning the list of potentially active sub meshes.
  96291. */
  96292. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96293. /**
  96294. * Lambda returning the list of potentially intersecting sub meshes.
  96295. */
  96296. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96297. /**
  96298. * Lambda returning the list of potentially colliding sub meshes.
  96299. */
  96300. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96301. private _activeMeshesFrozen;
  96302. /**
  96303. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96304. * @returns the current scene
  96305. */
  96306. freezeActiveMeshes(): Scene;
  96307. /**
  96308. * Use this function to restart evaluating active meshes on every frame
  96309. * @returns the current scene
  96310. */
  96311. unfreezeActiveMeshes(): Scene;
  96312. private _evaluateActiveMeshes;
  96313. private _activeMesh;
  96314. /**
  96315. * Update the transform matrix to update from the current active camera
  96316. * @param force defines a boolean used to force the update even if cache is up to date
  96317. */
  96318. updateTransformMatrix(force?: boolean): void;
  96319. private _bindFrameBuffer;
  96320. /** @hidden */
  96321. _allowPostProcessClearColor: boolean;
  96322. /** @hidden */
  96323. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96324. private _processSubCameras;
  96325. private _checkIntersections;
  96326. /** @hidden */
  96327. _advancePhysicsEngineStep(step: number): void;
  96328. /**
  96329. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96330. */
  96331. getDeterministicFrameTime: () => number;
  96332. /** @hidden */
  96333. _animate(): void;
  96334. /** Execute all animations (for a frame) */
  96335. animate(): void;
  96336. /**
  96337. * Render the scene
  96338. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96339. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96340. */
  96341. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96342. /**
  96343. * Freeze all materials
  96344. * A frozen material will not be updatable but should be faster to render
  96345. */
  96346. freezeMaterials(): void;
  96347. /**
  96348. * Unfreeze all materials
  96349. * A frozen material will not be updatable but should be faster to render
  96350. */
  96351. unfreezeMaterials(): void;
  96352. /**
  96353. * Releases all held ressources
  96354. */
  96355. dispose(): void;
  96356. /**
  96357. * Gets if the scene is already disposed
  96358. */
  96359. readonly isDisposed: boolean;
  96360. /**
  96361. * Call this function to reduce memory footprint of the scene.
  96362. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96363. */
  96364. clearCachedVertexData(): void;
  96365. /**
  96366. * This function will remove the local cached buffer data from texture.
  96367. * It will save memory but will prevent the texture from being rebuilt
  96368. */
  96369. cleanCachedTextureBuffer(): void;
  96370. /**
  96371. * Get the world extend vectors with an optional filter
  96372. *
  96373. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96374. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96375. */
  96376. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96377. min: Vector3;
  96378. max: Vector3;
  96379. };
  96380. /**
  96381. * Creates a ray that can be used to pick in the scene
  96382. * @param x defines the x coordinate of the origin (on-screen)
  96383. * @param y defines the y coordinate of the origin (on-screen)
  96384. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96385. * @param camera defines the camera to use for the picking
  96386. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96387. * @returns a Ray
  96388. */
  96389. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96390. /**
  96391. * Creates a ray that can be used to pick in the scene
  96392. * @param x defines the x coordinate of the origin (on-screen)
  96393. * @param y defines the y coordinate of the origin (on-screen)
  96394. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96395. * @param result defines the ray where to store the picking ray
  96396. * @param camera defines the camera to use for the picking
  96397. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96398. * @returns the current scene
  96399. */
  96400. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96401. /**
  96402. * Creates a ray that can be used to pick in the scene
  96403. * @param x defines the x coordinate of the origin (on-screen)
  96404. * @param y defines the y coordinate of the origin (on-screen)
  96405. * @param camera defines the camera to use for the picking
  96406. * @returns a Ray
  96407. */
  96408. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96409. /**
  96410. * Creates a ray that can be used to pick in the scene
  96411. * @param x defines the x coordinate of the origin (on-screen)
  96412. * @param y defines the y coordinate of the origin (on-screen)
  96413. * @param result defines the ray where to store the picking ray
  96414. * @param camera defines the camera to use for the picking
  96415. * @returns the current scene
  96416. */
  96417. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96418. /** Launch a ray to try to pick a mesh in the scene
  96419. * @param x position on screen
  96420. * @param y position on screen
  96421. * @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
  96422. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96423. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96424. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96425. * @returns a PickingInfo
  96426. */
  96427. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96428. /** Use the given ray to pick a mesh in the scene
  96429. * @param ray The ray to use to pick meshes
  96430. * @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
  96431. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96432. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96433. * @returns a PickingInfo
  96434. */
  96435. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96436. /**
  96437. * Launch a ray to try to pick a mesh in the scene
  96438. * @param x X position on screen
  96439. * @param y Y position on screen
  96440. * @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
  96441. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96442. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96443. * @returns an array of PickingInfo
  96444. */
  96445. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96446. /**
  96447. * Launch a ray to try to pick a mesh in the scene
  96448. * @param ray Ray to use
  96449. * @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
  96450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96451. * @returns an array of PickingInfo
  96452. */
  96453. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96454. /**
  96455. * Force the value of meshUnderPointer
  96456. * @param mesh defines the mesh to use
  96457. */
  96458. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96459. /**
  96460. * Gets the mesh under the pointer
  96461. * @returns a Mesh or null if no mesh is under the pointer
  96462. */
  96463. getPointerOverMesh(): Nullable<AbstractMesh>;
  96464. /** @hidden */
  96465. _rebuildGeometries(): void;
  96466. /** @hidden */
  96467. _rebuildTextures(): void;
  96468. private _getByTags;
  96469. /**
  96470. * Get a list of meshes by tags
  96471. * @param tagsQuery defines the tags query to use
  96472. * @param forEach defines a predicate used to filter results
  96473. * @returns an array of Mesh
  96474. */
  96475. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96476. /**
  96477. * Get a list of cameras by tags
  96478. * @param tagsQuery defines the tags query to use
  96479. * @param forEach defines a predicate used to filter results
  96480. * @returns an array of Camera
  96481. */
  96482. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96483. /**
  96484. * Get a list of lights by tags
  96485. * @param tagsQuery defines the tags query to use
  96486. * @param forEach defines a predicate used to filter results
  96487. * @returns an array of Light
  96488. */
  96489. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96490. /**
  96491. * Get a list of materials by tags
  96492. * @param tagsQuery defines the tags query to use
  96493. * @param forEach defines a predicate used to filter results
  96494. * @returns an array of Material
  96495. */
  96496. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96497. /**
  96498. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96499. * This allowed control for front to back rendering or reversly depending of the special needs.
  96500. *
  96501. * @param renderingGroupId The rendering group id corresponding to its index
  96502. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96503. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96504. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96505. */
  96506. 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;
  96507. /**
  96508. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96509. *
  96510. * @param renderingGroupId The rendering group id corresponding to its index
  96511. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96512. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96513. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96514. */
  96515. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96516. /**
  96517. * Gets the current auto clear configuration for one rendering group of the rendering
  96518. * manager.
  96519. * @param index the rendering group index to get the information for
  96520. * @returns The auto clear setup for the requested rendering group
  96521. */
  96522. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96523. private _blockMaterialDirtyMechanism;
  96524. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96525. blockMaterialDirtyMechanism: boolean;
  96526. /**
  96527. * Will flag all materials as dirty to trigger new shader compilation
  96528. * @param flag defines the flag used to specify which material part must be marked as dirty
  96529. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96530. */
  96531. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96532. /** @hidden */
  96533. _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;
  96534. /** @hidden */
  96535. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96536. }
  96537. }
  96538. declare module BABYLON {
  96539. /**
  96540. * Set of assets to keep when moving a scene into an asset container.
  96541. */
  96542. export class KeepAssets extends AbstractScene {
  96543. }
  96544. /**
  96545. * Container with a set of assets that can be added or removed from a scene.
  96546. */
  96547. export class AssetContainer extends AbstractScene {
  96548. /**
  96549. * The scene the AssetContainer belongs to.
  96550. */
  96551. scene: Scene;
  96552. /**
  96553. * Instantiates an AssetContainer.
  96554. * @param scene The scene the AssetContainer belongs to.
  96555. */
  96556. constructor(scene: Scene);
  96557. /**
  96558. * Adds all the assets from the container to the scene.
  96559. */
  96560. addAllToScene(): void;
  96561. /**
  96562. * Removes all the assets in the container from the scene
  96563. */
  96564. removeAllFromScene(): void;
  96565. /**
  96566. * Disposes all the assets in the container
  96567. */
  96568. dispose(): void;
  96569. private _moveAssets;
  96570. /**
  96571. * Removes all the assets contained in the scene and adds them to the container.
  96572. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96573. */
  96574. moveAllFromScene(keepAssets?: KeepAssets): void;
  96575. /**
  96576. * 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.
  96577. * @returns the root mesh
  96578. */
  96579. createRootMesh(): Mesh;
  96580. }
  96581. }
  96582. declare module BABYLON {
  96583. /**
  96584. * Defines how the parser contract is defined.
  96585. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96586. */
  96587. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96588. /**
  96589. * Defines how the individual parser contract is defined.
  96590. * These parser can parse an individual asset
  96591. */
  96592. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96593. /**
  96594. * Base class of the scene acting as a container for the different elements composing a scene.
  96595. * This class is dynamically extended by the different components of the scene increasing
  96596. * flexibility and reducing coupling
  96597. */
  96598. export abstract class AbstractScene {
  96599. /**
  96600. * Stores the list of available parsers in the application.
  96601. */
  96602. private static _BabylonFileParsers;
  96603. /**
  96604. * Stores the list of available individual parsers in the application.
  96605. */
  96606. private static _IndividualBabylonFileParsers;
  96607. /**
  96608. * Adds a parser in the list of available ones
  96609. * @param name Defines the name of the parser
  96610. * @param parser Defines the parser to add
  96611. */
  96612. static AddParser(name: string, parser: BabylonFileParser): void;
  96613. /**
  96614. * Gets a general parser from the list of avaialble ones
  96615. * @param name Defines the name of the parser
  96616. * @returns the requested parser or null
  96617. */
  96618. static GetParser(name: string): Nullable<BabylonFileParser>;
  96619. /**
  96620. * Adds n individual parser in the list of available ones
  96621. * @param name Defines the name of the parser
  96622. * @param parser Defines the parser to add
  96623. */
  96624. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96625. /**
  96626. * Gets an individual parser from the list of avaialble ones
  96627. * @param name Defines the name of the parser
  96628. * @returns the requested parser or null
  96629. */
  96630. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96631. /**
  96632. * Parser json data and populate both a scene and its associated container object
  96633. * @param jsonData Defines the data to parse
  96634. * @param scene Defines the scene to parse the data for
  96635. * @param container Defines the container attached to the parsing sequence
  96636. * @param rootUrl Defines the root url of the data
  96637. */
  96638. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96639. /**
  96640. * Gets the list of root nodes (ie. nodes with no parent)
  96641. */
  96642. rootNodes: Node[];
  96643. /** All of the cameras added to this scene
  96644. * @see http://doc.babylonjs.com/babylon101/cameras
  96645. */
  96646. cameras: Camera[];
  96647. /**
  96648. * All of the lights added to this scene
  96649. * @see http://doc.babylonjs.com/babylon101/lights
  96650. */
  96651. lights: Light[];
  96652. /**
  96653. * All of the (abstract) meshes added to this scene
  96654. */
  96655. meshes: AbstractMesh[];
  96656. /**
  96657. * The list of skeletons added to the scene
  96658. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96659. */
  96660. skeletons: Skeleton[];
  96661. /**
  96662. * All of the particle systems added to this scene
  96663. * @see http://doc.babylonjs.com/babylon101/particles
  96664. */
  96665. particleSystems: IParticleSystem[];
  96666. /**
  96667. * Gets a list of Animations associated with the scene
  96668. */
  96669. animations: Animation[];
  96670. /**
  96671. * All of the animation groups added to this scene
  96672. * @see http://doc.babylonjs.com/how_to/group
  96673. */
  96674. animationGroups: AnimationGroup[];
  96675. /**
  96676. * All of the multi-materials added to this scene
  96677. * @see http://doc.babylonjs.com/how_to/multi_materials
  96678. */
  96679. multiMaterials: MultiMaterial[];
  96680. /**
  96681. * All of the materials added to this scene
  96682. * In the context of a Scene, it is not supposed to be modified manually.
  96683. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96684. * Note also that the order of the Material wihin the array is not significant and might change.
  96685. * @see http://doc.babylonjs.com/babylon101/materials
  96686. */
  96687. materials: Material[];
  96688. /**
  96689. * The list of morph target managers added to the scene
  96690. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96691. */
  96692. morphTargetManagers: MorphTargetManager[];
  96693. /**
  96694. * The list of geometries used in the scene.
  96695. */
  96696. geometries: Geometry[];
  96697. /**
  96698. * All of the tranform nodes added to this scene
  96699. * In the context of a Scene, it is not supposed to be modified manually.
  96700. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96701. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96702. * @see http://doc.babylonjs.com/how_to/transformnode
  96703. */
  96704. transformNodes: TransformNode[];
  96705. /**
  96706. * ActionManagers available on the scene.
  96707. */
  96708. actionManagers: AbstractActionManager[];
  96709. /**
  96710. * Textures to keep.
  96711. */
  96712. textures: BaseTexture[];
  96713. /**
  96714. * Environment texture for the scene
  96715. */
  96716. environmentTexture: Nullable<BaseTexture>;
  96717. }
  96718. }
  96719. declare module BABYLON {
  96720. /**
  96721. * Defines a sound that can be played in the application.
  96722. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96724. */
  96725. export class Sound {
  96726. /**
  96727. * The name of the sound in the scene.
  96728. */
  96729. name: string;
  96730. /**
  96731. * Does the sound autoplay once loaded.
  96732. */
  96733. autoplay: boolean;
  96734. /**
  96735. * Does the sound loop after it finishes playing once.
  96736. */
  96737. loop: boolean;
  96738. /**
  96739. * Does the sound use a custom attenuation curve to simulate the falloff
  96740. * happening when the source gets further away from the camera.
  96741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96742. */
  96743. useCustomAttenuation: boolean;
  96744. /**
  96745. * The sound track id this sound belongs to.
  96746. */
  96747. soundTrackId: number;
  96748. /**
  96749. * Is this sound currently played.
  96750. */
  96751. isPlaying: boolean;
  96752. /**
  96753. * Is this sound currently paused.
  96754. */
  96755. isPaused: boolean;
  96756. /**
  96757. * Does this sound enables spatial sound.
  96758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96759. */
  96760. spatialSound: boolean;
  96761. /**
  96762. * Define the reference distance the sound should be heard perfectly.
  96763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96764. */
  96765. refDistance: number;
  96766. /**
  96767. * Define the roll off factor of spatial sounds.
  96768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96769. */
  96770. rolloffFactor: number;
  96771. /**
  96772. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96774. */
  96775. maxDistance: number;
  96776. /**
  96777. * Define the distance attenuation model the sound will follow.
  96778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96779. */
  96780. distanceModel: string;
  96781. /**
  96782. * @hidden
  96783. * Back Compat
  96784. **/
  96785. onended: () => any;
  96786. /**
  96787. * Observable event when the current playing sound finishes.
  96788. */
  96789. onEndedObservable: Observable<Sound>;
  96790. private _panningModel;
  96791. private _playbackRate;
  96792. private _streaming;
  96793. private _startTime;
  96794. private _startOffset;
  96795. private _position;
  96796. /** @hidden */
  96797. _positionInEmitterSpace: boolean;
  96798. private _localDirection;
  96799. private _volume;
  96800. private _isReadyToPlay;
  96801. private _isDirectional;
  96802. private _readyToPlayCallback;
  96803. private _audioBuffer;
  96804. private _soundSource;
  96805. private _streamingSource;
  96806. private _soundPanner;
  96807. private _soundGain;
  96808. private _inputAudioNode;
  96809. private _outputAudioNode;
  96810. private _coneInnerAngle;
  96811. private _coneOuterAngle;
  96812. private _coneOuterGain;
  96813. private _scene;
  96814. private _connectedTransformNode;
  96815. private _customAttenuationFunction;
  96816. private _registerFunc;
  96817. private _isOutputConnected;
  96818. private _htmlAudioElement;
  96819. private _urlType;
  96820. /** @hidden */
  96821. static _SceneComponentInitialization: (scene: Scene) => void;
  96822. /**
  96823. * Create a sound and attach it to a scene
  96824. * @param name Name of your sound
  96825. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96826. * @param scene defines the scene the sound belongs to
  96827. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96828. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96829. */
  96830. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  96831. /**
  96832. * Release the sound and its associated resources
  96833. */
  96834. dispose(): void;
  96835. /**
  96836. * Gets if the sounds is ready to be played or not.
  96837. * @returns true if ready, otherwise false
  96838. */
  96839. isReady(): boolean;
  96840. private _soundLoaded;
  96841. /**
  96842. * Sets the data of the sound from an audiobuffer
  96843. * @param audioBuffer The audioBuffer containing the data
  96844. */
  96845. setAudioBuffer(audioBuffer: AudioBuffer): void;
  96846. /**
  96847. * Updates the current sounds options such as maxdistance, loop...
  96848. * @param options A JSON object containing values named as the object properties
  96849. */
  96850. updateOptions(options: any): void;
  96851. private _createSpatialParameters;
  96852. private _updateSpatialParameters;
  96853. /**
  96854. * Switch the panning model to HRTF:
  96855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96857. */
  96858. switchPanningModelToHRTF(): void;
  96859. /**
  96860. * Switch the panning model to Equal Power:
  96861. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96863. */
  96864. switchPanningModelToEqualPower(): void;
  96865. private _switchPanningModel;
  96866. /**
  96867. * Connect this sound to a sound track audio node like gain...
  96868. * @param soundTrackAudioNode the sound track audio node to connect to
  96869. */
  96870. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  96871. /**
  96872. * Transform this sound into a directional source
  96873. * @param coneInnerAngle Size of the inner cone in degree
  96874. * @param coneOuterAngle Size of the outer cone in degree
  96875. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  96876. */
  96877. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  96878. /**
  96879. * Gets or sets the inner angle for the directional cone.
  96880. */
  96881. /**
  96882. * Gets or sets the inner angle for the directional cone.
  96883. */
  96884. directionalConeInnerAngle: number;
  96885. /**
  96886. * Gets or sets the outer angle for the directional cone.
  96887. */
  96888. /**
  96889. * Gets or sets the outer angle for the directional cone.
  96890. */
  96891. directionalConeOuterAngle: number;
  96892. /**
  96893. * Sets the position of the emitter if spatial sound is enabled
  96894. * @param newPosition Defines the new posisiton
  96895. */
  96896. setPosition(newPosition: Vector3): void;
  96897. /**
  96898. * Sets the local direction of the emitter if spatial sound is enabled
  96899. * @param newLocalDirection Defines the new local direction
  96900. */
  96901. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  96902. private _updateDirection;
  96903. /** @hidden */
  96904. updateDistanceFromListener(): void;
  96905. /**
  96906. * Sets a new custom attenuation function for the sound.
  96907. * @param callback Defines the function used for the attenuation
  96908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96909. */
  96910. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  96911. /**
  96912. * Play the sound
  96913. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  96914. * @param offset (optional) Start the sound setting it at a specific time
  96915. */
  96916. play(time?: number, offset?: number): void;
  96917. private _onended;
  96918. /**
  96919. * Stop the sound
  96920. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  96921. */
  96922. stop(time?: number): void;
  96923. /**
  96924. * Put the sound in pause
  96925. */
  96926. pause(): void;
  96927. /**
  96928. * Sets a dedicated volume for this sounds
  96929. * @param newVolume Define the new volume of the sound
  96930. * @param time Define in how long the sound should be at this value
  96931. */
  96932. setVolume(newVolume: number, time?: number): void;
  96933. /**
  96934. * Set the sound play back rate
  96935. * @param newPlaybackRate Define the playback rate the sound should be played at
  96936. */
  96937. setPlaybackRate(newPlaybackRate: number): void;
  96938. /**
  96939. * Gets the volume of the sound.
  96940. * @returns the volume of the sound
  96941. */
  96942. getVolume(): number;
  96943. /**
  96944. * Attach the sound to a dedicated mesh
  96945. * @param transformNode The transform node to connect the sound with
  96946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96947. */
  96948. attachToMesh(transformNode: TransformNode): void;
  96949. /**
  96950. * Detach the sound from the previously attached mesh
  96951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96952. */
  96953. detachFromMesh(): void;
  96954. private _onRegisterAfterWorldMatrixUpdate;
  96955. /**
  96956. * Clone the current sound in the scene.
  96957. * @returns the new sound clone
  96958. */
  96959. clone(): Nullable<Sound>;
  96960. /**
  96961. * Gets the current underlying audio buffer containing the data
  96962. * @returns the audio buffer
  96963. */
  96964. getAudioBuffer(): Nullable<AudioBuffer>;
  96965. /**
  96966. * Serializes the Sound in a JSON representation
  96967. * @returns the JSON representation of the sound
  96968. */
  96969. serialize(): any;
  96970. /**
  96971. * Parse a JSON representation of a sound to innstantiate in a given scene
  96972. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  96973. * @param scene Define the scene the new parsed sound should be created in
  96974. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  96975. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  96976. * @returns the newly parsed sound
  96977. */
  96978. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  96979. }
  96980. }
  96981. declare module BABYLON {
  96982. /**
  96983. * This defines an action helpful to play a defined sound on a triggered action.
  96984. */
  96985. export class PlaySoundAction extends Action {
  96986. private _sound;
  96987. /**
  96988. * Instantiate the action
  96989. * @param triggerOptions defines the trigger options
  96990. * @param sound defines the sound to play
  96991. * @param condition defines the trigger related conditions
  96992. */
  96993. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96994. /** @hidden */
  96995. _prepare(): void;
  96996. /**
  96997. * Execute the action and play the sound.
  96998. */
  96999. execute(): void;
  97000. /**
  97001. * Serializes the actions and its related information.
  97002. * @param parent defines the object to serialize in
  97003. * @returns the serialized object
  97004. */
  97005. serialize(parent: any): any;
  97006. }
  97007. /**
  97008. * This defines an action helpful to stop a defined sound on a triggered action.
  97009. */
  97010. export class StopSoundAction extends Action {
  97011. private _sound;
  97012. /**
  97013. * Instantiate the action
  97014. * @param triggerOptions defines the trigger options
  97015. * @param sound defines the sound to stop
  97016. * @param condition defines the trigger related conditions
  97017. */
  97018. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97019. /** @hidden */
  97020. _prepare(): void;
  97021. /**
  97022. * Execute the action and stop the sound.
  97023. */
  97024. execute(): void;
  97025. /**
  97026. * Serializes the actions and its related information.
  97027. * @param parent defines the object to serialize in
  97028. * @returns the serialized object
  97029. */
  97030. serialize(parent: any): any;
  97031. }
  97032. }
  97033. declare module BABYLON {
  97034. /**
  97035. * This defines an action responsible to change the value of a property
  97036. * by interpolating between its current value and the newly set one once triggered.
  97037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97038. */
  97039. export class InterpolateValueAction extends Action {
  97040. /**
  97041. * Defines the path of the property where the value should be interpolated
  97042. */
  97043. propertyPath: string;
  97044. /**
  97045. * Defines the target value at the end of the interpolation.
  97046. */
  97047. value: any;
  97048. /**
  97049. * Defines the time it will take for the property to interpolate to the value.
  97050. */
  97051. duration: number;
  97052. /**
  97053. * Defines if the other scene animations should be stopped when the action has been triggered
  97054. */
  97055. stopOtherAnimations?: boolean;
  97056. /**
  97057. * Defines a callback raised once the interpolation animation has been done.
  97058. */
  97059. onInterpolationDone?: () => void;
  97060. /**
  97061. * Observable triggered once the interpolation animation has been done.
  97062. */
  97063. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97064. private _target;
  97065. private _effectiveTarget;
  97066. private _property;
  97067. /**
  97068. * Instantiate the action
  97069. * @param triggerOptions defines the trigger options
  97070. * @param target defines the object containing the value to interpolate
  97071. * @param propertyPath defines the path to the property in the target object
  97072. * @param value defines the target value at the end of the interpolation
  97073. * @param duration deines the time it will take for the property to interpolate to the value.
  97074. * @param condition defines the trigger related conditions
  97075. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97076. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97077. */
  97078. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97079. /** @hidden */
  97080. _prepare(): void;
  97081. /**
  97082. * Execute the action starts the value interpolation.
  97083. */
  97084. execute(): void;
  97085. /**
  97086. * Serializes the actions and its related information.
  97087. * @param parent defines the object to serialize in
  97088. * @returns the serialized object
  97089. */
  97090. serialize(parent: any): any;
  97091. }
  97092. }
  97093. declare module BABYLON {
  97094. /**
  97095. * Options allowed during the creation of a sound track.
  97096. */
  97097. export interface ISoundTrackOptions {
  97098. /**
  97099. * The volume the sound track should take during creation
  97100. */
  97101. volume?: number;
  97102. /**
  97103. * Define if the sound track is the main sound track of the scene
  97104. */
  97105. mainTrack?: boolean;
  97106. }
  97107. /**
  97108. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97109. * It will be also used in a future release to apply effects on a specific track.
  97110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97111. */
  97112. export class SoundTrack {
  97113. /**
  97114. * The unique identifier of the sound track in the scene.
  97115. */
  97116. id: number;
  97117. /**
  97118. * The list of sounds included in the sound track.
  97119. */
  97120. soundCollection: Array<Sound>;
  97121. private _outputAudioNode;
  97122. private _scene;
  97123. private _isMainTrack;
  97124. private _connectedAnalyser;
  97125. private _options;
  97126. private _isInitialized;
  97127. /**
  97128. * Creates a new sound track.
  97129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97130. * @param scene Define the scene the sound track belongs to
  97131. * @param options
  97132. */
  97133. constructor(scene: Scene, options?: ISoundTrackOptions);
  97134. private _initializeSoundTrackAudioGraph;
  97135. /**
  97136. * Release the sound track and its associated resources
  97137. */
  97138. dispose(): void;
  97139. /**
  97140. * Adds a sound to this sound track
  97141. * @param sound define the cound to add
  97142. * @ignoreNaming
  97143. */
  97144. AddSound(sound: Sound): void;
  97145. /**
  97146. * Removes a sound to this sound track
  97147. * @param sound define the cound to remove
  97148. * @ignoreNaming
  97149. */
  97150. RemoveSound(sound: Sound): void;
  97151. /**
  97152. * Set a global volume for the full sound track.
  97153. * @param newVolume Define the new volume of the sound track
  97154. */
  97155. setVolume(newVolume: number): void;
  97156. /**
  97157. * Switch the panning model to HRTF:
  97158. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97160. */
  97161. switchPanningModelToHRTF(): void;
  97162. /**
  97163. * Switch the panning model to Equal Power:
  97164. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97166. */
  97167. switchPanningModelToEqualPower(): void;
  97168. /**
  97169. * Connect the sound track to an audio analyser allowing some amazing
  97170. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97172. * @param analyser The analyser to connect to the engine
  97173. */
  97174. connectToAnalyser(analyser: Analyser): void;
  97175. }
  97176. }
  97177. declare module BABYLON {
  97178. interface AbstractScene {
  97179. /**
  97180. * The list of sounds used in the scene.
  97181. */
  97182. sounds: Nullable<Array<Sound>>;
  97183. }
  97184. interface Scene {
  97185. /**
  97186. * @hidden
  97187. * Backing field
  97188. */
  97189. _mainSoundTrack: SoundTrack;
  97190. /**
  97191. * The main sound track played by the scene.
  97192. * It cotains your primary collection of sounds.
  97193. */
  97194. mainSoundTrack: SoundTrack;
  97195. /**
  97196. * The list of sound tracks added to the scene
  97197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97198. */
  97199. soundTracks: Nullable<Array<SoundTrack>>;
  97200. /**
  97201. * Gets a sound using a given name
  97202. * @param name defines the name to search for
  97203. * @return the found sound or null if not found at all.
  97204. */
  97205. getSoundByName(name: string): Nullable<Sound>;
  97206. /**
  97207. * Gets or sets if audio support is enabled
  97208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97209. */
  97210. audioEnabled: boolean;
  97211. /**
  97212. * Gets or sets if audio will be output to headphones
  97213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97214. */
  97215. headphone: boolean;
  97216. }
  97217. /**
  97218. * Defines the sound scene component responsible to manage any sounds
  97219. * in a given scene.
  97220. */
  97221. export class AudioSceneComponent implements ISceneSerializableComponent {
  97222. /**
  97223. * The component name helpfull to identify the component in the list of scene components.
  97224. */
  97225. readonly name: string;
  97226. /**
  97227. * The scene the component belongs to.
  97228. */
  97229. scene: Scene;
  97230. private _audioEnabled;
  97231. /**
  97232. * Gets whether audio is enabled or not.
  97233. * Please use related enable/disable method to switch state.
  97234. */
  97235. readonly audioEnabled: boolean;
  97236. private _headphone;
  97237. /**
  97238. * Gets whether audio is outputing to headphone or not.
  97239. * Please use the according Switch methods to change output.
  97240. */
  97241. readonly headphone: boolean;
  97242. /**
  97243. * Creates a new instance of the component for the given scene
  97244. * @param scene Defines the scene to register the component in
  97245. */
  97246. constructor(scene: Scene);
  97247. /**
  97248. * Registers the component in a given scene
  97249. */
  97250. register(): void;
  97251. /**
  97252. * Rebuilds the elements related to this component in case of
  97253. * context lost for instance.
  97254. */
  97255. rebuild(): void;
  97256. /**
  97257. * Serializes the component data to the specified json object
  97258. * @param serializationObject The object to serialize to
  97259. */
  97260. serialize(serializationObject: any): void;
  97261. /**
  97262. * Adds all the elements from the container to the scene
  97263. * @param container the container holding the elements
  97264. */
  97265. addFromContainer(container: AbstractScene): void;
  97266. /**
  97267. * Removes all the elements in the container from the scene
  97268. * @param container contains the elements to remove
  97269. * @param dispose if the removed element should be disposed (default: false)
  97270. */
  97271. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97272. /**
  97273. * Disposes the component and the associated ressources.
  97274. */
  97275. dispose(): void;
  97276. /**
  97277. * Disables audio in the associated scene.
  97278. */
  97279. disableAudio(): void;
  97280. /**
  97281. * Enables audio in the associated scene.
  97282. */
  97283. enableAudio(): void;
  97284. /**
  97285. * Switch audio to headphone output.
  97286. */
  97287. switchAudioModeForHeadphones(): void;
  97288. /**
  97289. * Switch audio to normal speakers.
  97290. */
  97291. switchAudioModeForNormalSpeakers(): void;
  97292. private _afterRender;
  97293. }
  97294. }
  97295. declare module BABYLON {
  97296. /**
  97297. * Wraps one or more Sound objects and selects one with random weight for playback.
  97298. */
  97299. export class WeightedSound {
  97300. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97301. loop: boolean;
  97302. private _coneInnerAngle;
  97303. private _coneOuterAngle;
  97304. private _volume;
  97305. /** A Sound is currently playing. */
  97306. isPlaying: boolean;
  97307. /** A Sound is currently paused. */
  97308. isPaused: boolean;
  97309. private _sounds;
  97310. private _weights;
  97311. private _currentIndex?;
  97312. /**
  97313. * Creates a new WeightedSound from the list of sounds given.
  97314. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97315. * @param sounds Array of Sounds that will be selected from.
  97316. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97317. */
  97318. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97319. /**
  97320. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97321. */
  97322. /**
  97323. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97324. */
  97325. directionalConeInnerAngle: number;
  97326. /**
  97327. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97328. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97329. */
  97330. /**
  97331. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97332. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97333. */
  97334. directionalConeOuterAngle: number;
  97335. /**
  97336. * Playback volume.
  97337. */
  97338. /**
  97339. * Playback volume.
  97340. */
  97341. volume: number;
  97342. private _onended;
  97343. /**
  97344. * Suspend playback
  97345. */
  97346. pause(): void;
  97347. /**
  97348. * Stop playback
  97349. */
  97350. stop(): void;
  97351. /**
  97352. * Start playback.
  97353. * @param startOffset Position the clip head at a specific time in seconds.
  97354. */
  97355. play(startOffset?: number): void;
  97356. }
  97357. }
  97358. declare module BABYLON {
  97359. /**
  97360. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97362. */
  97363. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97364. /**
  97365. * Gets the name of the behavior.
  97366. */
  97367. readonly name: string;
  97368. /**
  97369. * The easing function used by animations
  97370. */
  97371. static EasingFunction: BackEase;
  97372. /**
  97373. * The easing mode used by animations
  97374. */
  97375. static EasingMode: number;
  97376. /**
  97377. * The duration of the animation, in milliseconds
  97378. */
  97379. transitionDuration: number;
  97380. /**
  97381. * Length of the distance animated by the transition when lower radius is reached
  97382. */
  97383. lowerRadiusTransitionRange: number;
  97384. /**
  97385. * Length of the distance animated by the transition when upper radius is reached
  97386. */
  97387. upperRadiusTransitionRange: number;
  97388. private _autoTransitionRange;
  97389. /**
  97390. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97391. */
  97392. /**
  97393. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97394. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97395. */
  97396. autoTransitionRange: boolean;
  97397. private _attachedCamera;
  97398. private _onAfterCheckInputsObserver;
  97399. private _onMeshTargetChangedObserver;
  97400. /**
  97401. * Initializes the behavior.
  97402. */
  97403. init(): void;
  97404. /**
  97405. * Attaches the behavior to its arc rotate camera.
  97406. * @param camera Defines the camera to attach the behavior to
  97407. */
  97408. attach(camera: ArcRotateCamera): void;
  97409. /**
  97410. * Detaches the behavior from its current arc rotate camera.
  97411. */
  97412. detach(): void;
  97413. private _radiusIsAnimating;
  97414. private _radiusBounceTransition;
  97415. private _animatables;
  97416. private _cachedWheelPrecision;
  97417. /**
  97418. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97419. * @param radiusLimit The limit to check against.
  97420. * @return Bool to indicate if at limit.
  97421. */
  97422. private _isRadiusAtLimit;
  97423. /**
  97424. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97425. * @param radiusDelta The delta by which to animate to. Can be negative.
  97426. */
  97427. private _applyBoundRadiusAnimation;
  97428. /**
  97429. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97430. */
  97431. protected _clearAnimationLocks(): void;
  97432. /**
  97433. * Stops and removes all animations that have been applied to the camera
  97434. */
  97435. stopAllAnimations(): void;
  97436. }
  97437. }
  97438. declare module BABYLON {
  97439. /**
  97440. * 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.
  97441. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97442. */
  97443. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97444. /**
  97445. * Gets the name of the behavior.
  97446. */
  97447. readonly name: string;
  97448. private _mode;
  97449. private _radiusScale;
  97450. private _positionScale;
  97451. private _defaultElevation;
  97452. private _elevationReturnTime;
  97453. private _elevationReturnWaitTime;
  97454. private _zoomStopsAnimation;
  97455. private _framingTime;
  97456. /**
  97457. * The easing function used by animations
  97458. */
  97459. static EasingFunction: ExponentialEase;
  97460. /**
  97461. * The easing mode used by animations
  97462. */
  97463. static EasingMode: number;
  97464. /**
  97465. * Sets the current mode used by the behavior
  97466. */
  97467. /**
  97468. * Gets current mode used by the behavior.
  97469. */
  97470. mode: number;
  97471. /**
  97472. * Sets the scale applied to the radius (1 by default)
  97473. */
  97474. /**
  97475. * Gets the scale applied to the radius
  97476. */
  97477. radiusScale: number;
  97478. /**
  97479. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97480. */
  97481. /**
  97482. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97483. */
  97484. positionScale: number;
  97485. /**
  97486. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97487. * behaviour is triggered, in radians.
  97488. */
  97489. /**
  97490. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97491. * behaviour is triggered, in radians.
  97492. */
  97493. defaultElevation: number;
  97494. /**
  97495. * Sets the time (in milliseconds) taken to return to the default beta position.
  97496. * Negative value indicates camera should not return to default.
  97497. */
  97498. /**
  97499. * Gets the time (in milliseconds) taken to return to the default beta position.
  97500. * Negative value indicates camera should not return to default.
  97501. */
  97502. elevationReturnTime: number;
  97503. /**
  97504. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97505. */
  97506. /**
  97507. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97508. */
  97509. elevationReturnWaitTime: number;
  97510. /**
  97511. * Sets the flag that indicates if user zooming should stop animation.
  97512. */
  97513. /**
  97514. * Gets the flag that indicates if user zooming should stop animation.
  97515. */
  97516. zoomStopsAnimation: boolean;
  97517. /**
  97518. * Sets the transition time when framing the mesh, in milliseconds
  97519. */
  97520. /**
  97521. * Gets the transition time when framing the mesh, in milliseconds
  97522. */
  97523. framingTime: number;
  97524. /**
  97525. * Define if the behavior should automatically change the configured
  97526. * camera limits and sensibilities.
  97527. */
  97528. autoCorrectCameraLimitsAndSensibility: boolean;
  97529. private _onPrePointerObservableObserver;
  97530. private _onAfterCheckInputsObserver;
  97531. private _onMeshTargetChangedObserver;
  97532. private _attachedCamera;
  97533. private _isPointerDown;
  97534. private _lastInteractionTime;
  97535. /**
  97536. * Initializes the behavior.
  97537. */
  97538. init(): void;
  97539. /**
  97540. * Attaches the behavior to its arc rotate camera.
  97541. * @param camera Defines the camera to attach the behavior to
  97542. */
  97543. attach(camera: ArcRotateCamera): void;
  97544. /**
  97545. * Detaches the behavior from its current arc rotate camera.
  97546. */
  97547. detach(): void;
  97548. private _animatables;
  97549. private _betaIsAnimating;
  97550. private _betaTransition;
  97551. private _radiusTransition;
  97552. private _vectorTransition;
  97553. /**
  97554. * Targets the given mesh and updates zoom level accordingly.
  97555. * @param mesh The mesh to target.
  97556. * @param radius Optional. If a cached radius position already exists, overrides default.
  97557. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97558. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97559. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97560. */
  97561. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97562. /**
  97563. * Targets the given mesh with its children and updates zoom level accordingly.
  97564. * @param mesh The mesh to target.
  97565. * @param radius Optional. If a cached radius position already exists, overrides default.
  97566. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97567. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97568. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97569. */
  97570. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97571. /**
  97572. * Targets the given meshes with their children and updates zoom level accordingly.
  97573. * @param meshes The mesh to target.
  97574. * @param radius Optional. If a cached radius position already exists, overrides default.
  97575. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97576. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97577. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97578. */
  97579. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97580. /**
  97581. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97582. * @param minimumWorld Determines the smaller position of the bounding box extend
  97583. * @param maximumWorld Determines the bigger position of the bounding box extend
  97584. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97585. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97586. */
  97587. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97588. /**
  97589. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97590. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97591. * frustum width.
  97592. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97593. * to fully enclose the mesh in the viewing frustum.
  97594. */
  97595. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97596. /**
  97597. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97598. * is automatically returned to its default position (expected to be above ground plane).
  97599. */
  97600. private _maintainCameraAboveGround;
  97601. /**
  97602. * Returns the frustum slope based on the canvas ratio and camera FOV
  97603. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97604. */
  97605. private _getFrustumSlope;
  97606. /**
  97607. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97608. */
  97609. private _clearAnimationLocks;
  97610. /**
  97611. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97612. */
  97613. private _applyUserInteraction;
  97614. /**
  97615. * Stops and removes all animations that have been applied to the camera
  97616. */
  97617. stopAllAnimations(): void;
  97618. /**
  97619. * Gets a value indicating if the user is moving the camera
  97620. */
  97621. readonly isUserIsMoving: boolean;
  97622. /**
  97623. * The camera can move all the way towards the mesh.
  97624. */
  97625. static IgnoreBoundsSizeMode: number;
  97626. /**
  97627. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97628. */
  97629. static FitFrustumSidesMode: number;
  97630. }
  97631. }
  97632. declare module BABYLON {
  97633. /**
  97634. * Base class for Camera Pointer Inputs.
  97635. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97636. * for example usage.
  97637. */
  97638. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97639. /**
  97640. * Defines the camera the input is attached to.
  97641. */
  97642. abstract camera: Camera;
  97643. /**
  97644. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97645. */
  97646. protected _altKey: boolean;
  97647. protected _ctrlKey: boolean;
  97648. protected _metaKey: boolean;
  97649. protected _shiftKey: boolean;
  97650. /**
  97651. * Which mouse buttons were pressed at time of last mouse event.
  97652. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97653. */
  97654. protected _buttonsPressed: number;
  97655. /**
  97656. * Defines the buttons associated with the input to handle camera move.
  97657. */
  97658. buttons: number[];
  97659. /**
  97660. * Attach the input controls to a specific dom element to get the input from.
  97661. * @param element Defines the element the controls should be listened from
  97662. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97663. */
  97664. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97665. /**
  97666. * Detach the current controls from the specified dom element.
  97667. * @param element Defines the element to stop listening the inputs from
  97668. */
  97669. detachControl(element: Nullable<HTMLElement>): void;
  97670. /**
  97671. * Gets the class name of the current input.
  97672. * @returns the class name
  97673. */
  97674. getClassName(): string;
  97675. /**
  97676. * Get the friendly name associated with the input class.
  97677. * @returns the input friendly name
  97678. */
  97679. getSimpleName(): string;
  97680. /**
  97681. * Called on pointer POINTERDOUBLETAP event.
  97682. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97683. */
  97684. protected onDoubleTap(type: string): void;
  97685. /**
  97686. * Called on pointer POINTERMOVE event if only a single touch is active.
  97687. * Override this method to provide functionality.
  97688. */
  97689. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97690. /**
  97691. * Called on pointer POINTERMOVE event if multiple touches are active.
  97692. * Override this method to provide functionality.
  97693. */
  97694. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97695. /**
  97696. * Called on JS contextmenu event.
  97697. * Override this method to provide functionality.
  97698. */
  97699. protected onContextMenu(evt: PointerEvent): void;
  97700. /**
  97701. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97702. * press.
  97703. * Override this method to provide functionality.
  97704. */
  97705. protected onButtonDown(evt: PointerEvent): void;
  97706. /**
  97707. * Called each time a new POINTERUP event occurs. Ie, for each button
  97708. * release.
  97709. * Override this method to provide functionality.
  97710. */
  97711. protected onButtonUp(evt: PointerEvent): void;
  97712. /**
  97713. * Called when window becomes inactive.
  97714. * Override this method to provide functionality.
  97715. */
  97716. protected onLostFocus(): void;
  97717. private _pointerInput;
  97718. private _observer;
  97719. private _onLostFocus;
  97720. private pointA;
  97721. private pointB;
  97722. }
  97723. }
  97724. declare module BABYLON {
  97725. /**
  97726. * Manage the pointers inputs to control an arc rotate camera.
  97727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97728. */
  97729. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97730. /**
  97731. * Defines the camera the input is attached to.
  97732. */
  97733. camera: ArcRotateCamera;
  97734. /**
  97735. * Gets the class name of the current input.
  97736. * @returns the class name
  97737. */
  97738. getClassName(): string;
  97739. /**
  97740. * Defines the buttons associated with the input to handle camera move.
  97741. */
  97742. buttons: number[];
  97743. /**
  97744. * Defines the pointer angular sensibility along the X axis or how fast is
  97745. * the camera rotating.
  97746. */
  97747. angularSensibilityX: number;
  97748. /**
  97749. * Defines the pointer angular sensibility along the Y axis or how fast is
  97750. * the camera rotating.
  97751. */
  97752. angularSensibilityY: number;
  97753. /**
  97754. * Defines the pointer pinch precision or how fast is the camera zooming.
  97755. */
  97756. pinchPrecision: number;
  97757. /**
  97758. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97759. * from 0.
  97760. * It defines the percentage of current camera.radius to use as delta when
  97761. * pinch zoom is used.
  97762. */
  97763. pinchDeltaPercentage: number;
  97764. /**
  97765. * Defines the pointer panning sensibility or how fast is the camera moving.
  97766. */
  97767. panningSensibility: number;
  97768. /**
  97769. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97770. */
  97771. multiTouchPanning: boolean;
  97772. /**
  97773. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97774. * zoom (pinch) through multitouch.
  97775. */
  97776. multiTouchPanAndZoom: boolean;
  97777. /**
  97778. * Revers pinch action direction.
  97779. */
  97780. pinchInwards: boolean;
  97781. private _isPanClick;
  97782. private _twoFingerActivityCount;
  97783. private _isPinching;
  97784. /**
  97785. * Called on pointer POINTERMOVE event if only a single touch is active.
  97786. */
  97787. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97788. /**
  97789. * Called on pointer POINTERDOUBLETAP event.
  97790. */
  97791. protected onDoubleTap(type: string): void;
  97792. /**
  97793. * Called on pointer POINTERMOVE event if multiple touches are active.
  97794. */
  97795. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97796. /**
  97797. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97798. * press.
  97799. */
  97800. protected onButtonDown(evt: PointerEvent): void;
  97801. /**
  97802. * Called each time a new POINTERUP event occurs. Ie, for each button
  97803. * release.
  97804. */
  97805. protected onButtonUp(evt: PointerEvent): void;
  97806. /**
  97807. * Called when window becomes inactive.
  97808. */
  97809. protected onLostFocus(): void;
  97810. }
  97811. }
  97812. declare module BABYLON {
  97813. /**
  97814. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97816. */
  97817. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97818. /**
  97819. * Defines the camera the input is attached to.
  97820. */
  97821. camera: ArcRotateCamera;
  97822. /**
  97823. * Defines the list of key codes associated with the up action (increase alpha)
  97824. */
  97825. keysUp: number[];
  97826. /**
  97827. * Defines the list of key codes associated with the down action (decrease alpha)
  97828. */
  97829. keysDown: number[];
  97830. /**
  97831. * Defines the list of key codes associated with the left action (increase beta)
  97832. */
  97833. keysLeft: number[];
  97834. /**
  97835. * Defines the list of key codes associated with the right action (decrease beta)
  97836. */
  97837. keysRight: number[];
  97838. /**
  97839. * Defines the list of key codes associated with the reset action.
  97840. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97841. */
  97842. keysReset: number[];
  97843. /**
  97844. * Defines the panning sensibility of the inputs.
  97845. * (How fast is the camera paning)
  97846. */
  97847. panningSensibility: number;
  97848. /**
  97849. * Defines the zooming sensibility of the inputs.
  97850. * (How fast is the camera zooming)
  97851. */
  97852. zoomingSensibility: number;
  97853. /**
  97854. * Defines wether maintaining the alt key down switch the movement mode from
  97855. * orientation to zoom.
  97856. */
  97857. useAltToZoom: boolean;
  97858. /**
  97859. * Rotation speed of the camera
  97860. */
  97861. angularSpeed: number;
  97862. private _keys;
  97863. private _ctrlPressed;
  97864. private _altPressed;
  97865. private _onCanvasBlurObserver;
  97866. private _onKeyboardObserver;
  97867. private _engine;
  97868. private _scene;
  97869. /**
  97870. * Attach the input controls to a specific dom element to get the input from.
  97871. * @param element Defines the element the controls should be listened from
  97872. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97873. */
  97874. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97875. /**
  97876. * Detach the current controls from the specified dom element.
  97877. * @param element Defines the element to stop listening the inputs from
  97878. */
  97879. detachControl(element: Nullable<HTMLElement>): void;
  97880. /**
  97881. * Update the current camera state depending on the inputs that have been used this frame.
  97882. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97883. */
  97884. checkInputs(): void;
  97885. /**
  97886. * Gets the class name of the current intput.
  97887. * @returns the class name
  97888. */
  97889. getClassName(): string;
  97890. /**
  97891. * Get the friendly name associated with the input class.
  97892. * @returns the input friendly name
  97893. */
  97894. getSimpleName(): string;
  97895. }
  97896. }
  97897. declare module BABYLON {
  97898. /**
  97899. * Manage the mouse wheel inputs to control an arc rotate camera.
  97900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97901. */
  97902. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  97903. /**
  97904. * Defines the camera the input is attached to.
  97905. */
  97906. camera: ArcRotateCamera;
  97907. /**
  97908. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97909. */
  97910. wheelPrecision: number;
  97911. /**
  97912. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  97913. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  97914. */
  97915. wheelDeltaPercentage: number;
  97916. private _wheel;
  97917. private _observer;
  97918. private computeDeltaFromMouseWheelLegacyEvent;
  97919. /**
  97920. * Attach the input controls to a specific dom element to get the input from.
  97921. * @param element Defines the element the controls should be listened from
  97922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97923. */
  97924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97925. /**
  97926. * Detach the current controls from the specified dom element.
  97927. * @param element Defines the element to stop listening the inputs from
  97928. */
  97929. detachControl(element: Nullable<HTMLElement>): void;
  97930. /**
  97931. * Gets the class name of the current intput.
  97932. * @returns the class name
  97933. */
  97934. getClassName(): string;
  97935. /**
  97936. * Get the friendly name associated with the input class.
  97937. * @returns the input friendly name
  97938. */
  97939. getSimpleName(): string;
  97940. }
  97941. }
  97942. declare module BABYLON {
  97943. /**
  97944. * Default Inputs manager for the ArcRotateCamera.
  97945. * It groups all the default supported inputs for ease of use.
  97946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97947. */
  97948. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  97949. /**
  97950. * Instantiates a new ArcRotateCameraInputsManager.
  97951. * @param camera Defines the camera the inputs belong to
  97952. */
  97953. constructor(camera: ArcRotateCamera);
  97954. /**
  97955. * Add mouse wheel input support to the input manager.
  97956. * @returns the current input manager
  97957. */
  97958. addMouseWheel(): ArcRotateCameraInputsManager;
  97959. /**
  97960. * Add pointers input support to the input manager.
  97961. * @returns the current input manager
  97962. */
  97963. addPointers(): ArcRotateCameraInputsManager;
  97964. /**
  97965. * Add keyboard input support to the input manager.
  97966. * @returns the current input manager
  97967. */
  97968. addKeyboard(): ArcRotateCameraInputsManager;
  97969. }
  97970. }
  97971. declare module BABYLON {
  97972. /**
  97973. * This represents an orbital type of camera.
  97974. *
  97975. * 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.
  97976. * 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.
  97977. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  97978. */
  97979. export class ArcRotateCamera extends TargetCamera {
  97980. /**
  97981. * Defines the rotation angle of the camera along the longitudinal axis.
  97982. */
  97983. alpha: number;
  97984. /**
  97985. * Defines the rotation angle of the camera along the latitudinal axis.
  97986. */
  97987. beta: number;
  97988. /**
  97989. * Defines the radius of the camera from it s target point.
  97990. */
  97991. radius: number;
  97992. protected _target: Vector3;
  97993. protected _targetHost: Nullable<AbstractMesh>;
  97994. /**
  97995. * Defines the target point of the camera.
  97996. * The camera looks towards it form the radius distance.
  97997. */
  97998. target: Vector3;
  97999. /**
  98000. * Define the current local position of the camera in the scene
  98001. */
  98002. position: Vector3;
  98003. protected _upVector: Vector3;
  98004. protected _upToYMatrix: Matrix;
  98005. protected _YToUpMatrix: Matrix;
  98006. /**
  98007. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98008. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98009. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98010. */
  98011. upVector: Vector3;
  98012. /**
  98013. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98014. */
  98015. setMatUp(): void;
  98016. /**
  98017. * Current inertia value on the longitudinal axis.
  98018. * The bigger this number the longer it will take for the camera to stop.
  98019. */
  98020. inertialAlphaOffset: number;
  98021. /**
  98022. * Current inertia value on the latitudinal axis.
  98023. * The bigger this number the longer it will take for the camera to stop.
  98024. */
  98025. inertialBetaOffset: number;
  98026. /**
  98027. * Current inertia value on the radius axis.
  98028. * The bigger this number the longer it will take for the camera to stop.
  98029. */
  98030. inertialRadiusOffset: number;
  98031. /**
  98032. * Minimum allowed angle on the longitudinal axis.
  98033. * This can help limiting how the Camera is able to move in the scene.
  98034. */
  98035. lowerAlphaLimit: Nullable<number>;
  98036. /**
  98037. * Maximum allowed angle on the longitudinal axis.
  98038. * This can help limiting how the Camera is able to move in the scene.
  98039. */
  98040. upperAlphaLimit: Nullable<number>;
  98041. /**
  98042. * Minimum allowed angle on the latitudinal axis.
  98043. * This can help limiting how the Camera is able to move in the scene.
  98044. */
  98045. lowerBetaLimit: number;
  98046. /**
  98047. * Maximum allowed angle on the latitudinal axis.
  98048. * This can help limiting how the Camera is able to move in the scene.
  98049. */
  98050. upperBetaLimit: number;
  98051. /**
  98052. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98053. * This can help limiting how the Camera is able to move in the scene.
  98054. */
  98055. lowerRadiusLimit: Nullable<number>;
  98056. /**
  98057. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98058. * This can help limiting how the Camera is able to move in the scene.
  98059. */
  98060. upperRadiusLimit: Nullable<number>;
  98061. /**
  98062. * Defines the current inertia value used during panning of the camera along the X axis.
  98063. */
  98064. inertialPanningX: number;
  98065. /**
  98066. * Defines the current inertia value used during panning of the camera along the Y axis.
  98067. */
  98068. inertialPanningY: number;
  98069. /**
  98070. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98071. * Basically if your fingers moves away from more than this distance you will be considered
  98072. * in pinch mode.
  98073. */
  98074. pinchToPanMaxDistance: number;
  98075. /**
  98076. * Defines the maximum distance the camera can pan.
  98077. * This could help keeping the cammera always in your scene.
  98078. */
  98079. panningDistanceLimit: Nullable<number>;
  98080. /**
  98081. * Defines the target of the camera before paning.
  98082. */
  98083. panningOriginTarget: Vector3;
  98084. /**
  98085. * Defines the value of the inertia used during panning.
  98086. * 0 would mean stop inertia and one would mean no decelleration at all.
  98087. */
  98088. panningInertia: number;
  98089. /**
  98090. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98091. */
  98092. angularSensibilityX: number;
  98093. /**
  98094. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98095. */
  98096. angularSensibilityY: number;
  98097. /**
  98098. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98099. */
  98100. pinchPrecision: number;
  98101. /**
  98102. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98103. * It will be used instead of pinchDeltaPrecision if different from 0.
  98104. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98105. */
  98106. pinchDeltaPercentage: number;
  98107. /**
  98108. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98109. */
  98110. panningSensibility: number;
  98111. /**
  98112. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98113. */
  98114. keysUp: number[];
  98115. /**
  98116. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98117. */
  98118. keysDown: number[];
  98119. /**
  98120. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98121. */
  98122. keysLeft: number[];
  98123. /**
  98124. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98125. */
  98126. keysRight: number[];
  98127. /**
  98128. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98129. */
  98130. wheelPrecision: number;
  98131. /**
  98132. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98133. * It will be used instead of pinchDeltaPrecision if different from 0.
  98134. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98135. */
  98136. wheelDeltaPercentage: number;
  98137. /**
  98138. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98139. */
  98140. zoomOnFactor: number;
  98141. /**
  98142. * Defines a screen offset for the camera position.
  98143. */
  98144. targetScreenOffset: Vector2;
  98145. /**
  98146. * Allows the camera to be completely reversed.
  98147. * If false the camera can not arrive upside down.
  98148. */
  98149. allowUpsideDown: boolean;
  98150. /**
  98151. * Define if double tap/click is used to restore the previously saved state of the camera.
  98152. */
  98153. useInputToRestoreState: boolean;
  98154. /** @hidden */
  98155. _viewMatrix: Matrix;
  98156. /** @hidden */
  98157. _useCtrlForPanning: boolean;
  98158. /** @hidden */
  98159. _panningMouseButton: number;
  98160. /**
  98161. * Defines the input associated to the camera.
  98162. */
  98163. inputs: ArcRotateCameraInputsManager;
  98164. /** @hidden */
  98165. _reset: () => void;
  98166. /**
  98167. * Defines the allowed panning axis.
  98168. */
  98169. panningAxis: Vector3;
  98170. protected _localDirection: Vector3;
  98171. protected _transformedDirection: Vector3;
  98172. private _bouncingBehavior;
  98173. /**
  98174. * Gets the bouncing behavior of the camera if it has been enabled.
  98175. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98176. */
  98177. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98178. /**
  98179. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98180. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98181. */
  98182. useBouncingBehavior: boolean;
  98183. private _framingBehavior;
  98184. /**
  98185. * Gets the framing behavior of the camera if it has been enabled.
  98186. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98187. */
  98188. readonly framingBehavior: Nullable<FramingBehavior>;
  98189. /**
  98190. * Defines if the framing behavior of the camera is enabled on the camera.
  98191. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98192. */
  98193. useFramingBehavior: boolean;
  98194. private _autoRotationBehavior;
  98195. /**
  98196. * Gets the auto rotation behavior of the camera if it has been enabled.
  98197. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98198. */
  98199. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98200. /**
  98201. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98202. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98203. */
  98204. useAutoRotationBehavior: boolean;
  98205. /**
  98206. * Observable triggered when the mesh target has been changed on the camera.
  98207. */
  98208. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98209. /**
  98210. * Event raised when the camera is colliding with a mesh.
  98211. */
  98212. onCollide: (collidedMesh: AbstractMesh) => void;
  98213. /**
  98214. * Defines whether the camera should check collision with the objects oh the scene.
  98215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98216. */
  98217. checkCollisions: boolean;
  98218. /**
  98219. * Defines the collision radius of the camera.
  98220. * This simulates a sphere around the camera.
  98221. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98222. */
  98223. collisionRadius: Vector3;
  98224. protected _collider: Collider;
  98225. protected _previousPosition: Vector3;
  98226. protected _collisionVelocity: Vector3;
  98227. protected _newPosition: Vector3;
  98228. protected _previousAlpha: number;
  98229. protected _previousBeta: number;
  98230. protected _previousRadius: number;
  98231. protected _collisionTriggered: boolean;
  98232. protected _targetBoundingCenter: Nullable<Vector3>;
  98233. private _computationVector;
  98234. /**
  98235. * Instantiates a new ArcRotateCamera in a given scene
  98236. * @param name Defines the name of the camera
  98237. * @param alpha Defines the camera rotation along the logitudinal axis
  98238. * @param beta Defines the camera rotation along the latitudinal axis
  98239. * @param radius Defines the camera distance from its target
  98240. * @param target Defines the camera target
  98241. * @param scene Defines the scene the camera belongs to
  98242. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98243. */
  98244. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98245. /** @hidden */
  98246. _initCache(): void;
  98247. /** @hidden */
  98248. _updateCache(ignoreParentClass?: boolean): void;
  98249. protected _getTargetPosition(): Vector3;
  98250. private _storedAlpha;
  98251. private _storedBeta;
  98252. private _storedRadius;
  98253. private _storedTarget;
  98254. /**
  98255. * Stores the current state of the camera (alpha, beta, radius and target)
  98256. * @returns the camera itself
  98257. */
  98258. storeState(): Camera;
  98259. /**
  98260. * @hidden
  98261. * Restored camera state. You must call storeState() first
  98262. */
  98263. _restoreStateValues(): boolean;
  98264. /** @hidden */
  98265. _isSynchronizedViewMatrix(): boolean;
  98266. /**
  98267. * Attached controls to the current camera.
  98268. * @param element Defines the element the controls should be listened from
  98269. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98270. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98271. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98272. */
  98273. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98274. /**
  98275. * Detach the current controls from the camera.
  98276. * The camera will stop reacting to inputs.
  98277. * @param element Defines the element to stop listening the inputs from
  98278. */
  98279. detachControl(element: HTMLElement): void;
  98280. /** @hidden */
  98281. _checkInputs(): void;
  98282. protected _checkLimits(): void;
  98283. /**
  98284. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98285. */
  98286. rebuildAnglesAndRadius(): void;
  98287. /**
  98288. * Use a position to define the current camera related information like aplha, beta and radius
  98289. * @param position Defines the position to set the camera at
  98290. */
  98291. setPosition(position: Vector3): void;
  98292. /**
  98293. * Defines the target the camera should look at.
  98294. * This will automatically adapt alpha beta and radius to fit within the new target.
  98295. * @param target Defines the new target as a Vector or a mesh
  98296. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98297. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98298. */
  98299. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98300. /** @hidden */
  98301. _getViewMatrix(): Matrix;
  98302. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98303. /**
  98304. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98305. * @param meshes Defines the mesh to zoom on
  98306. * @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)
  98307. */
  98308. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98309. /**
  98310. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98311. * The target will be changed but the radius
  98312. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98313. * @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)
  98314. */
  98315. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98316. min: Vector3;
  98317. max: Vector3;
  98318. distance: number;
  98319. }, doNotUpdateMaxZ?: boolean): void;
  98320. /**
  98321. * @override
  98322. * Override Camera.createRigCamera
  98323. */
  98324. createRigCamera(name: string, cameraIndex: number): Camera;
  98325. /**
  98326. * @hidden
  98327. * @override
  98328. * Override Camera._updateRigCameras
  98329. */
  98330. _updateRigCameras(): void;
  98331. /**
  98332. * Destroy the camera and release the current resources hold by it.
  98333. */
  98334. dispose(): void;
  98335. /**
  98336. * Gets the current object class name.
  98337. * @return the class name
  98338. */
  98339. getClassName(): string;
  98340. }
  98341. }
  98342. declare module BABYLON {
  98343. /**
  98344. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98346. */
  98347. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98348. /**
  98349. * Gets the name of the behavior.
  98350. */
  98351. readonly name: string;
  98352. private _zoomStopsAnimation;
  98353. private _idleRotationSpeed;
  98354. private _idleRotationWaitTime;
  98355. private _idleRotationSpinupTime;
  98356. /**
  98357. * Sets the flag that indicates if user zooming should stop animation.
  98358. */
  98359. /**
  98360. * Gets the flag that indicates if user zooming should stop animation.
  98361. */
  98362. zoomStopsAnimation: boolean;
  98363. /**
  98364. * Sets the default speed at which the camera rotates around the model.
  98365. */
  98366. /**
  98367. * Gets the default speed at which the camera rotates around the model.
  98368. */
  98369. idleRotationSpeed: number;
  98370. /**
  98371. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98372. */
  98373. /**
  98374. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98375. */
  98376. idleRotationWaitTime: number;
  98377. /**
  98378. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98379. */
  98380. /**
  98381. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98382. */
  98383. idleRotationSpinupTime: number;
  98384. /**
  98385. * Gets a value indicating if the camera is currently rotating because of this behavior
  98386. */
  98387. readonly rotationInProgress: boolean;
  98388. private _onPrePointerObservableObserver;
  98389. private _onAfterCheckInputsObserver;
  98390. private _attachedCamera;
  98391. private _isPointerDown;
  98392. private _lastFrameTime;
  98393. private _lastInteractionTime;
  98394. private _cameraRotationSpeed;
  98395. /**
  98396. * Initializes the behavior.
  98397. */
  98398. init(): void;
  98399. /**
  98400. * Attaches the behavior to its arc rotate camera.
  98401. * @param camera Defines the camera to attach the behavior to
  98402. */
  98403. attach(camera: ArcRotateCamera): void;
  98404. /**
  98405. * Detaches the behavior from its current arc rotate camera.
  98406. */
  98407. detach(): void;
  98408. /**
  98409. * Returns true if user is scrolling.
  98410. * @return true if user is scrolling.
  98411. */
  98412. private _userIsZooming;
  98413. private _lastFrameRadius;
  98414. private _shouldAnimationStopForInteraction;
  98415. /**
  98416. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98417. */
  98418. private _applyUserInteraction;
  98419. private _userIsMoving;
  98420. }
  98421. }
  98422. declare module BABYLON {
  98423. /**
  98424. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98425. */
  98426. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98427. private ui;
  98428. /**
  98429. * The name of the behavior
  98430. */
  98431. name: string;
  98432. /**
  98433. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98434. */
  98435. distanceAwayFromFace: number;
  98436. /**
  98437. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98438. */
  98439. distanceAwayFromBottomOfFace: number;
  98440. private _faceVectors;
  98441. private _target;
  98442. private _scene;
  98443. private _onRenderObserver;
  98444. private _tmpMatrix;
  98445. private _tmpVector;
  98446. /**
  98447. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98448. * @param ui The transform node that should be attched to the mesh
  98449. */
  98450. constructor(ui: TransformNode);
  98451. /**
  98452. * Initializes the behavior
  98453. */
  98454. init(): void;
  98455. private _closestFace;
  98456. private _zeroVector;
  98457. private _lookAtTmpMatrix;
  98458. private _lookAtToRef;
  98459. /**
  98460. * Attaches the AttachToBoxBehavior to the passed in mesh
  98461. * @param target The mesh that the specified node will be attached to
  98462. */
  98463. attach(target: Mesh): void;
  98464. /**
  98465. * Detaches the behavior from the mesh
  98466. */
  98467. detach(): void;
  98468. }
  98469. }
  98470. declare module BABYLON {
  98471. /**
  98472. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98473. */
  98474. export class FadeInOutBehavior implements Behavior<Mesh> {
  98475. /**
  98476. * Time in milliseconds to delay before fading in (Default: 0)
  98477. */
  98478. delay: number;
  98479. /**
  98480. * Time in milliseconds for the mesh to fade in (Default: 300)
  98481. */
  98482. fadeInTime: number;
  98483. private _millisecondsPerFrame;
  98484. private _hovered;
  98485. private _hoverValue;
  98486. private _ownerNode;
  98487. /**
  98488. * Instatiates the FadeInOutBehavior
  98489. */
  98490. constructor();
  98491. /**
  98492. * The name of the behavior
  98493. */
  98494. readonly name: string;
  98495. /**
  98496. * Initializes the behavior
  98497. */
  98498. init(): void;
  98499. /**
  98500. * Attaches the fade behavior on the passed in mesh
  98501. * @param ownerNode The mesh that will be faded in/out once attached
  98502. */
  98503. attach(ownerNode: Mesh): void;
  98504. /**
  98505. * Detaches the behavior from the mesh
  98506. */
  98507. detach(): void;
  98508. /**
  98509. * Triggers the mesh to begin fading in or out
  98510. * @param value if the object should fade in or out (true to fade in)
  98511. */
  98512. fadeIn(value: boolean): void;
  98513. private _update;
  98514. private _setAllVisibility;
  98515. }
  98516. }
  98517. declare module BABYLON {
  98518. /**
  98519. * Class containing a set of static utilities functions for managing Pivots
  98520. * @hidden
  98521. */
  98522. export class PivotTools {
  98523. private static _PivotCached;
  98524. private static _OldPivotPoint;
  98525. private static _PivotTranslation;
  98526. private static _PivotTmpVector;
  98527. /** @hidden */
  98528. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98529. /** @hidden */
  98530. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98531. }
  98532. }
  98533. declare module BABYLON {
  98534. /**
  98535. * Class containing static functions to help procedurally build meshes
  98536. */
  98537. export class PlaneBuilder {
  98538. /**
  98539. * Creates a plane mesh
  98540. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98541. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98542. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98546. * @param name defines the name of the mesh
  98547. * @param options defines the options used to create the mesh
  98548. * @param scene defines the hosting scene
  98549. * @returns the plane mesh
  98550. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98551. */
  98552. static CreatePlane(name: string, options: {
  98553. size?: number;
  98554. width?: number;
  98555. height?: number;
  98556. sideOrientation?: number;
  98557. frontUVs?: Vector4;
  98558. backUVs?: Vector4;
  98559. updatable?: boolean;
  98560. sourcePlane?: Plane;
  98561. }, scene?: Nullable<Scene>): Mesh;
  98562. }
  98563. }
  98564. declare module BABYLON {
  98565. /**
  98566. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98567. */
  98568. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98569. private static _AnyMouseID;
  98570. /**
  98571. * Abstract mesh the behavior is set on
  98572. */
  98573. attachedNode: AbstractMesh;
  98574. private _dragPlane;
  98575. private _scene;
  98576. private _pointerObserver;
  98577. private _beforeRenderObserver;
  98578. private static _planeScene;
  98579. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98580. /**
  98581. * 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)
  98582. */
  98583. maxDragAngle: number;
  98584. /**
  98585. * @hidden
  98586. */
  98587. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98588. /**
  98589. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98590. */
  98591. currentDraggingPointerID: number;
  98592. /**
  98593. * The last position where the pointer hit the drag plane in world space
  98594. */
  98595. lastDragPosition: Vector3;
  98596. /**
  98597. * If the behavior is currently in a dragging state
  98598. */
  98599. dragging: boolean;
  98600. /**
  98601. * 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)
  98602. */
  98603. dragDeltaRatio: number;
  98604. /**
  98605. * If the drag plane orientation should be updated during the dragging (Default: true)
  98606. */
  98607. updateDragPlane: boolean;
  98608. private _debugMode;
  98609. private _moving;
  98610. /**
  98611. * Fires each time the attached mesh is dragged with the pointer
  98612. * * delta between last drag position and current drag position in world space
  98613. * * dragDistance along the drag axis
  98614. * * dragPlaneNormal normal of the current drag plane used during the drag
  98615. * * dragPlanePoint in world space where the drag intersects the drag plane
  98616. */
  98617. onDragObservable: Observable<{
  98618. delta: Vector3;
  98619. dragPlanePoint: Vector3;
  98620. dragPlaneNormal: Vector3;
  98621. dragDistance: number;
  98622. pointerId: number;
  98623. }>;
  98624. /**
  98625. * Fires each time a drag begins (eg. mouse down on mesh)
  98626. */
  98627. onDragStartObservable: Observable<{
  98628. dragPlanePoint: Vector3;
  98629. pointerId: number;
  98630. }>;
  98631. /**
  98632. * Fires each time a drag ends (eg. mouse release after drag)
  98633. */
  98634. onDragEndObservable: Observable<{
  98635. dragPlanePoint: Vector3;
  98636. pointerId: number;
  98637. }>;
  98638. /**
  98639. * If the attached mesh should be moved when dragged
  98640. */
  98641. moveAttached: boolean;
  98642. /**
  98643. * If the drag behavior will react to drag events (Default: true)
  98644. */
  98645. enabled: boolean;
  98646. /**
  98647. * If camera controls should be detached during the drag
  98648. */
  98649. detachCameraControls: boolean;
  98650. /**
  98651. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98652. */
  98653. useObjectOrienationForDragging: boolean;
  98654. private _options;
  98655. /**
  98656. * Creates a pointer drag behavior that can be attached to a mesh
  98657. * @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)
  98658. */
  98659. constructor(options?: {
  98660. dragAxis?: Vector3;
  98661. dragPlaneNormal?: Vector3;
  98662. });
  98663. /**
  98664. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98665. */
  98666. validateDrag: (targetPosition: Vector3) => boolean;
  98667. /**
  98668. * The name of the behavior
  98669. */
  98670. readonly name: string;
  98671. /**
  98672. * Initializes the behavior
  98673. */
  98674. init(): void;
  98675. private _tmpVector;
  98676. private _alternatePickedPoint;
  98677. private _worldDragAxis;
  98678. private _targetPosition;
  98679. private _attachedElement;
  98680. /**
  98681. * Attaches the drag behavior the passed in mesh
  98682. * @param ownerNode The mesh that will be dragged around once attached
  98683. */
  98684. attach(ownerNode: AbstractMesh): void;
  98685. /**
  98686. * Force relase the drag action by code.
  98687. */
  98688. releaseDrag(): void;
  98689. private _startDragRay;
  98690. private _lastPointerRay;
  98691. /**
  98692. * Simulates the start of a pointer drag event on the behavior
  98693. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98694. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98695. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98696. */
  98697. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98698. private _startDrag;
  98699. private _dragDelta;
  98700. private _moveDrag;
  98701. private _pickWithRayOnDragPlane;
  98702. private _pointA;
  98703. private _pointB;
  98704. private _pointC;
  98705. private _lineA;
  98706. private _lineB;
  98707. private _localAxis;
  98708. private _lookAt;
  98709. private _updateDragPlanePosition;
  98710. /**
  98711. * Detaches the behavior from the mesh
  98712. */
  98713. detach(): void;
  98714. }
  98715. }
  98716. declare module BABYLON {
  98717. /**
  98718. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98719. */
  98720. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98721. private _dragBehaviorA;
  98722. private _dragBehaviorB;
  98723. private _startDistance;
  98724. private _initialScale;
  98725. private _targetScale;
  98726. private _ownerNode;
  98727. private _sceneRenderObserver;
  98728. /**
  98729. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98730. */
  98731. constructor();
  98732. /**
  98733. * The name of the behavior
  98734. */
  98735. readonly name: string;
  98736. /**
  98737. * Initializes the behavior
  98738. */
  98739. init(): void;
  98740. private _getCurrentDistance;
  98741. /**
  98742. * Attaches the scale behavior the passed in mesh
  98743. * @param ownerNode The mesh that will be scaled around once attached
  98744. */
  98745. attach(ownerNode: Mesh): void;
  98746. /**
  98747. * Detaches the behavior from the mesh
  98748. */
  98749. detach(): void;
  98750. }
  98751. }
  98752. declare module BABYLON {
  98753. /**
  98754. * 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
  98755. */
  98756. export class SixDofDragBehavior implements Behavior<Mesh> {
  98757. private static _virtualScene;
  98758. private _ownerNode;
  98759. private _sceneRenderObserver;
  98760. private _scene;
  98761. private _targetPosition;
  98762. private _virtualOriginMesh;
  98763. private _virtualDragMesh;
  98764. private _pointerObserver;
  98765. private _moving;
  98766. private _startingOrientation;
  98767. /**
  98768. * 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)
  98769. */
  98770. private zDragFactor;
  98771. /**
  98772. * If the object should rotate to face the drag origin
  98773. */
  98774. rotateDraggedObject: boolean;
  98775. /**
  98776. * If the behavior is currently in a dragging state
  98777. */
  98778. dragging: boolean;
  98779. /**
  98780. * 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)
  98781. */
  98782. dragDeltaRatio: number;
  98783. /**
  98784. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98785. */
  98786. currentDraggingPointerID: number;
  98787. /**
  98788. * If camera controls should be detached during the drag
  98789. */
  98790. detachCameraControls: boolean;
  98791. /**
  98792. * Fires each time a drag starts
  98793. */
  98794. onDragStartObservable: Observable<{}>;
  98795. /**
  98796. * Fires each time a drag ends (eg. mouse release after drag)
  98797. */
  98798. onDragEndObservable: Observable<{}>;
  98799. /**
  98800. * 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
  98801. */
  98802. constructor();
  98803. /**
  98804. * The name of the behavior
  98805. */
  98806. readonly name: string;
  98807. /**
  98808. * Initializes the behavior
  98809. */
  98810. init(): void;
  98811. /**
  98812. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  98813. */
  98814. private readonly _pointerCamera;
  98815. /**
  98816. * Attaches the scale behavior the passed in mesh
  98817. * @param ownerNode The mesh that will be scaled around once attached
  98818. */
  98819. attach(ownerNode: Mesh): void;
  98820. /**
  98821. * Detaches the behavior from the mesh
  98822. */
  98823. detach(): void;
  98824. }
  98825. }
  98826. declare module BABYLON {
  98827. /**
  98828. * Class used to apply inverse kinematics to bones
  98829. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98830. */
  98831. export class BoneIKController {
  98832. private static _tmpVecs;
  98833. private static _tmpQuat;
  98834. private static _tmpMats;
  98835. /**
  98836. * Gets or sets the target mesh
  98837. */
  98838. targetMesh: AbstractMesh;
  98839. /** Gets or sets the mesh used as pole */
  98840. poleTargetMesh: AbstractMesh;
  98841. /**
  98842. * Gets or sets the bone used as pole
  98843. */
  98844. poleTargetBone: Nullable<Bone>;
  98845. /**
  98846. * Gets or sets the target position
  98847. */
  98848. targetPosition: Vector3;
  98849. /**
  98850. * Gets or sets the pole target position
  98851. */
  98852. poleTargetPosition: Vector3;
  98853. /**
  98854. * Gets or sets the pole target local offset
  98855. */
  98856. poleTargetLocalOffset: Vector3;
  98857. /**
  98858. * Gets or sets the pole angle
  98859. */
  98860. poleAngle: number;
  98861. /**
  98862. * Gets or sets the mesh associated with the controller
  98863. */
  98864. mesh: AbstractMesh;
  98865. /**
  98866. * 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)
  98867. */
  98868. slerpAmount: number;
  98869. private _bone1Quat;
  98870. private _bone1Mat;
  98871. private _bone2Ang;
  98872. private _bone1;
  98873. private _bone2;
  98874. private _bone1Length;
  98875. private _bone2Length;
  98876. private _maxAngle;
  98877. private _maxReach;
  98878. private _rightHandedSystem;
  98879. private _bendAxis;
  98880. private _slerping;
  98881. private _adjustRoll;
  98882. /**
  98883. * Gets or sets maximum allowed angle
  98884. */
  98885. maxAngle: number;
  98886. /**
  98887. * Creates a new BoneIKController
  98888. * @param mesh defines the mesh to control
  98889. * @param bone defines the bone to control
  98890. * @param options defines options to set up the controller
  98891. */
  98892. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  98893. targetMesh?: AbstractMesh;
  98894. poleTargetMesh?: AbstractMesh;
  98895. poleTargetBone?: Bone;
  98896. poleTargetLocalOffset?: Vector3;
  98897. poleAngle?: number;
  98898. bendAxis?: Vector3;
  98899. maxAngle?: number;
  98900. slerpAmount?: number;
  98901. });
  98902. private _setMaxAngle;
  98903. /**
  98904. * Force the controller to update the bones
  98905. */
  98906. update(): void;
  98907. }
  98908. }
  98909. declare module BABYLON {
  98910. /**
  98911. * Class used to make a bone look toward a point in space
  98912. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  98913. */
  98914. export class BoneLookController {
  98915. private static _tmpVecs;
  98916. private static _tmpQuat;
  98917. private static _tmpMats;
  98918. /**
  98919. * The target Vector3 that the bone will look at
  98920. */
  98921. target: Vector3;
  98922. /**
  98923. * The mesh that the bone is attached to
  98924. */
  98925. mesh: AbstractMesh;
  98926. /**
  98927. * The bone that will be looking to the target
  98928. */
  98929. bone: Bone;
  98930. /**
  98931. * The up axis of the coordinate system that is used when the bone is rotated
  98932. */
  98933. upAxis: Vector3;
  98934. /**
  98935. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  98936. */
  98937. upAxisSpace: Space;
  98938. /**
  98939. * Used to make an adjustment to the yaw of the bone
  98940. */
  98941. adjustYaw: number;
  98942. /**
  98943. * Used to make an adjustment to the pitch of the bone
  98944. */
  98945. adjustPitch: number;
  98946. /**
  98947. * Used to make an adjustment to the roll of the bone
  98948. */
  98949. adjustRoll: number;
  98950. /**
  98951. * 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)
  98952. */
  98953. slerpAmount: number;
  98954. private _minYaw;
  98955. private _maxYaw;
  98956. private _minPitch;
  98957. private _maxPitch;
  98958. private _minYawSin;
  98959. private _minYawCos;
  98960. private _maxYawSin;
  98961. private _maxYawCos;
  98962. private _midYawConstraint;
  98963. private _minPitchTan;
  98964. private _maxPitchTan;
  98965. private _boneQuat;
  98966. private _slerping;
  98967. private _transformYawPitch;
  98968. private _transformYawPitchInv;
  98969. private _firstFrameSkipped;
  98970. private _yawRange;
  98971. private _fowardAxis;
  98972. /**
  98973. * Gets or sets the minimum yaw angle that the bone can look to
  98974. */
  98975. minYaw: number;
  98976. /**
  98977. * Gets or sets the maximum yaw angle that the bone can look to
  98978. */
  98979. maxYaw: number;
  98980. /**
  98981. * Gets or sets the minimum pitch angle that the bone can look to
  98982. */
  98983. minPitch: number;
  98984. /**
  98985. * Gets or sets the maximum pitch angle that the bone can look to
  98986. */
  98987. maxPitch: number;
  98988. /**
  98989. * Create a BoneLookController
  98990. * @param mesh the mesh that the bone belongs to
  98991. * @param bone the bone that will be looking to the target
  98992. * @param target the target Vector3 to look at
  98993. * @param options optional settings:
  98994. * * maxYaw: the maximum angle the bone will yaw to
  98995. * * minYaw: the minimum angle the bone will yaw to
  98996. * * maxPitch: the maximum angle the bone will pitch to
  98997. * * minPitch: the minimum angle the bone will yaw to
  98998. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  98999. * * upAxis: the up axis of the coordinate system
  99000. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99001. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99002. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99003. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99004. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99005. * * adjustRoll: used to make an adjustment to the roll of the bone
  99006. **/
  99007. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99008. maxYaw?: number;
  99009. minYaw?: number;
  99010. maxPitch?: number;
  99011. minPitch?: number;
  99012. slerpAmount?: number;
  99013. upAxis?: Vector3;
  99014. upAxisSpace?: Space;
  99015. yawAxis?: Vector3;
  99016. pitchAxis?: Vector3;
  99017. adjustYaw?: number;
  99018. adjustPitch?: number;
  99019. adjustRoll?: number;
  99020. });
  99021. /**
  99022. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99023. */
  99024. update(): void;
  99025. private _getAngleDiff;
  99026. private _getAngleBetween;
  99027. private _isAngleBetween;
  99028. }
  99029. }
  99030. declare module BABYLON {
  99031. /**
  99032. * Manage the gamepad inputs to control an arc rotate camera.
  99033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99034. */
  99035. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99036. /**
  99037. * Defines the camera the input is attached to.
  99038. */
  99039. camera: ArcRotateCamera;
  99040. /**
  99041. * Defines the gamepad the input is gathering event from.
  99042. */
  99043. gamepad: Nullable<Gamepad>;
  99044. /**
  99045. * Defines the gamepad rotation sensiblity.
  99046. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99047. */
  99048. gamepadRotationSensibility: number;
  99049. /**
  99050. * Defines the gamepad move sensiblity.
  99051. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99052. */
  99053. gamepadMoveSensibility: number;
  99054. private _onGamepadConnectedObserver;
  99055. private _onGamepadDisconnectedObserver;
  99056. /**
  99057. * Attach the input controls to a specific dom element to get the input from.
  99058. * @param element Defines the element the controls should be listened from
  99059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99060. */
  99061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99062. /**
  99063. * Detach the current controls from the specified dom element.
  99064. * @param element Defines the element to stop listening the inputs from
  99065. */
  99066. detachControl(element: Nullable<HTMLElement>): void;
  99067. /**
  99068. * Update the current camera state depending on the inputs that have been used this frame.
  99069. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99070. */
  99071. checkInputs(): void;
  99072. /**
  99073. * Gets the class name of the current intput.
  99074. * @returns the class name
  99075. */
  99076. getClassName(): string;
  99077. /**
  99078. * Get the friendly name associated with the input class.
  99079. * @returns the input friendly name
  99080. */
  99081. getSimpleName(): string;
  99082. }
  99083. }
  99084. declare module BABYLON {
  99085. interface ArcRotateCameraInputsManager {
  99086. /**
  99087. * Add orientation input support to the input manager.
  99088. * @returns the current input manager
  99089. */
  99090. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99091. }
  99092. /**
  99093. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99095. */
  99096. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99097. /**
  99098. * Defines the camera the input is attached to.
  99099. */
  99100. camera: ArcRotateCamera;
  99101. /**
  99102. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99103. */
  99104. alphaCorrection: number;
  99105. /**
  99106. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99107. */
  99108. gammaCorrection: number;
  99109. private _alpha;
  99110. private _gamma;
  99111. private _dirty;
  99112. private _deviceOrientationHandler;
  99113. /**
  99114. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99115. */
  99116. constructor();
  99117. /**
  99118. * Attach the input controls to a specific dom element to get the input from.
  99119. * @param element Defines the element the controls should be listened from
  99120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99121. */
  99122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99123. /** @hidden */
  99124. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99125. /**
  99126. * Update the current camera state depending on the inputs that have been used this frame.
  99127. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99128. */
  99129. checkInputs(): void;
  99130. /**
  99131. * Detach the current controls from the specified dom element.
  99132. * @param element Defines the element to stop listening the inputs from
  99133. */
  99134. detachControl(element: Nullable<HTMLElement>): void;
  99135. /**
  99136. * Gets the class name of the current intput.
  99137. * @returns the class name
  99138. */
  99139. getClassName(): string;
  99140. /**
  99141. * Get the friendly name associated with the input class.
  99142. * @returns the input friendly name
  99143. */
  99144. getSimpleName(): string;
  99145. }
  99146. }
  99147. declare module BABYLON {
  99148. /**
  99149. * Listen to mouse events to control the camera.
  99150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99151. */
  99152. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99153. /**
  99154. * Defines the camera the input is attached to.
  99155. */
  99156. camera: FlyCamera;
  99157. /**
  99158. * Defines if touch is enabled. (Default is true.)
  99159. */
  99160. touchEnabled: boolean;
  99161. /**
  99162. * Defines the buttons associated with the input to handle camera rotation.
  99163. */
  99164. buttons: number[];
  99165. /**
  99166. * Assign buttons for Yaw control.
  99167. */
  99168. buttonsYaw: number[];
  99169. /**
  99170. * Assign buttons for Pitch control.
  99171. */
  99172. buttonsPitch: number[];
  99173. /**
  99174. * Assign buttons for Roll control.
  99175. */
  99176. buttonsRoll: number[];
  99177. /**
  99178. * Detect if any button is being pressed while mouse is moved.
  99179. * -1 = Mouse locked.
  99180. * 0 = Left button.
  99181. * 1 = Middle Button.
  99182. * 2 = Right Button.
  99183. */
  99184. activeButton: number;
  99185. /**
  99186. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99187. * Higher values reduce its sensitivity.
  99188. */
  99189. angularSensibility: number;
  99190. private _mousemoveCallback;
  99191. private _observer;
  99192. private _rollObserver;
  99193. private previousPosition;
  99194. private noPreventDefault;
  99195. private element;
  99196. /**
  99197. * Listen to mouse events to control the camera.
  99198. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99200. */
  99201. constructor(touchEnabled?: boolean);
  99202. /**
  99203. * Attach the mouse control to the HTML DOM element.
  99204. * @param element Defines the element that listens to the input events.
  99205. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99206. */
  99207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99208. /**
  99209. * Detach the current controls from the specified dom element.
  99210. * @param element Defines the element to stop listening the inputs from
  99211. */
  99212. detachControl(element: Nullable<HTMLElement>): void;
  99213. /**
  99214. * Gets the class name of the current input.
  99215. * @returns the class name.
  99216. */
  99217. getClassName(): string;
  99218. /**
  99219. * Get the friendly name associated with the input class.
  99220. * @returns the input's friendly name.
  99221. */
  99222. getSimpleName(): string;
  99223. private _pointerInput;
  99224. private _onMouseMove;
  99225. /**
  99226. * Rotate camera by mouse offset.
  99227. */
  99228. private rotateCamera;
  99229. }
  99230. }
  99231. declare module BABYLON {
  99232. /**
  99233. * Default Inputs manager for the FlyCamera.
  99234. * It groups all the default supported inputs for ease of use.
  99235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99236. */
  99237. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99238. /**
  99239. * Instantiates a new FlyCameraInputsManager.
  99240. * @param camera Defines the camera the inputs belong to.
  99241. */
  99242. constructor(camera: FlyCamera);
  99243. /**
  99244. * Add keyboard input support to the input manager.
  99245. * @returns the new FlyCameraKeyboardMoveInput().
  99246. */
  99247. addKeyboard(): FlyCameraInputsManager;
  99248. /**
  99249. * Add mouse input support to the input manager.
  99250. * @param touchEnabled Enable touch screen support.
  99251. * @returns the new FlyCameraMouseInput().
  99252. */
  99253. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99254. }
  99255. }
  99256. declare module BABYLON {
  99257. /**
  99258. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99259. * such as in a 3D Space Shooter or a Flight Simulator.
  99260. */
  99261. export class FlyCamera extends TargetCamera {
  99262. /**
  99263. * Define the collision ellipsoid of the camera.
  99264. * This is helpful for simulating a camera body, like a player's body.
  99265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99266. */
  99267. ellipsoid: Vector3;
  99268. /**
  99269. * Define an offset for the position of the ellipsoid around the camera.
  99270. * This can be helpful if the camera is attached away from the player's body center,
  99271. * such as at its head.
  99272. */
  99273. ellipsoidOffset: Vector3;
  99274. /**
  99275. * Enable or disable collisions of the camera with the rest of the scene objects.
  99276. */
  99277. checkCollisions: boolean;
  99278. /**
  99279. * Enable or disable gravity on the camera.
  99280. */
  99281. applyGravity: boolean;
  99282. /**
  99283. * Define the current direction the camera is moving to.
  99284. */
  99285. cameraDirection: Vector3;
  99286. /**
  99287. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99288. * This overrides and empties cameraRotation.
  99289. */
  99290. rotationQuaternion: Quaternion;
  99291. /**
  99292. * Track Roll to maintain the wanted Rolling when looking around.
  99293. */
  99294. _trackRoll: number;
  99295. /**
  99296. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99297. */
  99298. rollCorrect: number;
  99299. /**
  99300. * Mimic a banked turn, Rolling the camera when Yawing.
  99301. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99302. */
  99303. bankedTurn: boolean;
  99304. /**
  99305. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99306. */
  99307. bankedTurnLimit: number;
  99308. /**
  99309. * Value of 0 disables the banked Roll.
  99310. * Value of 1 is equal to the Yaw angle in radians.
  99311. */
  99312. bankedTurnMultiplier: number;
  99313. /**
  99314. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99315. */
  99316. inputs: FlyCameraInputsManager;
  99317. /**
  99318. * Gets the input sensibility for mouse input.
  99319. * Higher values reduce sensitivity.
  99320. */
  99321. /**
  99322. * Sets the input sensibility for a mouse input.
  99323. * Higher values reduce sensitivity.
  99324. */
  99325. angularSensibility: number;
  99326. /**
  99327. * Get the keys for camera movement forward.
  99328. */
  99329. /**
  99330. * Set the keys for camera movement forward.
  99331. */
  99332. keysForward: number[];
  99333. /**
  99334. * Get the keys for camera movement backward.
  99335. */
  99336. keysBackward: number[];
  99337. /**
  99338. * Get the keys for camera movement up.
  99339. */
  99340. /**
  99341. * Set the keys for camera movement up.
  99342. */
  99343. keysUp: number[];
  99344. /**
  99345. * Get the keys for camera movement down.
  99346. */
  99347. /**
  99348. * Set the keys for camera movement down.
  99349. */
  99350. keysDown: number[];
  99351. /**
  99352. * Get the keys for camera movement left.
  99353. */
  99354. /**
  99355. * Set the keys for camera movement left.
  99356. */
  99357. keysLeft: number[];
  99358. /**
  99359. * Set the keys for camera movement right.
  99360. */
  99361. /**
  99362. * Set the keys for camera movement right.
  99363. */
  99364. keysRight: number[];
  99365. /**
  99366. * Event raised when the camera collides with a mesh in the scene.
  99367. */
  99368. onCollide: (collidedMesh: AbstractMesh) => void;
  99369. private _collider;
  99370. private _needMoveForGravity;
  99371. private _oldPosition;
  99372. private _diffPosition;
  99373. private _newPosition;
  99374. /** @hidden */
  99375. _localDirection: Vector3;
  99376. /** @hidden */
  99377. _transformedDirection: Vector3;
  99378. /**
  99379. * Instantiates a FlyCamera.
  99380. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99381. * such as in a 3D Space Shooter or a Flight Simulator.
  99382. * @param name Define the name of the camera in the scene.
  99383. * @param position Define the starting position of the camera in the scene.
  99384. * @param scene Define the scene the camera belongs to.
  99385. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99386. */
  99387. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99388. /**
  99389. * Attach a control to the HTML DOM element.
  99390. * @param element Defines the element that listens to the input events.
  99391. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99392. */
  99393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99394. /**
  99395. * Detach a control from the HTML DOM element.
  99396. * The camera will stop reacting to that input.
  99397. * @param element Defines the element that listens to the input events.
  99398. */
  99399. detachControl(element: HTMLElement): void;
  99400. private _collisionMask;
  99401. /**
  99402. * Get the mask that the camera ignores in collision events.
  99403. */
  99404. /**
  99405. * Set the mask that the camera ignores in collision events.
  99406. */
  99407. collisionMask: number;
  99408. /** @hidden */
  99409. _collideWithWorld(displacement: Vector3): void;
  99410. /** @hidden */
  99411. private _onCollisionPositionChange;
  99412. /** @hidden */
  99413. _checkInputs(): void;
  99414. /** @hidden */
  99415. _decideIfNeedsToMove(): boolean;
  99416. /** @hidden */
  99417. _updatePosition(): void;
  99418. /**
  99419. * Restore the Roll to its target value at the rate specified.
  99420. * @param rate - Higher means slower restoring.
  99421. * @hidden
  99422. */
  99423. restoreRoll(rate: number): void;
  99424. /**
  99425. * Destroy the camera and release the current resources held by it.
  99426. */
  99427. dispose(): void;
  99428. /**
  99429. * Get the current object class name.
  99430. * @returns the class name.
  99431. */
  99432. getClassName(): string;
  99433. }
  99434. }
  99435. declare module BABYLON {
  99436. /**
  99437. * Listen to keyboard events to control the camera.
  99438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99439. */
  99440. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99441. /**
  99442. * Defines the camera the input is attached to.
  99443. */
  99444. camera: FlyCamera;
  99445. /**
  99446. * The list of keyboard keys used to control the forward move of the camera.
  99447. */
  99448. keysForward: number[];
  99449. /**
  99450. * The list of keyboard keys used to control the backward move of the camera.
  99451. */
  99452. keysBackward: number[];
  99453. /**
  99454. * The list of keyboard keys used to control the forward move of the camera.
  99455. */
  99456. keysUp: number[];
  99457. /**
  99458. * The list of keyboard keys used to control the backward move of the camera.
  99459. */
  99460. keysDown: number[];
  99461. /**
  99462. * The list of keyboard keys used to control the right strafe move of the camera.
  99463. */
  99464. keysRight: number[];
  99465. /**
  99466. * The list of keyboard keys used to control the left strafe move of the camera.
  99467. */
  99468. keysLeft: number[];
  99469. private _keys;
  99470. private _onCanvasBlurObserver;
  99471. private _onKeyboardObserver;
  99472. private _engine;
  99473. private _scene;
  99474. /**
  99475. * Attach the input controls to a specific dom element to get the input from.
  99476. * @param element Defines the element the controls should be listened from
  99477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99478. */
  99479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99480. /**
  99481. * Detach the current controls from the specified dom element.
  99482. * @param element Defines the element to stop listening the inputs from
  99483. */
  99484. detachControl(element: Nullable<HTMLElement>): void;
  99485. /**
  99486. * Gets the class name of the current intput.
  99487. * @returns the class name
  99488. */
  99489. getClassName(): string;
  99490. /** @hidden */
  99491. _onLostFocus(e: FocusEvent): void;
  99492. /**
  99493. * Get the friendly name associated with the input class.
  99494. * @returns the input friendly name
  99495. */
  99496. getSimpleName(): string;
  99497. /**
  99498. * Update the current camera state depending on the inputs that have been used this frame.
  99499. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99500. */
  99501. checkInputs(): void;
  99502. }
  99503. }
  99504. declare module BABYLON {
  99505. /**
  99506. * Manage the mouse wheel inputs to control a follow camera.
  99507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99508. */
  99509. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99510. /**
  99511. * Defines the camera the input is attached to.
  99512. */
  99513. camera: FollowCamera;
  99514. /**
  99515. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99516. */
  99517. axisControlRadius: boolean;
  99518. /**
  99519. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99520. */
  99521. axisControlHeight: boolean;
  99522. /**
  99523. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99524. */
  99525. axisControlRotation: boolean;
  99526. /**
  99527. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99528. * relation to mouseWheel events.
  99529. */
  99530. wheelPrecision: number;
  99531. /**
  99532. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99533. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99534. */
  99535. wheelDeltaPercentage: number;
  99536. private _wheel;
  99537. private _observer;
  99538. /**
  99539. * Attach the input controls to a specific dom element to get the input from.
  99540. * @param element Defines the element the controls should be listened from
  99541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99542. */
  99543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99544. /**
  99545. * Detach the current controls from the specified dom element.
  99546. * @param element Defines the element to stop listening the inputs from
  99547. */
  99548. detachControl(element: Nullable<HTMLElement>): void;
  99549. /**
  99550. * Gets the class name of the current intput.
  99551. * @returns the class name
  99552. */
  99553. getClassName(): string;
  99554. /**
  99555. * Get the friendly name associated with the input class.
  99556. * @returns the input friendly name
  99557. */
  99558. getSimpleName(): string;
  99559. }
  99560. }
  99561. declare module BABYLON {
  99562. /**
  99563. * Manage the pointers inputs to control an follow camera.
  99564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99565. */
  99566. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99567. /**
  99568. * Defines the camera the input is attached to.
  99569. */
  99570. camera: FollowCamera;
  99571. /**
  99572. * Gets the class name of the current input.
  99573. * @returns the class name
  99574. */
  99575. getClassName(): string;
  99576. /**
  99577. * Defines the pointer angular sensibility along the X axis or how fast is
  99578. * the camera rotating.
  99579. * A negative number will reverse the axis direction.
  99580. */
  99581. angularSensibilityX: number;
  99582. /**
  99583. * Defines the pointer angular sensibility along the Y axis or how fast is
  99584. * the camera rotating.
  99585. * A negative number will reverse the axis direction.
  99586. */
  99587. angularSensibilityY: number;
  99588. /**
  99589. * Defines the pointer pinch precision or how fast is the camera zooming.
  99590. * A negative number will reverse the axis direction.
  99591. */
  99592. pinchPrecision: number;
  99593. /**
  99594. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99595. * from 0.
  99596. * It defines the percentage of current camera.radius to use as delta when
  99597. * pinch zoom is used.
  99598. */
  99599. pinchDeltaPercentage: number;
  99600. /**
  99601. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99602. */
  99603. axisXControlRadius: boolean;
  99604. /**
  99605. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99606. */
  99607. axisXControlHeight: boolean;
  99608. /**
  99609. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99610. */
  99611. axisXControlRotation: boolean;
  99612. /**
  99613. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99614. */
  99615. axisYControlRadius: boolean;
  99616. /**
  99617. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99618. */
  99619. axisYControlHeight: boolean;
  99620. /**
  99621. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99622. */
  99623. axisYControlRotation: boolean;
  99624. /**
  99625. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99626. */
  99627. axisPinchControlRadius: boolean;
  99628. /**
  99629. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99630. */
  99631. axisPinchControlHeight: boolean;
  99632. /**
  99633. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99634. */
  99635. axisPinchControlRotation: boolean;
  99636. /**
  99637. * Log error messages if basic misconfiguration has occurred.
  99638. */
  99639. warningEnable: boolean;
  99640. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99641. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99642. private _warningCounter;
  99643. private _warning;
  99644. }
  99645. }
  99646. declare module BABYLON {
  99647. /**
  99648. * Default Inputs manager for the FollowCamera.
  99649. * It groups all the default supported inputs for ease of use.
  99650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99651. */
  99652. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99653. /**
  99654. * Instantiates a new FollowCameraInputsManager.
  99655. * @param camera Defines the camera the inputs belong to
  99656. */
  99657. constructor(camera: FollowCamera);
  99658. /**
  99659. * Add keyboard input support to the input manager.
  99660. * @returns the current input manager
  99661. */
  99662. addKeyboard(): FollowCameraInputsManager;
  99663. /**
  99664. * Add mouse wheel input support to the input manager.
  99665. * @returns the current input manager
  99666. */
  99667. addMouseWheel(): FollowCameraInputsManager;
  99668. /**
  99669. * Add pointers input support to the input manager.
  99670. * @returns the current input manager
  99671. */
  99672. addPointers(): FollowCameraInputsManager;
  99673. /**
  99674. * Add orientation input support to the input manager.
  99675. * @returns the current input manager
  99676. */
  99677. addVRDeviceOrientation(): FollowCameraInputsManager;
  99678. }
  99679. }
  99680. declare module BABYLON {
  99681. /**
  99682. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99683. * an arc rotate version arcFollowCamera are available.
  99684. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99685. */
  99686. export class FollowCamera extends TargetCamera {
  99687. /**
  99688. * Distance the follow camera should follow an object at
  99689. */
  99690. radius: number;
  99691. /**
  99692. * Minimum allowed distance of the camera to the axis of rotation
  99693. * (The camera can not get closer).
  99694. * This can help limiting how the Camera is able to move in the scene.
  99695. */
  99696. lowerRadiusLimit: Nullable<number>;
  99697. /**
  99698. * Maximum allowed distance of the camera to the axis of rotation
  99699. * (The camera can not get further).
  99700. * This can help limiting how the Camera is able to move in the scene.
  99701. */
  99702. upperRadiusLimit: Nullable<number>;
  99703. /**
  99704. * Define a rotation offset between the camera and the object it follows
  99705. */
  99706. rotationOffset: number;
  99707. /**
  99708. * Minimum allowed angle to camera position relative to target object.
  99709. * This can help limiting how the Camera is able to move in the scene.
  99710. */
  99711. lowerRotationOffsetLimit: Nullable<number>;
  99712. /**
  99713. * Maximum allowed angle to camera position relative to target object.
  99714. * This can help limiting how the Camera is able to move in the scene.
  99715. */
  99716. upperRotationOffsetLimit: Nullable<number>;
  99717. /**
  99718. * Define a height offset between the camera and the object it follows.
  99719. * It can help following an object from the top (like a car chaing a plane)
  99720. */
  99721. heightOffset: number;
  99722. /**
  99723. * Minimum allowed height of camera position relative to target object.
  99724. * This can help limiting how the Camera is able to move in the scene.
  99725. */
  99726. lowerHeightOffsetLimit: Nullable<number>;
  99727. /**
  99728. * Maximum allowed height of camera position relative to target object.
  99729. * This can help limiting how the Camera is able to move in the scene.
  99730. */
  99731. upperHeightOffsetLimit: Nullable<number>;
  99732. /**
  99733. * Define how fast the camera can accelerate to follow it s target.
  99734. */
  99735. cameraAcceleration: number;
  99736. /**
  99737. * Define the speed limit of the camera following an object.
  99738. */
  99739. maxCameraSpeed: number;
  99740. /**
  99741. * Define the target of the camera.
  99742. */
  99743. lockedTarget: Nullable<AbstractMesh>;
  99744. /**
  99745. * Defines the input associated with the camera.
  99746. */
  99747. inputs: FollowCameraInputsManager;
  99748. /**
  99749. * Instantiates the follow camera.
  99750. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99751. * @param name Define the name of the camera in the scene
  99752. * @param position Define the position of the camera
  99753. * @param scene Define the scene the camera belong to
  99754. * @param lockedTarget Define the target of the camera
  99755. */
  99756. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99757. private _follow;
  99758. /**
  99759. * Attached controls to the current camera.
  99760. * @param element Defines the element the controls should be listened from
  99761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99762. */
  99763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99764. /**
  99765. * Detach the current controls from the camera.
  99766. * The camera will stop reacting to inputs.
  99767. * @param element Defines the element to stop listening the inputs from
  99768. */
  99769. detachControl(element: HTMLElement): void;
  99770. /** @hidden */
  99771. _checkInputs(): void;
  99772. private _checkLimits;
  99773. /**
  99774. * Gets the camera class name.
  99775. * @returns the class name
  99776. */
  99777. getClassName(): string;
  99778. }
  99779. /**
  99780. * Arc Rotate version of the follow camera.
  99781. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99782. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99783. */
  99784. export class ArcFollowCamera extends TargetCamera {
  99785. /** The longitudinal angle of the camera */
  99786. alpha: number;
  99787. /** The latitudinal angle of the camera */
  99788. beta: number;
  99789. /** The radius of the camera from its target */
  99790. radius: number;
  99791. /** Define the camera target (the messh it should follow) */
  99792. target: Nullable<AbstractMesh>;
  99793. private _cartesianCoordinates;
  99794. /**
  99795. * Instantiates a new ArcFollowCamera
  99796. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99797. * @param name Define the name of the camera
  99798. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  99799. * @param beta Define the rotation angle of the camera around the elevation axis
  99800. * @param radius Define the radius of the camera from its target point
  99801. * @param target Define the target of the camera
  99802. * @param scene Define the scene the camera belongs to
  99803. */
  99804. constructor(name: string,
  99805. /** The longitudinal angle of the camera */
  99806. alpha: number,
  99807. /** The latitudinal angle of the camera */
  99808. beta: number,
  99809. /** The radius of the camera from its target */
  99810. radius: number,
  99811. /** Define the camera target (the messh it should follow) */
  99812. target: Nullable<AbstractMesh>, scene: Scene);
  99813. private _follow;
  99814. /** @hidden */
  99815. _checkInputs(): void;
  99816. /**
  99817. * Returns the class name of the object.
  99818. * It is mostly used internally for serialization purposes.
  99819. */
  99820. getClassName(): string;
  99821. }
  99822. }
  99823. declare module BABYLON {
  99824. /**
  99825. * Manage the keyboard inputs to control the movement of a follow camera.
  99826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99827. */
  99828. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99829. /**
  99830. * Defines the camera the input is attached to.
  99831. */
  99832. camera: FollowCamera;
  99833. /**
  99834. * Defines the list of key codes associated with the up action (increase heightOffset)
  99835. */
  99836. keysHeightOffsetIncr: number[];
  99837. /**
  99838. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99839. */
  99840. keysHeightOffsetDecr: number[];
  99841. /**
  99842. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  99843. */
  99844. keysHeightOffsetModifierAlt: boolean;
  99845. /**
  99846. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  99847. */
  99848. keysHeightOffsetModifierCtrl: boolean;
  99849. /**
  99850. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  99851. */
  99852. keysHeightOffsetModifierShift: boolean;
  99853. /**
  99854. * Defines the list of key codes associated with the left action (increase rotationOffset)
  99855. */
  99856. keysRotationOffsetIncr: number[];
  99857. /**
  99858. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  99859. */
  99860. keysRotationOffsetDecr: number[];
  99861. /**
  99862. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  99863. */
  99864. keysRotationOffsetModifierAlt: boolean;
  99865. /**
  99866. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  99867. */
  99868. keysRotationOffsetModifierCtrl: boolean;
  99869. /**
  99870. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  99871. */
  99872. keysRotationOffsetModifierShift: boolean;
  99873. /**
  99874. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  99875. */
  99876. keysRadiusIncr: number[];
  99877. /**
  99878. * Defines the list of key codes associated with the zoom-out action (increase radius)
  99879. */
  99880. keysRadiusDecr: number[];
  99881. /**
  99882. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  99883. */
  99884. keysRadiusModifierAlt: boolean;
  99885. /**
  99886. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  99887. */
  99888. keysRadiusModifierCtrl: boolean;
  99889. /**
  99890. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  99891. */
  99892. keysRadiusModifierShift: boolean;
  99893. /**
  99894. * Defines the rate of change of heightOffset.
  99895. */
  99896. heightSensibility: number;
  99897. /**
  99898. * Defines the rate of change of rotationOffset.
  99899. */
  99900. rotationSensibility: number;
  99901. /**
  99902. * Defines the rate of change of radius.
  99903. */
  99904. radiusSensibility: number;
  99905. private _keys;
  99906. private _ctrlPressed;
  99907. private _altPressed;
  99908. private _shiftPressed;
  99909. private _onCanvasBlurObserver;
  99910. private _onKeyboardObserver;
  99911. private _engine;
  99912. private _scene;
  99913. /**
  99914. * Attach the input controls to a specific dom element to get the input from.
  99915. * @param element Defines the element the controls should be listened from
  99916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99917. */
  99918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99919. /**
  99920. * Detach the current controls from the specified dom element.
  99921. * @param element Defines the element to stop listening the inputs from
  99922. */
  99923. detachControl(element: Nullable<HTMLElement>): void;
  99924. /**
  99925. * Update the current camera state depending on the inputs that have been used this frame.
  99926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99927. */
  99928. checkInputs(): void;
  99929. /**
  99930. * Gets the class name of the current input.
  99931. * @returns the class name
  99932. */
  99933. getClassName(): string;
  99934. /**
  99935. * Get the friendly name associated with the input class.
  99936. * @returns the input friendly name
  99937. */
  99938. getSimpleName(): string;
  99939. /**
  99940. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99941. * allow modification of the heightOffset value.
  99942. */
  99943. private _modifierHeightOffset;
  99944. /**
  99945. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99946. * allow modification of the rotationOffset value.
  99947. */
  99948. private _modifierRotationOffset;
  99949. /**
  99950. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99951. * allow modification of the radius value.
  99952. */
  99953. private _modifierRadius;
  99954. }
  99955. }
  99956. declare module BABYLON {
  99957. interface FreeCameraInputsManager {
  99958. /**
  99959. * @hidden
  99960. */
  99961. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  99962. /**
  99963. * Add orientation input support to the input manager.
  99964. * @returns the current input manager
  99965. */
  99966. addDeviceOrientation(): FreeCameraInputsManager;
  99967. }
  99968. /**
  99969. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  99970. * Screen rotation is taken into account.
  99971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99972. */
  99973. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  99974. private _camera;
  99975. private _screenOrientationAngle;
  99976. private _constantTranform;
  99977. private _screenQuaternion;
  99978. private _alpha;
  99979. private _beta;
  99980. private _gamma;
  99981. /**
  99982. * Can be used to detect if a device orientation sensor is availible on a device
  99983. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  99984. * @returns a promise that will resolve on orientation change
  99985. */
  99986. static WaitForOrientationChangeAsync(timeout?: number): Promise<{}>;
  99987. /**
  99988. * @hidden
  99989. */
  99990. _onDeviceOrientationChangedObservable: Observable<void>;
  99991. /**
  99992. * Instantiates a new input
  99993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99994. */
  99995. constructor();
  99996. /**
  99997. * Define the camera controlled by the input.
  99998. */
  99999. camera: FreeCamera;
  100000. /**
  100001. * Attach the input controls to a specific dom element to get the input from.
  100002. * @param element Defines the element the controls should be listened from
  100003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100004. */
  100005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100006. private _orientationChanged;
  100007. private _deviceOrientation;
  100008. /**
  100009. * Detach the current controls from the specified dom element.
  100010. * @param element Defines the element to stop listening the inputs from
  100011. */
  100012. detachControl(element: Nullable<HTMLElement>): void;
  100013. /**
  100014. * Update the current camera state depending on the inputs that have been used this frame.
  100015. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100016. */
  100017. checkInputs(): void;
  100018. /**
  100019. * Gets the class name of the current intput.
  100020. * @returns the class name
  100021. */
  100022. getClassName(): string;
  100023. /**
  100024. * Get the friendly name associated with the input class.
  100025. * @returns the input friendly name
  100026. */
  100027. getSimpleName(): string;
  100028. }
  100029. }
  100030. declare module BABYLON {
  100031. /**
  100032. * Manage the gamepad inputs to control a free camera.
  100033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100034. */
  100035. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100036. /**
  100037. * Define the camera the input is attached to.
  100038. */
  100039. camera: FreeCamera;
  100040. /**
  100041. * Define the Gamepad controlling the input
  100042. */
  100043. gamepad: Nullable<Gamepad>;
  100044. /**
  100045. * Defines the gamepad rotation sensiblity.
  100046. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100047. */
  100048. gamepadAngularSensibility: number;
  100049. /**
  100050. * Defines the gamepad move sensiblity.
  100051. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100052. */
  100053. gamepadMoveSensibility: number;
  100054. private _onGamepadConnectedObserver;
  100055. private _onGamepadDisconnectedObserver;
  100056. private _cameraTransform;
  100057. private _deltaTransform;
  100058. private _vector3;
  100059. private _vector2;
  100060. /**
  100061. * Attach the input controls to a specific dom element to get the input from.
  100062. * @param element Defines the element the controls should be listened from
  100063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100064. */
  100065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100066. /**
  100067. * Detach the current controls from the specified dom element.
  100068. * @param element Defines the element to stop listening the inputs from
  100069. */
  100070. detachControl(element: Nullable<HTMLElement>): void;
  100071. /**
  100072. * Update the current camera state depending on the inputs that have been used this frame.
  100073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100074. */
  100075. checkInputs(): void;
  100076. /**
  100077. * Gets the class name of the current intput.
  100078. * @returns the class name
  100079. */
  100080. getClassName(): string;
  100081. /**
  100082. * Get the friendly name associated with the input class.
  100083. * @returns the input friendly name
  100084. */
  100085. getSimpleName(): string;
  100086. }
  100087. }
  100088. declare module BABYLON {
  100089. /**
  100090. * Defines the potential axis of a Joystick
  100091. */
  100092. export enum JoystickAxis {
  100093. /** X axis */
  100094. X = 0,
  100095. /** Y axis */
  100096. Y = 1,
  100097. /** Z axis */
  100098. Z = 2
  100099. }
  100100. /**
  100101. * Class used to define virtual joystick (used in touch mode)
  100102. */
  100103. export class VirtualJoystick {
  100104. /**
  100105. * Gets or sets a boolean indicating that left and right values must be inverted
  100106. */
  100107. reverseLeftRight: boolean;
  100108. /**
  100109. * Gets or sets a boolean indicating that up and down values must be inverted
  100110. */
  100111. reverseUpDown: boolean;
  100112. /**
  100113. * Gets the offset value for the position (ie. the change of the position value)
  100114. */
  100115. deltaPosition: Vector3;
  100116. /**
  100117. * Gets a boolean indicating if the virtual joystick was pressed
  100118. */
  100119. pressed: boolean;
  100120. /**
  100121. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100122. */
  100123. static Canvas: Nullable<HTMLCanvasElement>;
  100124. private static _globalJoystickIndex;
  100125. private static vjCanvasContext;
  100126. private static vjCanvasWidth;
  100127. private static vjCanvasHeight;
  100128. private static halfWidth;
  100129. private _action;
  100130. private _axisTargetedByLeftAndRight;
  100131. private _axisTargetedByUpAndDown;
  100132. private _joystickSensibility;
  100133. private _inversedSensibility;
  100134. private _joystickPointerID;
  100135. private _joystickColor;
  100136. private _joystickPointerPos;
  100137. private _joystickPreviousPointerPos;
  100138. private _joystickPointerStartPos;
  100139. private _deltaJoystickVector;
  100140. private _leftJoystick;
  100141. private _touches;
  100142. private _onPointerDownHandlerRef;
  100143. private _onPointerMoveHandlerRef;
  100144. private _onPointerUpHandlerRef;
  100145. private _onResize;
  100146. /**
  100147. * Creates a new virtual joystick
  100148. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100149. */
  100150. constructor(leftJoystick?: boolean);
  100151. /**
  100152. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100153. * @param newJoystickSensibility defines the new sensibility
  100154. */
  100155. setJoystickSensibility(newJoystickSensibility: number): void;
  100156. private _onPointerDown;
  100157. private _onPointerMove;
  100158. private _onPointerUp;
  100159. /**
  100160. * Change the color of the virtual joystick
  100161. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100162. */
  100163. setJoystickColor(newColor: string): void;
  100164. /**
  100165. * Defines a callback to call when the joystick is touched
  100166. * @param action defines the callback
  100167. */
  100168. setActionOnTouch(action: () => any): void;
  100169. /**
  100170. * Defines which axis you'd like to control for left & right
  100171. * @param axis defines the axis to use
  100172. */
  100173. setAxisForLeftRight(axis: JoystickAxis): void;
  100174. /**
  100175. * Defines which axis you'd like to control for up & down
  100176. * @param axis defines the axis to use
  100177. */
  100178. setAxisForUpDown(axis: JoystickAxis): void;
  100179. private _drawVirtualJoystick;
  100180. /**
  100181. * Release internal HTML canvas
  100182. */
  100183. releaseCanvas(): void;
  100184. }
  100185. }
  100186. declare module BABYLON {
  100187. interface FreeCameraInputsManager {
  100188. /**
  100189. * Add virtual joystick input support to the input manager.
  100190. * @returns the current input manager
  100191. */
  100192. addVirtualJoystick(): FreeCameraInputsManager;
  100193. }
  100194. /**
  100195. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100197. */
  100198. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100199. /**
  100200. * Defines the camera the input is attached to.
  100201. */
  100202. camera: FreeCamera;
  100203. private _leftjoystick;
  100204. private _rightjoystick;
  100205. /**
  100206. * Gets the left stick of the virtual joystick.
  100207. * @returns The virtual Joystick
  100208. */
  100209. getLeftJoystick(): VirtualJoystick;
  100210. /**
  100211. * Gets the right stick of the virtual joystick.
  100212. * @returns The virtual Joystick
  100213. */
  100214. getRightJoystick(): VirtualJoystick;
  100215. /**
  100216. * Update the current camera state depending on the inputs that have been used this frame.
  100217. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100218. */
  100219. checkInputs(): void;
  100220. /**
  100221. * Attach the input controls to a specific dom element to get the input from.
  100222. * @param element Defines the element the controls should be listened from
  100223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100224. */
  100225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100226. /**
  100227. * Detach the current controls from the specified dom element.
  100228. * @param element Defines the element to stop listening the inputs from
  100229. */
  100230. detachControl(element: Nullable<HTMLElement>): void;
  100231. /**
  100232. * Gets the class name of the current intput.
  100233. * @returns the class name
  100234. */
  100235. getClassName(): string;
  100236. /**
  100237. * Get the friendly name associated with the input class.
  100238. * @returns the input friendly name
  100239. */
  100240. getSimpleName(): string;
  100241. }
  100242. }
  100243. declare module BABYLON {
  100244. /**
  100245. * This represents a FPS type of camera controlled by touch.
  100246. * This is like a universal camera minus the Gamepad controls.
  100247. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100248. */
  100249. export class TouchCamera extends FreeCamera {
  100250. /**
  100251. * Defines the touch sensibility for rotation.
  100252. * The higher the faster.
  100253. */
  100254. touchAngularSensibility: number;
  100255. /**
  100256. * Defines the touch sensibility for move.
  100257. * The higher the faster.
  100258. */
  100259. touchMoveSensibility: number;
  100260. /**
  100261. * Instantiates a new touch camera.
  100262. * This represents a FPS type of camera controlled by touch.
  100263. * This is like a universal camera minus the Gamepad controls.
  100264. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100265. * @param name Define the name of the camera in the scene
  100266. * @param position Define the start position of the camera in the scene
  100267. * @param scene Define the scene the camera belongs to
  100268. */
  100269. constructor(name: string, position: Vector3, scene: Scene);
  100270. /**
  100271. * Gets the current object class name.
  100272. * @return the class name
  100273. */
  100274. getClassName(): string;
  100275. /** @hidden */
  100276. _setupInputs(): void;
  100277. }
  100278. }
  100279. declare module BABYLON {
  100280. /**
  100281. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100282. * being tilted forward or back and left or right.
  100283. */
  100284. export class DeviceOrientationCamera extends FreeCamera {
  100285. private _initialQuaternion;
  100286. private _quaternionCache;
  100287. private _tmpDragQuaternion;
  100288. /**
  100289. * Creates a new device orientation camera
  100290. * @param name The name of the camera
  100291. * @param position The start position camera
  100292. * @param scene The scene the camera belongs to
  100293. */
  100294. constructor(name: string, position: Vector3, scene: Scene);
  100295. /**
  100296. * @hidden
  100297. * Disabled pointer input on first orientation sensor update (Default: true)
  100298. */
  100299. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100300. private _dragFactor;
  100301. /**
  100302. * Enabled turning on the y axis when the orientation sensor is active
  100303. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100304. */
  100305. enableHorizontalDragging(dragFactor?: number): void;
  100306. /**
  100307. * Gets the current instance class name ("DeviceOrientationCamera").
  100308. * This helps avoiding instanceof at run time.
  100309. * @returns the class name
  100310. */
  100311. getClassName(): string;
  100312. /**
  100313. * @hidden
  100314. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100315. */
  100316. _checkInputs(): void;
  100317. /**
  100318. * Reset the camera to its default orientation on the specified axis only.
  100319. * @param axis The axis to reset
  100320. */
  100321. resetToCurrentRotation(axis?: Axis): void;
  100322. }
  100323. }
  100324. declare module BABYLON {
  100325. /**
  100326. * Defines supported buttons for XBox360 compatible gamepads
  100327. */
  100328. export enum Xbox360Button {
  100329. /** A */
  100330. A = 0,
  100331. /** B */
  100332. B = 1,
  100333. /** X */
  100334. X = 2,
  100335. /** Y */
  100336. Y = 3,
  100337. /** Start */
  100338. Start = 4,
  100339. /** Back */
  100340. Back = 5,
  100341. /** Left button */
  100342. LB = 6,
  100343. /** Right button */
  100344. RB = 7,
  100345. /** Left stick */
  100346. LeftStick = 8,
  100347. /** Right stick */
  100348. RightStick = 9
  100349. }
  100350. /** Defines values for XBox360 DPad */
  100351. export enum Xbox360Dpad {
  100352. /** Up */
  100353. Up = 0,
  100354. /** Down */
  100355. Down = 1,
  100356. /** Left */
  100357. Left = 2,
  100358. /** Right */
  100359. Right = 3
  100360. }
  100361. /**
  100362. * Defines a XBox360 gamepad
  100363. */
  100364. export class Xbox360Pad extends Gamepad {
  100365. private _leftTrigger;
  100366. private _rightTrigger;
  100367. private _onlefttriggerchanged;
  100368. private _onrighttriggerchanged;
  100369. private _onbuttondown;
  100370. private _onbuttonup;
  100371. private _ondpaddown;
  100372. private _ondpadup;
  100373. /** Observable raised when a button is pressed */
  100374. onButtonDownObservable: Observable<Xbox360Button>;
  100375. /** Observable raised when a button is released */
  100376. onButtonUpObservable: Observable<Xbox360Button>;
  100377. /** Observable raised when a pad is pressed */
  100378. onPadDownObservable: Observable<Xbox360Dpad>;
  100379. /** Observable raised when a pad is released */
  100380. onPadUpObservable: Observable<Xbox360Dpad>;
  100381. private _buttonA;
  100382. private _buttonB;
  100383. private _buttonX;
  100384. private _buttonY;
  100385. private _buttonBack;
  100386. private _buttonStart;
  100387. private _buttonLB;
  100388. private _buttonRB;
  100389. private _buttonLeftStick;
  100390. private _buttonRightStick;
  100391. private _dPadUp;
  100392. private _dPadDown;
  100393. private _dPadLeft;
  100394. private _dPadRight;
  100395. private _isXboxOnePad;
  100396. /**
  100397. * Creates a new XBox360 gamepad object
  100398. * @param id defines the id of this gamepad
  100399. * @param index defines its index
  100400. * @param gamepad defines the internal HTML gamepad object
  100401. * @param xboxOne defines if it is a XBox One gamepad
  100402. */
  100403. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100404. /**
  100405. * Defines the callback to call when left trigger is pressed
  100406. * @param callback defines the callback to use
  100407. */
  100408. onlefttriggerchanged(callback: (value: number) => void): void;
  100409. /**
  100410. * Defines the callback to call when right trigger is pressed
  100411. * @param callback defines the callback to use
  100412. */
  100413. onrighttriggerchanged(callback: (value: number) => void): void;
  100414. /**
  100415. * Gets the left trigger value
  100416. */
  100417. /**
  100418. * Sets the left trigger value
  100419. */
  100420. leftTrigger: number;
  100421. /**
  100422. * Gets the right trigger value
  100423. */
  100424. /**
  100425. * Sets the right trigger value
  100426. */
  100427. rightTrigger: number;
  100428. /**
  100429. * Defines the callback to call when a button is pressed
  100430. * @param callback defines the callback to use
  100431. */
  100432. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100433. /**
  100434. * Defines the callback to call when a button is released
  100435. * @param callback defines the callback to use
  100436. */
  100437. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100438. /**
  100439. * Defines the callback to call when a pad is pressed
  100440. * @param callback defines the callback to use
  100441. */
  100442. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100443. /**
  100444. * Defines the callback to call when a pad is released
  100445. * @param callback defines the callback to use
  100446. */
  100447. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100448. private _setButtonValue;
  100449. private _setDPadValue;
  100450. /**
  100451. * Gets the value of the `A` button
  100452. */
  100453. /**
  100454. * Sets the value of the `A` button
  100455. */
  100456. buttonA: number;
  100457. /**
  100458. * Gets the value of the `B` button
  100459. */
  100460. /**
  100461. * Sets the value of the `B` button
  100462. */
  100463. buttonB: number;
  100464. /**
  100465. * Gets the value of the `X` button
  100466. */
  100467. /**
  100468. * Sets the value of the `X` button
  100469. */
  100470. buttonX: number;
  100471. /**
  100472. * Gets the value of the `Y` button
  100473. */
  100474. /**
  100475. * Sets the value of the `Y` button
  100476. */
  100477. buttonY: number;
  100478. /**
  100479. * Gets the value of the `Start` button
  100480. */
  100481. /**
  100482. * Sets the value of the `Start` button
  100483. */
  100484. buttonStart: number;
  100485. /**
  100486. * Gets the value of the `Back` button
  100487. */
  100488. /**
  100489. * Sets the value of the `Back` button
  100490. */
  100491. buttonBack: number;
  100492. /**
  100493. * Gets the value of the `Left` button
  100494. */
  100495. /**
  100496. * Sets the value of the `Left` button
  100497. */
  100498. buttonLB: number;
  100499. /**
  100500. * Gets the value of the `Right` button
  100501. */
  100502. /**
  100503. * Sets the value of the `Right` button
  100504. */
  100505. buttonRB: number;
  100506. /**
  100507. * Gets the value of the Left joystick
  100508. */
  100509. /**
  100510. * Sets the value of the Left joystick
  100511. */
  100512. buttonLeftStick: number;
  100513. /**
  100514. * Gets the value of the Right joystick
  100515. */
  100516. /**
  100517. * Sets the value of the Right joystick
  100518. */
  100519. buttonRightStick: number;
  100520. /**
  100521. * Gets the value of D-pad up
  100522. */
  100523. /**
  100524. * Sets the value of D-pad up
  100525. */
  100526. dPadUp: number;
  100527. /**
  100528. * Gets the value of D-pad down
  100529. */
  100530. /**
  100531. * Sets the value of D-pad down
  100532. */
  100533. dPadDown: number;
  100534. /**
  100535. * Gets the value of D-pad left
  100536. */
  100537. /**
  100538. * Sets the value of D-pad left
  100539. */
  100540. dPadLeft: number;
  100541. /**
  100542. * Gets the value of D-pad right
  100543. */
  100544. /**
  100545. * Sets the value of D-pad right
  100546. */
  100547. dPadRight: number;
  100548. /**
  100549. * Force the gamepad to synchronize with device values
  100550. */
  100551. update(): void;
  100552. /**
  100553. * Disposes the gamepad
  100554. */
  100555. dispose(): void;
  100556. }
  100557. }
  100558. declare module BABYLON {
  100559. /**
  100560. * Manager for handling gamepads
  100561. */
  100562. export class GamepadManager {
  100563. private _scene?;
  100564. private _babylonGamepads;
  100565. private _oneGamepadConnected;
  100566. /** @hidden */
  100567. _isMonitoring: boolean;
  100568. private _gamepadEventSupported;
  100569. private _gamepadSupport;
  100570. /**
  100571. * observable to be triggered when the gamepad controller has been connected
  100572. */
  100573. onGamepadConnectedObservable: Observable<Gamepad>;
  100574. /**
  100575. * observable to be triggered when the gamepad controller has been disconnected
  100576. */
  100577. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100578. private _onGamepadConnectedEvent;
  100579. private _onGamepadDisconnectedEvent;
  100580. /**
  100581. * Initializes the gamepad manager
  100582. * @param _scene BabylonJS scene
  100583. */
  100584. constructor(_scene?: Scene | undefined);
  100585. /**
  100586. * The gamepads in the game pad manager
  100587. */
  100588. readonly gamepads: Gamepad[];
  100589. /**
  100590. * Get the gamepad controllers based on type
  100591. * @param type The type of gamepad controller
  100592. * @returns Nullable gamepad
  100593. */
  100594. getGamepadByType(type?: number): Nullable<Gamepad>;
  100595. /**
  100596. * Disposes the gamepad manager
  100597. */
  100598. dispose(): void;
  100599. private _addNewGamepad;
  100600. private _startMonitoringGamepads;
  100601. private _stopMonitoringGamepads;
  100602. /** @hidden */
  100603. _checkGamepadsStatus(): void;
  100604. private _updateGamepadObjects;
  100605. }
  100606. }
  100607. declare module BABYLON {
  100608. interface Scene {
  100609. /** @hidden */
  100610. _gamepadManager: Nullable<GamepadManager>;
  100611. /**
  100612. * Gets the gamepad manager associated with the scene
  100613. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100614. */
  100615. gamepadManager: GamepadManager;
  100616. }
  100617. /**
  100618. * Interface representing a free camera inputs manager
  100619. */
  100620. interface FreeCameraInputsManager {
  100621. /**
  100622. * Adds gamepad input support to the FreeCameraInputsManager.
  100623. * @returns the FreeCameraInputsManager
  100624. */
  100625. addGamepad(): FreeCameraInputsManager;
  100626. }
  100627. /**
  100628. * Interface representing an arc rotate camera inputs manager
  100629. */
  100630. interface ArcRotateCameraInputsManager {
  100631. /**
  100632. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100633. * @returns the camera inputs manager
  100634. */
  100635. addGamepad(): ArcRotateCameraInputsManager;
  100636. }
  100637. /**
  100638. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100639. */
  100640. export class GamepadSystemSceneComponent implements ISceneComponent {
  100641. /**
  100642. * The component name helpfull to identify the component in the list of scene components.
  100643. */
  100644. readonly name: string;
  100645. /**
  100646. * The scene the component belongs to.
  100647. */
  100648. scene: Scene;
  100649. /**
  100650. * Creates a new instance of the component for the given scene
  100651. * @param scene Defines the scene to register the component in
  100652. */
  100653. constructor(scene: Scene);
  100654. /**
  100655. * Registers the component in a given scene
  100656. */
  100657. register(): void;
  100658. /**
  100659. * Rebuilds the elements related to this component in case of
  100660. * context lost for instance.
  100661. */
  100662. rebuild(): void;
  100663. /**
  100664. * Disposes the component and the associated ressources
  100665. */
  100666. dispose(): void;
  100667. private _beforeCameraUpdate;
  100668. }
  100669. }
  100670. declare module BABYLON {
  100671. /**
  100672. * 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,
  100673. * which still works and will still be found in many Playgrounds.
  100674. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100675. */
  100676. export class UniversalCamera extends TouchCamera {
  100677. /**
  100678. * Defines the gamepad rotation sensiblity.
  100679. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100680. */
  100681. gamepadAngularSensibility: number;
  100682. /**
  100683. * Defines the gamepad move sensiblity.
  100684. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100685. */
  100686. gamepadMoveSensibility: number;
  100687. /**
  100688. * 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,
  100689. * which still works and will still be found in many Playgrounds.
  100690. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100691. * @param name Define the name of the camera in the scene
  100692. * @param position Define the start position of the camera in the scene
  100693. * @param scene Define the scene the camera belongs to
  100694. */
  100695. constructor(name: string, position: Vector3, scene: Scene);
  100696. /**
  100697. * Gets the current object class name.
  100698. * @return the class name
  100699. */
  100700. getClassName(): string;
  100701. }
  100702. }
  100703. declare module BABYLON {
  100704. /**
  100705. * This represents a FPS type of camera. This is only here for back compat purpose.
  100706. * Please use the UniversalCamera instead as both are identical.
  100707. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100708. */
  100709. export class GamepadCamera extends UniversalCamera {
  100710. /**
  100711. * Instantiates a new Gamepad Camera
  100712. * This represents a FPS type of camera. This is only here for back compat purpose.
  100713. * Please use the UniversalCamera instead as both are identical.
  100714. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100715. * @param name Define the name of the camera in the scene
  100716. * @param position Define the start position of the camera in the scene
  100717. * @param scene Define the scene the camera belongs to
  100718. */
  100719. constructor(name: string, position: Vector3, scene: Scene);
  100720. /**
  100721. * Gets the current object class name.
  100722. * @return the class name
  100723. */
  100724. getClassName(): string;
  100725. }
  100726. }
  100727. declare module BABYLON {
  100728. /** @hidden */
  100729. export var passPixelShader: {
  100730. name: string;
  100731. shader: string;
  100732. };
  100733. }
  100734. declare module BABYLON {
  100735. /** @hidden */
  100736. export var passCubePixelShader: {
  100737. name: string;
  100738. shader: string;
  100739. };
  100740. }
  100741. declare module BABYLON {
  100742. /**
  100743. * PassPostProcess which produces an output the same as it's input
  100744. */
  100745. export class PassPostProcess extends PostProcess {
  100746. /**
  100747. * Creates the PassPostProcess
  100748. * @param name The name of the effect.
  100749. * @param options The required width/height ratio to downsize to before computing the render pass.
  100750. * @param camera The camera to apply the render pass to.
  100751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100752. * @param engine The engine which the post process will be applied. (default: current engine)
  100753. * @param reusable If the post process can be reused on the same frame. (default: false)
  100754. * @param textureType The type of texture to be used when performing the post processing.
  100755. * @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)
  100756. */
  100757. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100758. }
  100759. /**
  100760. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100761. */
  100762. export class PassCubePostProcess extends PostProcess {
  100763. private _face;
  100764. /**
  100765. * Gets or sets the cube face to display.
  100766. * * 0 is +X
  100767. * * 1 is -X
  100768. * * 2 is +Y
  100769. * * 3 is -Y
  100770. * * 4 is +Z
  100771. * * 5 is -Z
  100772. */
  100773. face: number;
  100774. /**
  100775. * Creates the PassCubePostProcess
  100776. * @param name The name of the effect.
  100777. * @param options The required width/height ratio to downsize to before computing the render pass.
  100778. * @param camera The camera to apply the render pass to.
  100779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100780. * @param engine The engine which the post process will be applied. (default: current engine)
  100781. * @param reusable If the post process can be reused on the same frame. (default: false)
  100782. * @param textureType The type of texture to be used when performing the post processing.
  100783. * @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)
  100784. */
  100785. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100786. }
  100787. }
  100788. declare module BABYLON {
  100789. /** @hidden */
  100790. export var anaglyphPixelShader: {
  100791. name: string;
  100792. shader: string;
  100793. };
  100794. }
  100795. declare module BABYLON {
  100796. /**
  100797. * Postprocess used to generate anaglyphic rendering
  100798. */
  100799. export class AnaglyphPostProcess extends PostProcess {
  100800. private _passedProcess;
  100801. /**
  100802. * Creates a new AnaglyphPostProcess
  100803. * @param name defines postprocess name
  100804. * @param options defines creation options or target ratio scale
  100805. * @param rigCameras defines cameras using this postprocess
  100806. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  100807. * @param engine defines hosting engine
  100808. * @param reusable defines if the postprocess will be reused multiple times per frame
  100809. */
  100810. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  100811. }
  100812. }
  100813. declare module BABYLON {
  100814. /**
  100815. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100816. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100817. */
  100818. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100819. /**
  100820. * Creates a new AnaglyphArcRotateCamera
  100821. * @param name defines camera name
  100822. * @param alpha defines alpha angle (in radians)
  100823. * @param beta defines beta angle (in radians)
  100824. * @param radius defines radius
  100825. * @param target defines camera target
  100826. * @param interaxialDistance defines distance between each color axis
  100827. * @param scene defines the hosting scene
  100828. */
  100829. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100830. /**
  100831. * Gets camera class name
  100832. * @returns AnaglyphArcRotateCamera
  100833. */
  100834. getClassName(): string;
  100835. }
  100836. }
  100837. declare module BABYLON {
  100838. /**
  100839. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  100840. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100841. */
  100842. export class AnaglyphFreeCamera extends FreeCamera {
  100843. /**
  100844. * Creates a new AnaglyphFreeCamera
  100845. * @param name defines camera name
  100846. * @param position defines initial position
  100847. * @param interaxialDistance defines distance between each color axis
  100848. * @param scene defines the hosting scene
  100849. */
  100850. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100851. /**
  100852. * Gets camera class name
  100853. * @returns AnaglyphFreeCamera
  100854. */
  100855. getClassName(): string;
  100856. }
  100857. }
  100858. declare module BABYLON {
  100859. /**
  100860. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  100861. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100862. */
  100863. export class AnaglyphGamepadCamera extends GamepadCamera {
  100864. /**
  100865. * Creates a new AnaglyphGamepadCamera
  100866. * @param name defines camera name
  100867. * @param position defines initial position
  100868. * @param interaxialDistance defines distance between each color axis
  100869. * @param scene defines the hosting scene
  100870. */
  100871. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100872. /**
  100873. * Gets camera class name
  100874. * @returns AnaglyphGamepadCamera
  100875. */
  100876. getClassName(): string;
  100877. }
  100878. }
  100879. declare module BABYLON {
  100880. /**
  100881. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  100882. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100883. */
  100884. export class AnaglyphUniversalCamera extends UniversalCamera {
  100885. /**
  100886. * Creates a new AnaglyphUniversalCamera
  100887. * @param name defines camera name
  100888. * @param position defines initial position
  100889. * @param interaxialDistance defines distance between each color axis
  100890. * @param scene defines the hosting scene
  100891. */
  100892. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100893. /**
  100894. * Gets camera class name
  100895. * @returns AnaglyphUniversalCamera
  100896. */
  100897. getClassName(): string;
  100898. }
  100899. }
  100900. declare module BABYLON {
  100901. /** @hidden */
  100902. export var stereoscopicInterlacePixelShader: {
  100903. name: string;
  100904. shader: string;
  100905. };
  100906. }
  100907. declare module BABYLON {
  100908. /**
  100909. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  100910. */
  100911. export class StereoscopicInterlacePostProcess extends PostProcess {
  100912. private _stepSize;
  100913. private _passedProcess;
  100914. /**
  100915. * Initializes a StereoscopicInterlacePostProcess
  100916. * @param name The name of the effect.
  100917. * @param rigCameras The rig cameras to be appled to the post process
  100918. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  100919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100920. * @param engine The engine which the post process will be applied. (default: current engine)
  100921. * @param reusable If the post process can be reused on the same frame. (default: false)
  100922. */
  100923. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  100924. }
  100925. }
  100926. declare module BABYLON {
  100927. /**
  100928. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  100929. * @see http://doc.babylonjs.com/features/cameras
  100930. */
  100931. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  100932. /**
  100933. * Creates a new StereoscopicArcRotateCamera
  100934. * @param name defines camera name
  100935. * @param alpha defines alpha angle (in radians)
  100936. * @param beta defines beta angle (in radians)
  100937. * @param radius defines radius
  100938. * @param target defines camera target
  100939. * @param interaxialDistance defines distance between each color axis
  100940. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100941. * @param scene defines the hosting scene
  100942. */
  100943. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100944. /**
  100945. * Gets camera class name
  100946. * @returns StereoscopicArcRotateCamera
  100947. */
  100948. getClassName(): string;
  100949. }
  100950. }
  100951. declare module BABYLON {
  100952. /**
  100953. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  100954. * @see http://doc.babylonjs.com/features/cameras
  100955. */
  100956. export class StereoscopicFreeCamera extends FreeCamera {
  100957. /**
  100958. * Creates a new StereoscopicFreeCamera
  100959. * @param name defines camera name
  100960. * @param position defines initial position
  100961. * @param interaxialDistance defines distance between each color axis
  100962. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100963. * @param scene defines the hosting scene
  100964. */
  100965. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100966. /**
  100967. * Gets camera class name
  100968. * @returns StereoscopicFreeCamera
  100969. */
  100970. getClassName(): string;
  100971. }
  100972. }
  100973. declare module BABYLON {
  100974. /**
  100975. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  100976. * @see http://doc.babylonjs.com/features/cameras
  100977. */
  100978. export class StereoscopicGamepadCamera extends GamepadCamera {
  100979. /**
  100980. * Creates a new StereoscopicGamepadCamera
  100981. * @param name defines camera name
  100982. * @param position defines initial position
  100983. * @param interaxialDistance defines distance between each color axis
  100984. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100985. * @param scene defines the hosting scene
  100986. */
  100987. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100988. /**
  100989. * Gets camera class name
  100990. * @returns StereoscopicGamepadCamera
  100991. */
  100992. getClassName(): string;
  100993. }
  100994. }
  100995. declare module BABYLON {
  100996. /**
  100997. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  100998. * @see http://doc.babylonjs.com/features/cameras
  100999. */
  101000. export class StereoscopicUniversalCamera extends UniversalCamera {
  101001. /**
  101002. * Creates a new StereoscopicUniversalCamera
  101003. * @param name defines camera name
  101004. * @param position defines initial position
  101005. * @param interaxialDistance defines distance between each color axis
  101006. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101007. * @param scene defines the hosting scene
  101008. */
  101009. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101010. /**
  101011. * Gets camera class name
  101012. * @returns StereoscopicUniversalCamera
  101013. */
  101014. getClassName(): string;
  101015. }
  101016. }
  101017. declare module BABYLON {
  101018. /**
  101019. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101020. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101021. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101022. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101023. */
  101024. export class VirtualJoysticksCamera extends FreeCamera {
  101025. /**
  101026. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101027. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101028. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101029. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101030. * @param name Define the name of the camera in the scene
  101031. * @param position Define the start position of the camera in the scene
  101032. * @param scene Define the scene the camera belongs to
  101033. */
  101034. constructor(name: string, position: Vector3, scene: Scene);
  101035. /**
  101036. * Gets the current object class name.
  101037. * @return the class name
  101038. */
  101039. getClassName(): string;
  101040. }
  101041. }
  101042. declare module BABYLON {
  101043. /**
  101044. * This represents all the required metrics to create a VR camera.
  101045. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101046. */
  101047. export class VRCameraMetrics {
  101048. /**
  101049. * Define the horizontal resolution off the screen.
  101050. */
  101051. hResolution: number;
  101052. /**
  101053. * Define the vertical resolution off the screen.
  101054. */
  101055. vResolution: number;
  101056. /**
  101057. * Define the horizontal screen size.
  101058. */
  101059. hScreenSize: number;
  101060. /**
  101061. * Define the vertical screen size.
  101062. */
  101063. vScreenSize: number;
  101064. /**
  101065. * Define the vertical screen center position.
  101066. */
  101067. vScreenCenter: number;
  101068. /**
  101069. * Define the distance of the eyes to the screen.
  101070. */
  101071. eyeToScreenDistance: number;
  101072. /**
  101073. * Define the distance between both lenses
  101074. */
  101075. lensSeparationDistance: number;
  101076. /**
  101077. * Define the distance between both viewer's eyes.
  101078. */
  101079. interpupillaryDistance: number;
  101080. /**
  101081. * Define the distortion factor of the VR postprocess.
  101082. * Please, touch with care.
  101083. */
  101084. distortionK: number[];
  101085. /**
  101086. * Define the chromatic aberration correction factors for the VR post process.
  101087. */
  101088. chromaAbCorrection: number[];
  101089. /**
  101090. * Define the scale factor of the post process.
  101091. * The smaller the better but the slower.
  101092. */
  101093. postProcessScaleFactor: number;
  101094. /**
  101095. * Define an offset for the lens center.
  101096. */
  101097. lensCenterOffset: number;
  101098. /**
  101099. * Define if the current vr camera should compensate the distortion of the lense or not.
  101100. */
  101101. compensateDistortion: boolean;
  101102. /**
  101103. * Defines if multiview should be enabled when rendering (Default: false)
  101104. */
  101105. multiviewEnabled: boolean;
  101106. /**
  101107. * Gets the rendering aspect ratio based on the provided resolutions.
  101108. */
  101109. readonly aspectRatio: number;
  101110. /**
  101111. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101112. */
  101113. readonly aspectRatioFov: number;
  101114. /**
  101115. * @hidden
  101116. */
  101117. readonly leftHMatrix: Matrix;
  101118. /**
  101119. * @hidden
  101120. */
  101121. readonly rightHMatrix: Matrix;
  101122. /**
  101123. * @hidden
  101124. */
  101125. readonly leftPreViewMatrix: Matrix;
  101126. /**
  101127. * @hidden
  101128. */
  101129. readonly rightPreViewMatrix: Matrix;
  101130. /**
  101131. * Get the default VRMetrics based on the most generic setup.
  101132. * @returns the default vr metrics
  101133. */
  101134. static GetDefault(): VRCameraMetrics;
  101135. }
  101136. }
  101137. declare module BABYLON {
  101138. /** @hidden */
  101139. export var vrDistortionCorrectionPixelShader: {
  101140. name: string;
  101141. shader: string;
  101142. };
  101143. }
  101144. declare module BABYLON {
  101145. /**
  101146. * VRDistortionCorrectionPostProcess used for mobile VR
  101147. */
  101148. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101149. private _isRightEye;
  101150. private _distortionFactors;
  101151. private _postProcessScaleFactor;
  101152. private _lensCenterOffset;
  101153. private _scaleIn;
  101154. private _scaleFactor;
  101155. private _lensCenter;
  101156. /**
  101157. * Initializes the VRDistortionCorrectionPostProcess
  101158. * @param name The name of the effect.
  101159. * @param camera The camera to apply the render pass to.
  101160. * @param isRightEye If this is for the right eye distortion
  101161. * @param vrMetrics All the required metrics for the VR camera
  101162. */
  101163. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101164. }
  101165. }
  101166. declare module BABYLON {
  101167. /**
  101168. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101169. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101170. */
  101171. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101172. /**
  101173. * Creates a new VRDeviceOrientationArcRotateCamera
  101174. * @param name defines camera name
  101175. * @param alpha defines the camera rotation along the logitudinal axis
  101176. * @param beta defines the camera rotation along the latitudinal axis
  101177. * @param radius defines the camera distance from its target
  101178. * @param target defines the camera target
  101179. * @param scene defines the scene the camera belongs to
  101180. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101181. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101182. */
  101183. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101184. /**
  101185. * Gets camera class name
  101186. * @returns VRDeviceOrientationArcRotateCamera
  101187. */
  101188. getClassName(): string;
  101189. }
  101190. }
  101191. declare module BABYLON {
  101192. /**
  101193. * Camera used to simulate VR rendering (based on FreeCamera)
  101194. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101195. */
  101196. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101197. /**
  101198. * Creates a new VRDeviceOrientationFreeCamera
  101199. * @param name defines camera name
  101200. * @param position defines the start position of the camera
  101201. * @param scene defines the scene the camera belongs to
  101202. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101203. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101204. */
  101205. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101206. /**
  101207. * Gets camera class name
  101208. * @returns VRDeviceOrientationFreeCamera
  101209. */
  101210. getClassName(): string;
  101211. }
  101212. }
  101213. declare module BABYLON {
  101214. /**
  101215. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101216. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101217. */
  101218. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101219. /**
  101220. * Creates a new VRDeviceOrientationGamepadCamera
  101221. * @param name defines camera name
  101222. * @param position defines the start position of the camera
  101223. * @param scene defines the scene the camera belongs to
  101224. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101225. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101226. */
  101227. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101228. /**
  101229. * Gets camera class name
  101230. * @returns VRDeviceOrientationGamepadCamera
  101231. */
  101232. getClassName(): string;
  101233. }
  101234. }
  101235. declare module BABYLON {
  101236. /**
  101237. * Base class of materials working in push mode in babylon JS
  101238. * @hidden
  101239. */
  101240. export class PushMaterial extends Material {
  101241. protected _activeEffect: Effect;
  101242. protected _normalMatrix: Matrix;
  101243. /**
  101244. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101245. * This means that the material can keep using a previous shader while a new one is being compiled.
  101246. * This is mostly used when shader parallel compilation is supported (true by default)
  101247. */
  101248. allowShaderHotSwapping: boolean;
  101249. constructor(name: string, scene: Scene);
  101250. getEffect(): Effect;
  101251. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101252. /**
  101253. * Binds the given world matrix to the active effect
  101254. *
  101255. * @param world the matrix to bind
  101256. */
  101257. bindOnlyWorldMatrix(world: Matrix): void;
  101258. /**
  101259. * Binds the given normal matrix to the active effect
  101260. *
  101261. * @param normalMatrix the matrix to bind
  101262. */
  101263. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101264. bind(world: Matrix, mesh?: Mesh): void;
  101265. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101266. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101267. }
  101268. }
  101269. declare module BABYLON {
  101270. /**
  101271. * This groups all the flags used to control the materials channel.
  101272. */
  101273. export class MaterialFlags {
  101274. private static _DiffuseTextureEnabled;
  101275. /**
  101276. * Are diffuse textures enabled in the application.
  101277. */
  101278. static DiffuseTextureEnabled: boolean;
  101279. private static _AmbientTextureEnabled;
  101280. /**
  101281. * Are ambient textures enabled in the application.
  101282. */
  101283. static AmbientTextureEnabled: boolean;
  101284. private static _OpacityTextureEnabled;
  101285. /**
  101286. * Are opacity textures enabled in the application.
  101287. */
  101288. static OpacityTextureEnabled: boolean;
  101289. private static _ReflectionTextureEnabled;
  101290. /**
  101291. * Are reflection textures enabled in the application.
  101292. */
  101293. static ReflectionTextureEnabled: boolean;
  101294. private static _EmissiveTextureEnabled;
  101295. /**
  101296. * Are emissive textures enabled in the application.
  101297. */
  101298. static EmissiveTextureEnabled: boolean;
  101299. private static _SpecularTextureEnabled;
  101300. /**
  101301. * Are specular textures enabled in the application.
  101302. */
  101303. static SpecularTextureEnabled: boolean;
  101304. private static _BumpTextureEnabled;
  101305. /**
  101306. * Are bump textures enabled in the application.
  101307. */
  101308. static BumpTextureEnabled: boolean;
  101309. private static _LightmapTextureEnabled;
  101310. /**
  101311. * Are lightmap textures enabled in the application.
  101312. */
  101313. static LightmapTextureEnabled: boolean;
  101314. private static _RefractionTextureEnabled;
  101315. /**
  101316. * Are refraction textures enabled in the application.
  101317. */
  101318. static RefractionTextureEnabled: boolean;
  101319. private static _ColorGradingTextureEnabled;
  101320. /**
  101321. * Are color grading textures enabled in the application.
  101322. */
  101323. static ColorGradingTextureEnabled: boolean;
  101324. private static _FresnelEnabled;
  101325. /**
  101326. * Are fresnels enabled in the application.
  101327. */
  101328. static FresnelEnabled: boolean;
  101329. private static _ClearCoatTextureEnabled;
  101330. /**
  101331. * Are clear coat textures enabled in the application.
  101332. */
  101333. static ClearCoatTextureEnabled: boolean;
  101334. private static _ClearCoatBumpTextureEnabled;
  101335. /**
  101336. * Are clear coat bump textures enabled in the application.
  101337. */
  101338. static ClearCoatBumpTextureEnabled: boolean;
  101339. private static _ClearCoatTintTextureEnabled;
  101340. /**
  101341. * Are clear coat tint textures enabled in the application.
  101342. */
  101343. static ClearCoatTintTextureEnabled: boolean;
  101344. private static _SheenTextureEnabled;
  101345. /**
  101346. * Are sheen textures enabled in the application.
  101347. */
  101348. static SheenTextureEnabled: boolean;
  101349. private static _AnisotropicTextureEnabled;
  101350. /**
  101351. * Are anisotropic textures enabled in the application.
  101352. */
  101353. static AnisotropicTextureEnabled: boolean;
  101354. private static _ThicknessTextureEnabled;
  101355. /**
  101356. * Are thickness textures enabled in the application.
  101357. */
  101358. static ThicknessTextureEnabled: boolean;
  101359. }
  101360. }
  101361. declare module BABYLON {
  101362. /** @hidden */
  101363. export var defaultFragmentDeclaration: {
  101364. name: string;
  101365. shader: string;
  101366. };
  101367. }
  101368. declare module BABYLON {
  101369. /** @hidden */
  101370. export var defaultUboDeclaration: {
  101371. name: string;
  101372. shader: string;
  101373. };
  101374. }
  101375. declare module BABYLON {
  101376. /** @hidden */
  101377. export var lightFragmentDeclaration: {
  101378. name: string;
  101379. shader: string;
  101380. };
  101381. }
  101382. declare module BABYLON {
  101383. /** @hidden */
  101384. export var lightUboDeclaration: {
  101385. name: string;
  101386. shader: string;
  101387. };
  101388. }
  101389. declare module BABYLON {
  101390. /** @hidden */
  101391. export var lightsFragmentFunctions: {
  101392. name: string;
  101393. shader: string;
  101394. };
  101395. }
  101396. declare module BABYLON {
  101397. /** @hidden */
  101398. export var shadowsFragmentFunctions: {
  101399. name: string;
  101400. shader: string;
  101401. };
  101402. }
  101403. declare module BABYLON {
  101404. /** @hidden */
  101405. export var fresnelFunction: {
  101406. name: string;
  101407. shader: string;
  101408. };
  101409. }
  101410. declare module BABYLON {
  101411. /** @hidden */
  101412. export var reflectionFunction: {
  101413. name: string;
  101414. shader: string;
  101415. };
  101416. }
  101417. declare module BABYLON {
  101418. /** @hidden */
  101419. export var bumpFragmentFunctions: {
  101420. name: string;
  101421. shader: string;
  101422. };
  101423. }
  101424. declare module BABYLON {
  101425. /** @hidden */
  101426. export var logDepthDeclaration: {
  101427. name: string;
  101428. shader: string;
  101429. };
  101430. }
  101431. declare module BABYLON {
  101432. /** @hidden */
  101433. export var bumpFragment: {
  101434. name: string;
  101435. shader: string;
  101436. };
  101437. }
  101438. declare module BABYLON {
  101439. /** @hidden */
  101440. export var depthPrePass: {
  101441. name: string;
  101442. shader: string;
  101443. };
  101444. }
  101445. declare module BABYLON {
  101446. /** @hidden */
  101447. export var lightFragment: {
  101448. name: string;
  101449. shader: string;
  101450. };
  101451. }
  101452. declare module BABYLON {
  101453. /** @hidden */
  101454. export var logDepthFragment: {
  101455. name: string;
  101456. shader: string;
  101457. };
  101458. }
  101459. declare module BABYLON {
  101460. /** @hidden */
  101461. export var defaultPixelShader: {
  101462. name: string;
  101463. shader: string;
  101464. };
  101465. }
  101466. declare module BABYLON {
  101467. /** @hidden */
  101468. export var defaultVertexDeclaration: {
  101469. name: string;
  101470. shader: string;
  101471. };
  101472. }
  101473. declare module BABYLON {
  101474. /** @hidden */
  101475. export var bumpVertexDeclaration: {
  101476. name: string;
  101477. shader: string;
  101478. };
  101479. }
  101480. declare module BABYLON {
  101481. /** @hidden */
  101482. export var bumpVertex: {
  101483. name: string;
  101484. shader: string;
  101485. };
  101486. }
  101487. declare module BABYLON {
  101488. /** @hidden */
  101489. export var fogVertex: {
  101490. name: string;
  101491. shader: string;
  101492. };
  101493. }
  101494. declare module BABYLON {
  101495. /** @hidden */
  101496. export var shadowsVertex: {
  101497. name: string;
  101498. shader: string;
  101499. };
  101500. }
  101501. declare module BABYLON {
  101502. /** @hidden */
  101503. export var pointCloudVertex: {
  101504. name: string;
  101505. shader: string;
  101506. };
  101507. }
  101508. declare module BABYLON {
  101509. /** @hidden */
  101510. export var logDepthVertex: {
  101511. name: string;
  101512. shader: string;
  101513. };
  101514. }
  101515. declare module BABYLON {
  101516. /** @hidden */
  101517. export var defaultVertexShader: {
  101518. name: string;
  101519. shader: string;
  101520. };
  101521. }
  101522. declare module BABYLON {
  101523. /** @hidden */
  101524. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101525. MAINUV1: boolean;
  101526. MAINUV2: boolean;
  101527. DIFFUSE: boolean;
  101528. DIFFUSEDIRECTUV: number;
  101529. AMBIENT: boolean;
  101530. AMBIENTDIRECTUV: number;
  101531. OPACITY: boolean;
  101532. OPACITYDIRECTUV: number;
  101533. OPACITYRGB: boolean;
  101534. REFLECTION: boolean;
  101535. EMISSIVE: boolean;
  101536. EMISSIVEDIRECTUV: number;
  101537. SPECULAR: boolean;
  101538. SPECULARDIRECTUV: number;
  101539. BUMP: boolean;
  101540. BUMPDIRECTUV: number;
  101541. PARALLAX: boolean;
  101542. PARALLAXOCCLUSION: boolean;
  101543. SPECULAROVERALPHA: boolean;
  101544. CLIPPLANE: boolean;
  101545. CLIPPLANE2: boolean;
  101546. CLIPPLANE3: boolean;
  101547. CLIPPLANE4: boolean;
  101548. ALPHATEST: boolean;
  101549. DEPTHPREPASS: boolean;
  101550. ALPHAFROMDIFFUSE: boolean;
  101551. POINTSIZE: boolean;
  101552. FOG: boolean;
  101553. SPECULARTERM: boolean;
  101554. DIFFUSEFRESNEL: boolean;
  101555. OPACITYFRESNEL: boolean;
  101556. REFLECTIONFRESNEL: boolean;
  101557. REFRACTIONFRESNEL: boolean;
  101558. EMISSIVEFRESNEL: boolean;
  101559. FRESNEL: boolean;
  101560. NORMAL: boolean;
  101561. UV1: boolean;
  101562. UV2: boolean;
  101563. VERTEXCOLOR: boolean;
  101564. VERTEXALPHA: boolean;
  101565. NUM_BONE_INFLUENCERS: number;
  101566. BonesPerMesh: number;
  101567. BONETEXTURE: boolean;
  101568. INSTANCES: boolean;
  101569. GLOSSINESS: boolean;
  101570. ROUGHNESS: boolean;
  101571. EMISSIVEASILLUMINATION: boolean;
  101572. LINKEMISSIVEWITHDIFFUSE: boolean;
  101573. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101574. LIGHTMAP: boolean;
  101575. LIGHTMAPDIRECTUV: number;
  101576. OBJECTSPACE_NORMALMAP: boolean;
  101577. USELIGHTMAPASSHADOWMAP: boolean;
  101578. REFLECTIONMAP_3D: boolean;
  101579. REFLECTIONMAP_SPHERICAL: boolean;
  101580. REFLECTIONMAP_PLANAR: boolean;
  101581. REFLECTIONMAP_CUBIC: boolean;
  101582. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101583. REFLECTIONMAP_PROJECTION: boolean;
  101584. REFLECTIONMAP_SKYBOX: boolean;
  101585. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101586. REFLECTIONMAP_EXPLICIT: boolean;
  101587. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101588. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101589. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101590. INVERTCUBICMAP: boolean;
  101591. LOGARITHMICDEPTH: boolean;
  101592. REFRACTION: boolean;
  101593. REFRACTIONMAP_3D: boolean;
  101594. REFLECTIONOVERALPHA: boolean;
  101595. TWOSIDEDLIGHTING: boolean;
  101596. SHADOWFLOAT: boolean;
  101597. MORPHTARGETS: boolean;
  101598. MORPHTARGETS_NORMAL: boolean;
  101599. MORPHTARGETS_TANGENT: boolean;
  101600. NUM_MORPH_INFLUENCERS: number;
  101601. NONUNIFORMSCALING: boolean;
  101602. PREMULTIPLYALPHA: boolean;
  101603. IMAGEPROCESSING: boolean;
  101604. VIGNETTE: boolean;
  101605. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101606. VIGNETTEBLENDMODEOPAQUE: boolean;
  101607. TONEMAPPING: boolean;
  101608. TONEMAPPING_ACES: boolean;
  101609. CONTRAST: boolean;
  101610. COLORCURVES: boolean;
  101611. COLORGRADING: boolean;
  101612. COLORGRADING3D: boolean;
  101613. SAMPLER3DGREENDEPTH: boolean;
  101614. SAMPLER3DBGRMAP: boolean;
  101615. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101616. MULTIVIEW: boolean;
  101617. /**
  101618. * If the reflection texture on this material is in linear color space
  101619. * @hidden
  101620. */
  101621. IS_REFLECTION_LINEAR: boolean;
  101622. /**
  101623. * If the refraction texture on this material is in linear color space
  101624. * @hidden
  101625. */
  101626. IS_REFRACTION_LINEAR: boolean;
  101627. EXPOSURE: boolean;
  101628. constructor();
  101629. setReflectionMode(modeToEnable: string): void;
  101630. }
  101631. /**
  101632. * This is the default material used in Babylon. It is the best trade off between quality
  101633. * and performances.
  101634. * @see http://doc.babylonjs.com/babylon101/materials
  101635. */
  101636. export class StandardMaterial extends PushMaterial {
  101637. private _diffuseTexture;
  101638. /**
  101639. * The basic texture of the material as viewed under a light.
  101640. */
  101641. diffuseTexture: Nullable<BaseTexture>;
  101642. private _ambientTexture;
  101643. /**
  101644. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101645. */
  101646. ambientTexture: Nullable<BaseTexture>;
  101647. private _opacityTexture;
  101648. /**
  101649. * Define the transparency of the material from a texture.
  101650. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101651. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101652. */
  101653. opacityTexture: Nullable<BaseTexture>;
  101654. private _reflectionTexture;
  101655. /**
  101656. * Define the texture used to display the reflection.
  101657. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101658. */
  101659. reflectionTexture: Nullable<BaseTexture>;
  101660. private _emissiveTexture;
  101661. /**
  101662. * Define texture of the material as if self lit.
  101663. * This will be mixed in the final result even in the absence of light.
  101664. */
  101665. emissiveTexture: Nullable<BaseTexture>;
  101666. private _specularTexture;
  101667. /**
  101668. * Define how the color and intensity of the highlight given by the light in the material.
  101669. */
  101670. specularTexture: Nullable<BaseTexture>;
  101671. private _bumpTexture;
  101672. /**
  101673. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101674. * 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.
  101675. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101676. */
  101677. bumpTexture: Nullable<BaseTexture>;
  101678. private _lightmapTexture;
  101679. /**
  101680. * Complex lighting can be computationally expensive to compute at runtime.
  101681. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101682. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101683. */
  101684. lightmapTexture: Nullable<BaseTexture>;
  101685. private _refractionTexture;
  101686. /**
  101687. * Define the texture used to display the refraction.
  101688. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101689. */
  101690. refractionTexture: Nullable<BaseTexture>;
  101691. /**
  101692. * The color of the material lit by the environmental background lighting.
  101693. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101694. */
  101695. ambientColor: Color3;
  101696. /**
  101697. * The basic color of the material as viewed under a light.
  101698. */
  101699. diffuseColor: Color3;
  101700. /**
  101701. * Define how the color and intensity of the highlight given by the light in the material.
  101702. */
  101703. specularColor: Color3;
  101704. /**
  101705. * Define the color of the material as if self lit.
  101706. * This will be mixed in the final result even in the absence of light.
  101707. */
  101708. emissiveColor: Color3;
  101709. /**
  101710. * Defines how sharp are the highlights in the material.
  101711. * The bigger the value the sharper giving a more glossy feeling to the result.
  101712. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101713. */
  101714. specularPower: number;
  101715. private _useAlphaFromDiffuseTexture;
  101716. /**
  101717. * Does the transparency come from the diffuse texture alpha channel.
  101718. */
  101719. useAlphaFromDiffuseTexture: boolean;
  101720. private _useEmissiveAsIllumination;
  101721. /**
  101722. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101723. */
  101724. useEmissiveAsIllumination: boolean;
  101725. private _linkEmissiveWithDiffuse;
  101726. /**
  101727. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101728. * the emissive level when the final color is close to one.
  101729. */
  101730. linkEmissiveWithDiffuse: boolean;
  101731. private _useSpecularOverAlpha;
  101732. /**
  101733. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101734. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101735. */
  101736. useSpecularOverAlpha: boolean;
  101737. private _useReflectionOverAlpha;
  101738. /**
  101739. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101740. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101741. */
  101742. useReflectionOverAlpha: boolean;
  101743. private _disableLighting;
  101744. /**
  101745. * Does lights from the scene impacts this material.
  101746. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101747. */
  101748. disableLighting: boolean;
  101749. private _useObjectSpaceNormalMap;
  101750. /**
  101751. * Allows using an object space normal map (instead of tangent space).
  101752. */
  101753. useObjectSpaceNormalMap: boolean;
  101754. private _useParallax;
  101755. /**
  101756. * Is parallax enabled or not.
  101757. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101758. */
  101759. useParallax: boolean;
  101760. private _useParallaxOcclusion;
  101761. /**
  101762. * Is parallax occlusion enabled or not.
  101763. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101764. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101765. */
  101766. useParallaxOcclusion: boolean;
  101767. /**
  101768. * 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.
  101769. */
  101770. parallaxScaleBias: number;
  101771. private _roughness;
  101772. /**
  101773. * Helps to define how blurry the reflections should appears in the material.
  101774. */
  101775. roughness: number;
  101776. /**
  101777. * In case of refraction, define the value of the index of refraction.
  101778. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101779. */
  101780. indexOfRefraction: number;
  101781. /**
  101782. * Invert the refraction texture alongside the y axis.
  101783. * It can be useful with procedural textures or probe for instance.
  101784. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101785. */
  101786. invertRefractionY: boolean;
  101787. /**
  101788. * Defines the alpha limits in alpha test mode.
  101789. */
  101790. alphaCutOff: number;
  101791. private _useLightmapAsShadowmap;
  101792. /**
  101793. * In case of light mapping, define whether the map contains light or shadow informations.
  101794. */
  101795. useLightmapAsShadowmap: boolean;
  101796. private _diffuseFresnelParameters;
  101797. /**
  101798. * Define the diffuse fresnel parameters of the material.
  101799. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101800. */
  101801. diffuseFresnelParameters: FresnelParameters;
  101802. private _opacityFresnelParameters;
  101803. /**
  101804. * Define the opacity fresnel parameters of the material.
  101805. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101806. */
  101807. opacityFresnelParameters: FresnelParameters;
  101808. private _reflectionFresnelParameters;
  101809. /**
  101810. * Define the reflection fresnel parameters of the material.
  101811. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101812. */
  101813. reflectionFresnelParameters: FresnelParameters;
  101814. private _refractionFresnelParameters;
  101815. /**
  101816. * Define the refraction fresnel parameters of the material.
  101817. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101818. */
  101819. refractionFresnelParameters: FresnelParameters;
  101820. private _emissiveFresnelParameters;
  101821. /**
  101822. * Define the emissive fresnel parameters of the material.
  101823. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101824. */
  101825. emissiveFresnelParameters: FresnelParameters;
  101826. private _useReflectionFresnelFromSpecular;
  101827. /**
  101828. * If true automatically deducts the fresnels values from the material specularity.
  101829. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101830. */
  101831. useReflectionFresnelFromSpecular: boolean;
  101832. private _useGlossinessFromSpecularMapAlpha;
  101833. /**
  101834. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101835. */
  101836. useGlossinessFromSpecularMapAlpha: boolean;
  101837. private _maxSimultaneousLights;
  101838. /**
  101839. * Defines the maximum number of lights that can be used in the material
  101840. */
  101841. maxSimultaneousLights: number;
  101842. private _invertNormalMapX;
  101843. /**
  101844. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101845. */
  101846. invertNormalMapX: boolean;
  101847. private _invertNormalMapY;
  101848. /**
  101849. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101850. */
  101851. invertNormalMapY: boolean;
  101852. private _twoSidedLighting;
  101853. /**
  101854. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101855. */
  101856. twoSidedLighting: boolean;
  101857. /**
  101858. * Default configuration related to image processing available in the standard Material.
  101859. */
  101860. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101861. /**
  101862. * Gets the image processing configuration used either in this material.
  101863. */
  101864. /**
  101865. * Sets the Default image processing configuration used either in the this material.
  101866. *
  101867. * If sets to null, the scene one is in use.
  101868. */
  101869. imageProcessingConfiguration: ImageProcessingConfiguration;
  101870. /**
  101871. * Keep track of the image processing observer to allow dispose and replace.
  101872. */
  101873. private _imageProcessingObserver;
  101874. /**
  101875. * Attaches a new image processing configuration to the Standard Material.
  101876. * @param configuration
  101877. */
  101878. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101879. /**
  101880. * Gets wether the color curves effect is enabled.
  101881. */
  101882. /**
  101883. * Sets wether the color curves effect is enabled.
  101884. */
  101885. cameraColorCurvesEnabled: boolean;
  101886. /**
  101887. * Gets wether the color grading effect is enabled.
  101888. */
  101889. /**
  101890. * Gets wether the color grading effect is enabled.
  101891. */
  101892. cameraColorGradingEnabled: boolean;
  101893. /**
  101894. * Gets wether tonemapping is enabled or not.
  101895. */
  101896. /**
  101897. * Sets wether tonemapping is enabled or not
  101898. */
  101899. cameraToneMappingEnabled: boolean;
  101900. /**
  101901. * The camera exposure used on this material.
  101902. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101903. * This corresponds to a photographic exposure.
  101904. */
  101905. /**
  101906. * The camera exposure used on this material.
  101907. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101908. * This corresponds to a photographic exposure.
  101909. */
  101910. cameraExposure: number;
  101911. /**
  101912. * Gets The camera contrast used on this material.
  101913. */
  101914. /**
  101915. * Sets The camera contrast used on this material.
  101916. */
  101917. cameraContrast: number;
  101918. /**
  101919. * Gets the Color Grading 2D Lookup Texture.
  101920. */
  101921. /**
  101922. * Sets the Color Grading 2D Lookup Texture.
  101923. */
  101924. cameraColorGradingTexture: Nullable<BaseTexture>;
  101925. /**
  101926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101928. * 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;
  101929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101930. */
  101931. /**
  101932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101934. * 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;
  101935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101936. */
  101937. cameraColorCurves: Nullable<ColorCurves>;
  101938. /**
  101939. * Custom callback helping to override the default shader used in the material.
  101940. */
  101941. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  101942. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101943. protected _worldViewProjectionMatrix: Matrix;
  101944. protected _globalAmbientColor: Color3;
  101945. protected _useLogarithmicDepth: boolean;
  101946. /**
  101947. * Instantiates a new standard material.
  101948. * This is the default material used in Babylon. It is the best trade off between quality
  101949. * and performances.
  101950. * @see http://doc.babylonjs.com/babylon101/materials
  101951. * @param name Define the name of the material in the scene
  101952. * @param scene Define the scene the material belong to
  101953. */
  101954. constructor(name: string, scene: Scene);
  101955. /**
  101956. * Gets a boolean indicating that current material needs to register RTT
  101957. */
  101958. readonly hasRenderTargetTextures: boolean;
  101959. /**
  101960. * Gets the current class name of the material e.g. "StandardMaterial"
  101961. * Mainly use in serialization.
  101962. * @returns the class name
  101963. */
  101964. getClassName(): string;
  101965. /**
  101966. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101967. * You can try switching to logarithmic depth.
  101968. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101969. */
  101970. useLogarithmicDepth: boolean;
  101971. /**
  101972. * Specifies if the material will require alpha blending
  101973. * @returns a boolean specifying if alpha blending is needed
  101974. */
  101975. needAlphaBlending(): boolean;
  101976. /**
  101977. * Specifies if this material should be rendered in alpha test mode
  101978. * @returns a boolean specifying if an alpha test is needed.
  101979. */
  101980. needAlphaTesting(): boolean;
  101981. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101982. /**
  101983. * Get the texture used for alpha test purpose.
  101984. * @returns the diffuse texture in case of the standard material.
  101985. */
  101986. getAlphaTestTexture(): Nullable<BaseTexture>;
  101987. /**
  101988. * Get if the submesh is ready to be used and all its information available.
  101989. * Child classes can use it to update shaders
  101990. * @param mesh defines the mesh to check
  101991. * @param subMesh defines which submesh to check
  101992. * @param useInstances specifies that instances should be used
  101993. * @returns a boolean indicating that the submesh is ready or not
  101994. */
  101995. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101996. /**
  101997. * Builds the material UBO layouts.
  101998. * Used internally during the effect preparation.
  101999. */
  102000. buildUniformLayout(): void;
  102001. /**
  102002. * Unbinds the material from the mesh
  102003. */
  102004. unbind(): void;
  102005. /**
  102006. * Binds the submesh to this material by preparing the effect and shader to draw
  102007. * @param world defines the world transformation matrix
  102008. * @param mesh defines the mesh containing the submesh
  102009. * @param subMesh defines the submesh to bind the material to
  102010. */
  102011. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102012. /**
  102013. * Get the list of animatables in the material.
  102014. * @returns the list of animatables object used in the material
  102015. */
  102016. getAnimatables(): IAnimatable[];
  102017. /**
  102018. * Gets the active textures from the material
  102019. * @returns an array of textures
  102020. */
  102021. getActiveTextures(): BaseTexture[];
  102022. /**
  102023. * Specifies if the material uses a texture
  102024. * @param texture defines the texture to check against the material
  102025. * @returns a boolean specifying if the material uses the texture
  102026. */
  102027. hasTexture(texture: BaseTexture): boolean;
  102028. /**
  102029. * Disposes the material
  102030. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102031. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102032. */
  102033. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102034. /**
  102035. * Makes a duplicate of the material, and gives it a new name
  102036. * @param name defines the new name for the duplicated material
  102037. * @returns the cloned material
  102038. */
  102039. clone(name: string): StandardMaterial;
  102040. /**
  102041. * Serializes this material in a JSON representation
  102042. * @returns the serialized material object
  102043. */
  102044. serialize(): any;
  102045. /**
  102046. * Creates a standard material from parsed material data
  102047. * @param source defines the JSON representation of the material
  102048. * @param scene defines the hosting scene
  102049. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102050. * @returns a new standard material
  102051. */
  102052. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102053. /**
  102054. * Are diffuse textures enabled in the application.
  102055. */
  102056. static DiffuseTextureEnabled: boolean;
  102057. /**
  102058. * Are ambient textures enabled in the application.
  102059. */
  102060. static AmbientTextureEnabled: boolean;
  102061. /**
  102062. * Are opacity textures enabled in the application.
  102063. */
  102064. static OpacityTextureEnabled: boolean;
  102065. /**
  102066. * Are reflection textures enabled in the application.
  102067. */
  102068. static ReflectionTextureEnabled: boolean;
  102069. /**
  102070. * Are emissive textures enabled in the application.
  102071. */
  102072. static EmissiveTextureEnabled: boolean;
  102073. /**
  102074. * Are specular textures enabled in the application.
  102075. */
  102076. static SpecularTextureEnabled: boolean;
  102077. /**
  102078. * Are bump textures enabled in the application.
  102079. */
  102080. static BumpTextureEnabled: boolean;
  102081. /**
  102082. * Are lightmap textures enabled in the application.
  102083. */
  102084. static LightmapTextureEnabled: boolean;
  102085. /**
  102086. * Are refraction textures enabled in the application.
  102087. */
  102088. static RefractionTextureEnabled: boolean;
  102089. /**
  102090. * Are color grading textures enabled in the application.
  102091. */
  102092. static ColorGradingTextureEnabled: boolean;
  102093. /**
  102094. * Are fresnels enabled in the application.
  102095. */
  102096. static FresnelEnabled: boolean;
  102097. }
  102098. }
  102099. declare module BABYLON {
  102100. /**
  102101. * A class extending Texture allowing drawing on a texture
  102102. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102103. */
  102104. export class DynamicTexture extends Texture {
  102105. private _generateMipMaps;
  102106. private _canvas;
  102107. private _context;
  102108. private _engine;
  102109. /**
  102110. * Creates a DynamicTexture
  102111. * @param name defines the name of the texture
  102112. * @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
  102113. * @param scene defines the scene where you want the texture
  102114. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102115. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102116. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102117. */
  102118. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102119. /**
  102120. * Get the current class name of the texture useful for serialization or dynamic coding.
  102121. * @returns "DynamicTexture"
  102122. */
  102123. getClassName(): string;
  102124. /**
  102125. * Gets the current state of canRescale
  102126. */
  102127. readonly canRescale: boolean;
  102128. private _recreate;
  102129. /**
  102130. * Scales the texture
  102131. * @param ratio the scale factor to apply to both width and height
  102132. */
  102133. scale(ratio: number): void;
  102134. /**
  102135. * Resizes the texture
  102136. * @param width the new width
  102137. * @param height the new height
  102138. */
  102139. scaleTo(width: number, height: number): void;
  102140. /**
  102141. * Gets the context of the canvas used by the texture
  102142. * @returns the canvas context of the dynamic texture
  102143. */
  102144. getContext(): CanvasRenderingContext2D;
  102145. /**
  102146. * Clears the texture
  102147. */
  102148. clear(): void;
  102149. /**
  102150. * Updates the texture
  102151. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102152. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102153. */
  102154. update(invertY?: boolean, premulAlpha?: boolean): void;
  102155. /**
  102156. * Draws text onto the texture
  102157. * @param text defines the text to be drawn
  102158. * @param x defines the placement of the text from the left
  102159. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102160. * @param font defines the font to be used with font-style, font-size, font-name
  102161. * @param color defines the color used for the text
  102162. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102163. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102164. * @param update defines whether texture is immediately update (default is true)
  102165. */
  102166. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102167. /**
  102168. * Clones the texture
  102169. * @returns the clone of the texture.
  102170. */
  102171. clone(): DynamicTexture;
  102172. /**
  102173. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102174. * @returns a serialized dynamic texture object
  102175. */
  102176. serialize(): any;
  102177. /** @hidden */
  102178. _rebuild(): void;
  102179. }
  102180. }
  102181. declare module BABYLON {
  102182. /** @hidden */
  102183. export var imageProcessingPixelShader: {
  102184. name: string;
  102185. shader: string;
  102186. };
  102187. }
  102188. declare module BABYLON {
  102189. /**
  102190. * ImageProcessingPostProcess
  102191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102192. */
  102193. export class ImageProcessingPostProcess extends PostProcess {
  102194. /**
  102195. * Default configuration related to image processing available in the PBR Material.
  102196. */
  102197. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102198. /**
  102199. * Gets the image processing configuration used either in this material.
  102200. */
  102201. /**
  102202. * Sets the Default image processing configuration used either in the this material.
  102203. *
  102204. * If sets to null, the scene one is in use.
  102205. */
  102206. imageProcessingConfiguration: ImageProcessingConfiguration;
  102207. /**
  102208. * Keep track of the image processing observer to allow dispose and replace.
  102209. */
  102210. private _imageProcessingObserver;
  102211. /**
  102212. * Attaches a new image processing configuration to the PBR Material.
  102213. * @param configuration
  102214. */
  102215. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102216. /**
  102217. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102218. */
  102219. /**
  102220. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102221. */
  102222. colorCurves: Nullable<ColorCurves>;
  102223. /**
  102224. * Gets wether the color curves effect is enabled.
  102225. */
  102226. /**
  102227. * Sets wether the color curves effect is enabled.
  102228. */
  102229. colorCurvesEnabled: boolean;
  102230. /**
  102231. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102232. */
  102233. /**
  102234. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102235. */
  102236. colorGradingTexture: Nullable<BaseTexture>;
  102237. /**
  102238. * Gets wether the color grading effect is enabled.
  102239. */
  102240. /**
  102241. * Gets wether the color grading effect is enabled.
  102242. */
  102243. colorGradingEnabled: boolean;
  102244. /**
  102245. * Gets exposure used in the effect.
  102246. */
  102247. /**
  102248. * Sets exposure used in the effect.
  102249. */
  102250. exposure: number;
  102251. /**
  102252. * Gets wether tonemapping is enabled or not.
  102253. */
  102254. /**
  102255. * Sets wether tonemapping is enabled or not
  102256. */
  102257. toneMappingEnabled: boolean;
  102258. /**
  102259. * Gets the type of tone mapping effect.
  102260. */
  102261. /**
  102262. * Sets the type of tone mapping effect.
  102263. */
  102264. toneMappingType: number;
  102265. /**
  102266. * Gets contrast used in the effect.
  102267. */
  102268. /**
  102269. * Sets contrast used in the effect.
  102270. */
  102271. contrast: number;
  102272. /**
  102273. * Gets Vignette stretch size.
  102274. */
  102275. /**
  102276. * Sets Vignette stretch size.
  102277. */
  102278. vignetteStretch: number;
  102279. /**
  102280. * Gets Vignette centre X Offset.
  102281. */
  102282. /**
  102283. * Sets Vignette centre X Offset.
  102284. */
  102285. vignetteCentreX: number;
  102286. /**
  102287. * Gets Vignette centre Y Offset.
  102288. */
  102289. /**
  102290. * Sets Vignette centre Y Offset.
  102291. */
  102292. vignetteCentreY: number;
  102293. /**
  102294. * Gets Vignette weight or intensity of the vignette effect.
  102295. */
  102296. /**
  102297. * Sets Vignette weight or intensity of the vignette effect.
  102298. */
  102299. vignetteWeight: number;
  102300. /**
  102301. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102302. * if vignetteEnabled is set to true.
  102303. */
  102304. /**
  102305. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102306. * if vignetteEnabled is set to true.
  102307. */
  102308. vignetteColor: Color4;
  102309. /**
  102310. * Gets Camera field of view used by the Vignette effect.
  102311. */
  102312. /**
  102313. * Sets Camera field of view used by the Vignette effect.
  102314. */
  102315. vignetteCameraFov: number;
  102316. /**
  102317. * Gets the vignette blend mode allowing different kind of effect.
  102318. */
  102319. /**
  102320. * Sets the vignette blend mode allowing different kind of effect.
  102321. */
  102322. vignetteBlendMode: number;
  102323. /**
  102324. * Gets wether the vignette effect is enabled.
  102325. */
  102326. /**
  102327. * Sets wether the vignette effect is enabled.
  102328. */
  102329. vignetteEnabled: boolean;
  102330. private _fromLinearSpace;
  102331. /**
  102332. * Gets wether the input of the processing is in Gamma or Linear Space.
  102333. */
  102334. /**
  102335. * Sets wether the input of the processing is in Gamma or Linear Space.
  102336. */
  102337. fromLinearSpace: boolean;
  102338. /**
  102339. * Defines cache preventing GC.
  102340. */
  102341. private _defines;
  102342. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102343. /**
  102344. * "ImageProcessingPostProcess"
  102345. * @returns "ImageProcessingPostProcess"
  102346. */
  102347. getClassName(): string;
  102348. protected _updateParameters(): void;
  102349. dispose(camera?: Camera): void;
  102350. }
  102351. }
  102352. declare module BABYLON {
  102353. /**
  102354. * Class containing static functions to help procedurally build meshes
  102355. */
  102356. export class GroundBuilder {
  102357. /**
  102358. * Creates a ground mesh
  102359. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102360. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102362. * @param name defines the name of the mesh
  102363. * @param options defines the options used to create the mesh
  102364. * @param scene defines the hosting scene
  102365. * @returns the ground mesh
  102366. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102367. */
  102368. static CreateGround(name: string, options: {
  102369. width?: number;
  102370. height?: number;
  102371. subdivisions?: number;
  102372. subdivisionsX?: number;
  102373. subdivisionsY?: number;
  102374. updatable?: boolean;
  102375. }, scene: any): Mesh;
  102376. /**
  102377. * Creates a tiled ground mesh
  102378. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102379. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102380. * * 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
  102381. * * 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
  102382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102383. * @param name defines the name of the mesh
  102384. * @param options defines the options used to create the mesh
  102385. * @param scene defines the hosting scene
  102386. * @returns the tiled ground mesh
  102387. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102388. */
  102389. static CreateTiledGround(name: string, options: {
  102390. xmin: number;
  102391. zmin: number;
  102392. xmax: number;
  102393. zmax: number;
  102394. subdivisions?: {
  102395. w: number;
  102396. h: number;
  102397. };
  102398. precision?: {
  102399. w: number;
  102400. h: number;
  102401. };
  102402. updatable?: boolean;
  102403. }, scene?: Nullable<Scene>): Mesh;
  102404. /**
  102405. * Creates a ground mesh from a height map
  102406. * * The parameter `url` sets the URL of the height map image resource.
  102407. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102408. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102409. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102410. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102411. * * 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.
  102412. * * 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).
  102413. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102415. * @param name defines the name of the mesh
  102416. * @param url defines the url to the height map
  102417. * @param options defines the options used to create the mesh
  102418. * @param scene defines the hosting scene
  102419. * @returns the ground mesh
  102420. * @see https://doc.babylonjs.com/babylon101/height_map
  102421. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102422. */
  102423. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102424. width?: number;
  102425. height?: number;
  102426. subdivisions?: number;
  102427. minHeight?: number;
  102428. maxHeight?: number;
  102429. colorFilter?: Color3;
  102430. alphaFilter?: number;
  102431. updatable?: boolean;
  102432. onReady?: (mesh: GroundMesh) => void;
  102433. }, scene?: Nullable<Scene>): GroundMesh;
  102434. }
  102435. }
  102436. declare module BABYLON {
  102437. /**
  102438. * Class containing static functions to help procedurally build meshes
  102439. */
  102440. export class TorusBuilder {
  102441. /**
  102442. * Creates a torus mesh
  102443. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102444. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102445. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102449. * @param name defines the name of the mesh
  102450. * @param options defines the options used to create the mesh
  102451. * @param scene defines the hosting scene
  102452. * @returns the torus mesh
  102453. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102454. */
  102455. static CreateTorus(name: string, options: {
  102456. diameter?: number;
  102457. thickness?: number;
  102458. tessellation?: number;
  102459. updatable?: boolean;
  102460. sideOrientation?: number;
  102461. frontUVs?: Vector4;
  102462. backUVs?: Vector4;
  102463. }, scene: any): Mesh;
  102464. }
  102465. }
  102466. declare module BABYLON {
  102467. /**
  102468. * Class containing static functions to help procedurally build meshes
  102469. */
  102470. export class CylinderBuilder {
  102471. /**
  102472. * Creates a cylinder or a cone mesh
  102473. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102474. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102475. * * 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.
  102476. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102477. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102478. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102479. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102480. * * 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).
  102481. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102482. * * 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).
  102483. * * 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
  102484. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102485. * * 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
  102486. * * 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.
  102487. * * If `enclose` is false, a ring surface is one element.
  102488. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102489. * * 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
  102490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102493. * @param name defines the name of the mesh
  102494. * @param options defines the options used to create the mesh
  102495. * @param scene defines the hosting scene
  102496. * @returns the cylinder mesh
  102497. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102498. */
  102499. static CreateCylinder(name: string, options: {
  102500. height?: number;
  102501. diameterTop?: number;
  102502. diameterBottom?: number;
  102503. diameter?: number;
  102504. tessellation?: number;
  102505. subdivisions?: number;
  102506. arc?: number;
  102507. faceColors?: Color4[];
  102508. faceUV?: Vector4[];
  102509. updatable?: boolean;
  102510. hasRings?: boolean;
  102511. enclose?: boolean;
  102512. cap?: number;
  102513. sideOrientation?: number;
  102514. frontUVs?: Vector4;
  102515. backUVs?: Vector4;
  102516. }, scene: any): Mesh;
  102517. }
  102518. }
  102519. declare module BABYLON {
  102520. /**
  102521. * Options to modify the vr teleportation behavior.
  102522. */
  102523. export interface VRTeleportationOptions {
  102524. /**
  102525. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102526. */
  102527. floorMeshName?: string;
  102528. /**
  102529. * A list of meshes to be used as the teleportation floor. (default: empty)
  102530. */
  102531. floorMeshes?: Mesh[];
  102532. }
  102533. /**
  102534. * Options to modify the vr experience helper's behavior.
  102535. */
  102536. export interface VRExperienceHelperOptions extends WebVROptions {
  102537. /**
  102538. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102539. */
  102540. createDeviceOrientationCamera?: boolean;
  102541. /**
  102542. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102543. */
  102544. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102545. /**
  102546. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102547. */
  102548. laserToggle?: boolean;
  102549. /**
  102550. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102551. */
  102552. floorMeshes?: Mesh[];
  102553. /**
  102554. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102555. */
  102556. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102557. }
  102558. /**
  102559. * Event containing information after VR has been entered
  102560. */
  102561. export class OnAfterEnteringVRObservableEvent {
  102562. /**
  102563. * If entering vr was successful
  102564. */
  102565. success: boolean;
  102566. }
  102567. /**
  102568. * Helps to quickly add VR support to an existing scene.
  102569. * See http://doc.babylonjs.com/how_to/webvr_helper
  102570. */
  102571. export class VRExperienceHelper {
  102572. /** Options to modify the vr experience helper's behavior. */
  102573. webVROptions: VRExperienceHelperOptions;
  102574. private _scene;
  102575. private _position;
  102576. private _btnVR;
  102577. private _btnVRDisplayed;
  102578. private _webVRsupported;
  102579. private _webVRready;
  102580. private _webVRrequesting;
  102581. private _webVRpresenting;
  102582. private _hasEnteredVR;
  102583. private _fullscreenVRpresenting;
  102584. private _canvas;
  102585. private _webVRCamera;
  102586. private _vrDeviceOrientationCamera;
  102587. private _deviceOrientationCamera;
  102588. private _existingCamera;
  102589. private _onKeyDown;
  102590. private _onVrDisplayPresentChange;
  102591. private _onVRDisplayChanged;
  102592. private _onVRRequestPresentStart;
  102593. private _onVRRequestPresentComplete;
  102594. /**
  102595. * Observable raised right before entering VR.
  102596. */
  102597. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102598. /**
  102599. * Observable raised when entering VR has completed.
  102600. */
  102601. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102602. /**
  102603. * Observable raised when exiting VR.
  102604. */
  102605. onExitingVRObservable: Observable<VRExperienceHelper>;
  102606. /**
  102607. * Observable raised when controller mesh is loaded.
  102608. */
  102609. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102610. /** Return this.onEnteringVRObservable
  102611. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102612. */
  102613. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102614. /** Return this.onExitingVRObservable
  102615. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102616. */
  102617. readonly onExitingVR: Observable<VRExperienceHelper>;
  102618. /** Return this.onControllerMeshLoadedObservable
  102619. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102620. */
  102621. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102622. private _rayLength;
  102623. private _useCustomVRButton;
  102624. private _teleportationRequested;
  102625. private _teleportActive;
  102626. private _floorMeshName;
  102627. private _floorMeshesCollection;
  102628. private _rotationAllowed;
  102629. private _teleportBackwardsVector;
  102630. private _teleportationTarget;
  102631. private _isDefaultTeleportationTarget;
  102632. private _postProcessMove;
  102633. private _teleportationFillColor;
  102634. private _teleportationBorderColor;
  102635. private _rotationAngle;
  102636. private _haloCenter;
  102637. private _cameraGazer;
  102638. private _padSensibilityUp;
  102639. private _padSensibilityDown;
  102640. private _leftController;
  102641. private _rightController;
  102642. /**
  102643. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102644. */
  102645. onNewMeshSelected: Observable<AbstractMesh>;
  102646. /**
  102647. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102648. */
  102649. onNewMeshPicked: Observable<PickingInfo>;
  102650. private _circleEase;
  102651. /**
  102652. * Observable raised before camera teleportation
  102653. */
  102654. onBeforeCameraTeleport: Observable<Vector3>;
  102655. /**
  102656. * Observable raised after camera teleportation
  102657. */
  102658. onAfterCameraTeleport: Observable<Vector3>;
  102659. /**
  102660. * Observable raised when current selected mesh gets unselected
  102661. */
  102662. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102663. private _raySelectionPredicate;
  102664. /**
  102665. * To be optionaly changed by user to define custom ray selection
  102666. */
  102667. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102668. /**
  102669. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102670. */
  102671. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102672. /**
  102673. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102674. */
  102675. teleportationEnabled: boolean;
  102676. private _defaultHeight;
  102677. private _teleportationInitialized;
  102678. private _interactionsEnabled;
  102679. private _interactionsRequested;
  102680. private _displayGaze;
  102681. private _displayLaserPointer;
  102682. /**
  102683. * The mesh used to display where the user is going to teleport.
  102684. */
  102685. /**
  102686. * Sets the mesh to be used to display where the user is going to teleport.
  102687. */
  102688. teleportationTarget: Mesh;
  102689. /**
  102690. * 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
  102691. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102692. * See http://doc.babylonjs.com/resources/baking_transformations
  102693. */
  102694. gazeTrackerMesh: Mesh;
  102695. /**
  102696. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102697. */
  102698. updateGazeTrackerScale: boolean;
  102699. /**
  102700. * If the gaze trackers color should be updated when selecting meshes
  102701. */
  102702. updateGazeTrackerColor: boolean;
  102703. /**
  102704. * The gaze tracking mesh corresponding to the left controller
  102705. */
  102706. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102707. /**
  102708. * The gaze tracking mesh corresponding to the right controller
  102709. */
  102710. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102711. /**
  102712. * If the ray of the gaze should be displayed.
  102713. */
  102714. /**
  102715. * Sets if the ray of the gaze should be displayed.
  102716. */
  102717. displayGaze: boolean;
  102718. /**
  102719. * If the ray of the LaserPointer should be displayed.
  102720. */
  102721. /**
  102722. * Sets if the ray of the LaserPointer should be displayed.
  102723. */
  102724. displayLaserPointer: boolean;
  102725. /**
  102726. * The deviceOrientationCamera used as the camera when not in VR.
  102727. */
  102728. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102729. /**
  102730. * Based on the current WebVR support, returns the current VR camera used.
  102731. */
  102732. readonly currentVRCamera: Nullable<Camera>;
  102733. /**
  102734. * The webVRCamera which is used when in VR.
  102735. */
  102736. readonly webVRCamera: WebVRFreeCamera;
  102737. /**
  102738. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102739. */
  102740. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102741. private readonly _teleportationRequestInitiated;
  102742. /**
  102743. * Defines wether or not Pointer lock should be requested when switching to
  102744. * full screen.
  102745. */
  102746. requestPointerLockOnFullScreen: boolean;
  102747. /**
  102748. * Instantiates a VRExperienceHelper.
  102749. * Helps to quickly add VR support to an existing scene.
  102750. * @param scene The scene the VRExperienceHelper belongs to.
  102751. * @param webVROptions Options to modify the vr experience helper's behavior.
  102752. */
  102753. constructor(scene: Scene,
  102754. /** Options to modify the vr experience helper's behavior. */
  102755. webVROptions?: VRExperienceHelperOptions);
  102756. private _onDefaultMeshLoaded;
  102757. private _onResize;
  102758. private _onFullscreenChange;
  102759. /**
  102760. * Gets a value indicating if we are currently in VR mode.
  102761. */
  102762. readonly isInVRMode: boolean;
  102763. private onVrDisplayPresentChange;
  102764. private onVRDisplayChanged;
  102765. private moveButtonToBottomRight;
  102766. private displayVRButton;
  102767. private updateButtonVisibility;
  102768. private _cachedAngularSensibility;
  102769. /**
  102770. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102771. * Otherwise, will use the fullscreen API.
  102772. */
  102773. enterVR(): void;
  102774. /**
  102775. * Attempt to exit VR, or fullscreen.
  102776. */
  102777. exitVR(): void;
  102778. /**
  102779. * The position of the vr experience helper.
  102780. */
  102781. /**
  102782. * Sets the position of the vr experience helper.
  102783. */
  102784. position: Vector3;
  102785. /**
  102786. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102787. */
  102788. enableInteractions(): void;
  102789. private readonly _noControllerIsActive;
  102790. private beforeRender;
  102791. private _isTeleportationFloor;
  102792. /**
  102793. * Adds a floor mesh to be used for teleportation.
  102794. * @param floorMesh the mesh to be used for teleportation.
  102795. */
  102796. addFloorMesh(floorMesh: Mesh): void;
  102797. /**
  102798. * Removes a floor mesh from being used for teleportation.
  102799. * @param floorMesh the mesh to be removed.
  102800. */
  102801. removeFloorMesh(floorMesh: Mesh): void;
  102802. /**
  102803. * Enables interactions and teleportation using the VR controllers and gaze.
  102804. * @param vrTeleportationOptions options to modify teleportation behavior.
  102805. */
  102806. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  102807. private _onNewGamepadConnected;
  102808. private _tryEnableInteractionOnController;
  102809. private _onNewGamepadDisconnected;
  102810. private _enableInteractionOnController;
  102811. private _checkTeleportWithRay;
  102812. private _checkRotate;
  102813. private _checkTeleportBackwards;
  102814. private _enableTeleportationOnController;
  102815. private _createTeleportationCircles;
  102816. private _displayTeleportationTarget;
  102817. private _hideTeleportationTarget;
  102818. private _rotateCamera;
  102819. private _moveTeleportationSelectorTo;
  102820. private _workingVector;
  102821. private _workingQuaternion;
  102822. private _workingMatrix;
  102823. /**
  102824. * Teleports the users feet to the desired location
  102825. * @param location The location where the user's feet should be placed
  102826. */
  102827. teleportCamera(location: Vector3): void;
  102828. private _convertNormalToDirectionOfRay;
  102829. private _castRayAndSelectObject;
  102830. private _notifySelectedMeshUnselected;
  102831. /**
  102832. * Sets the color of the laser ray from the vr controllers.
  102833. * @param color new color for the ray.
  102834. */
  102835. changeLaserColor(color: Color3): void;
  102836. /**
  102837. * Sets the color of the ray from the vr headsets gaze.
  102838. * @param color new color for the ray.
  102839. */
  102840. changeGazeColor(color: Color3): void;
  102841. /**
  102842. * Exits VR and disposes of the vr experience helper
  102843. */
  102844. dispose(): void;
  102845. /**
  102846. * Gets the name of the VRExperienceHelper class
  102847. * @returns "VRExperienceHelper"
  102848. */
  102849. getClassName(): string;
  102850. }
  102851. }
  102852. declare module BABYLON {
  102853. /**
  102854. * Manages an XRSession
  102855. * @see https://doc.babylonjs.com/how_to/webxr
  102856. */
  102857. export class WebXRSessionManager implements IDisposable {
  102858. private scene;
  102859. /**
  102860. * Fires every time a new xrFrame arrives which can be used to update the camera
  102861. */
  102862. onXRFrameObservable: Observable<any>;
  102863. /**
  102864. * Fires when the xr session is ended either by the device or manually done
  102865. */
  102866. onXRSessionEnded: Observable<any>;
  102867. /** @hidden */
  102868. _xrSession: XRSession;
  102869. /** @hidden */
  102870. _frameOfReference: XRFrameOfReference;
  102871. /** @hidden */
  102872. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  102873. /** @hidden */
  102874. _currentXRFrame: Nullable<XRFrame>;
  102875. private _xrNavigator;
  102876. private _xrDevice;
  102877. private _tmpMatrix;
  102878. /**
  102879. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  102880. * @param scene The scene which the session should be created for
  102881. */
  102882. constructor(scene: Scene);
  102883. /**
  102884. * Initializes the manager
  102885. * After initialization enterXR can be called to start an XR session
  102886. * @returns Promise which resolves after it is initialized
  102887. */
  102888. initializeAsync(): Promise<void>;
  102889. /**
  102890. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  102891. * @param sessionCreationOptions xr options to create the session with
  102892. * @param frameOfReferenceType option to configure how the xr pose is expressed
  102893. * @returns Promise which resolves after it enters XR
  102894. */
  102895. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  102896. /**
  102897. * Stops the xrSession and restores the renderloop
  102898. * @returns Promise which resolves after it exits XR
  102899. */
  102900. exitXRAsync(): Promise<void>;
  102901. /**
  102902. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102903. * @param ray ray to cast into the environment
  102904. * @returns Promise which resolves with a collision point in the environment if it exists
  102905. */
  102906. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102907. /**
  102908. * Checks if a session would be supported for the creation options specified
  102909. * @param options creation options to check if they are supported
  102910. * @returns true if supported
  102911. */
  102912. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102913. /**
  102914. * @hidden
  102915. * Converts the render layer of xrSession to a render target
  102916. * @param session session to create render target for
  102917. * @param scene scene the new render target should be created for
  102918. */
  102919. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  102920. /**
  102921. * Disposes of the session manager
  102922. */
  102923. dispose(): void;
  102924. }
  102925. }
  102926. declare module BABYLON {
  102927. /**
  102928. * WebXR Camera which holds the views for the xrSession
  102929. * @see https://doc.babylonjs.com/how_to/webxr
  102930. */
  102931. export class WebXRCamera extends FreeCamera {
  102932. private static _TmpMatrix;
  102933. /**
  102934. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  102935. * @param name the name of the camera
  102936. * @param scene the scene to add the camera to
  102937. */
  102938. constructor(name: string, scene: Scene);
  102939. private _updateNumberOfRigCameras;
  102940. /** @hidden */
  102941. _updateForDualEyeDebugging(pupilDistance?: number): void;
  102942. /**
  102943. * Updates the cameras position from the current pose information of the XR session
  102944. * @param xrSessionManager the session containing pose information
  102945. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  102946. */
  102947. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  102948. }
  102949. }
  102950. declare module BABYLON {
  102951. /**
  102952. * States of the webXR experience
  102953. */
  102954. export enum WebXRState {
  102955. /**
  102956. * Transitioning to being in XR mode
  102957. */
  102958. ENTERING_XR = 0,
  102959. /**
  102960. * Transitioning to non XR mode
  102961. */
  102962. EXITING_XR = 1,
  102963. /**
  102964. * In XR mode and presenting
  102965. */
  102966. IN_XR = 2,
  102967. /**
  102968. * Not entered XR mode
  102969. */
  102970. NOT_IN_XR = 3
  102971. }
  102972. /**
  102973. * Helper class used to enable XR
  102974. * @see https://doc.babylonjs.com/how_to/webxr
  102975. */
  102976. export class WebXRExperienceHelper implements IDisposable {
  102977. private scene;
  102978. /**
  102979. * 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
  102980. */
  102981. container: AbstractMesh;
  102982. /**
  102983. * Camera used to render xr content
  102984. */
  102985. camera: WebXRCamera;
  102986. /**
  102987. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  102988. */
  102989. state: WebXRState;
  102990. private _setState;
  102991. private static _TmpVector;
  102992. /**
  102993. * Fires when the state of the experience helper has changed
  102994. */
  102995. onStateChangedObservable: Observable<WebXRState>;
  102996. /** @hidden */
  102997. _sessionManager: WebXRSessionManager;
  102998. private _nonVRCamera;
  102999. private _originalSceneAutoClear;
  103000. private _supported;
  103001. /**
  103002. * Creates the experience helper
  103003. * @param scene the scene to attach the experience helper to
  103004. * @returns a promise for the experience helper
  103005. */
  103006. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103007. /**
  103008. * Creates a WebXRExperienceHelper
  103009. * @param scene The scene the helper should be created in
  103010. */
  103011. private constructor();
  103012. /**
  103013. * Exits XR mode and returns the scene to its original state
  103014. * @returns promise that resolves after xr mode has exited
  103015. */
  103016. exitXRAsync(): Promise<void>;
  103017. /**
  103018. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103019. * @param sessionCreationOptions options for the XR session
  103020. * @param frameOfReference frame of reference of the XR session
  103021. * @returns promise that resolves after xr mode has entered
  103022. */
  103023. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  103024. /**
  103025. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103026. * @param ray ray to cast into the environment
  103027. * @returns Promise which resolves with a collision point in the environment if it exists
  103028. */
  103029. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103030. /**
  103031. * Updates the global position of the camera by moving the camera's container
  103032. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103033. * @param position The desired global position of the camera
  103034. */
  103035. setPositionOfCameraUsingContainer(position: Vector3): void;
  103036. /**
  103037. * Rotates the xr camera by rotating the camera's container around the camera's position
  103038. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103039. * @param rotation the desired quaternion rotation to apply to the camera
  103040. */
  103041. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103042. /**
  103043. * Checks if the creation options are supported by the xr session
  103044. * @param options creation options
  103045. * @returns true if supported
  103046. */
  103047. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103048. /**
  103049. * Disposes of the experience helper
  103050. */
  103051. dispose(): void;
  103052. }
  103053. }
  103054. declare module BABYLON {
  103055. /**
  103056. * Button which can be used to enter a different mode of XR
  103057. */
  103058. export class WebXREnterExitUIButton {
  103059. /** button element */
  103060. element: HTMLElement;
  103061. /** XR initialization options for the button */
  103062. initializationOptions: XRSessionCreationOptions;
  103063. /**
  103064. * Creates a WebXREnterExitUIButton
  103065. * @param element button element
  103066. * @param initializationOptions XR initialization options for the button
  103067. */
  103068. constructor(
  103069. /** button element */
  103070. element: HTMLElement,
  103071. /** XR initialization options for the button */
  103072. initializationOptions: XRSessionCreationOptions);
  103073. /**
  103074. * Overwritable function which can be used to update the button's visuals when the state changes
  103075. * @param activeButton the current active button in the UI
  103076. */
  103077. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103078. }
  103079. /**
  103080. * Options to create the webXR UI
  103081. */
  103082. export class WebXREnterExitUIOptions {
  103083. /**
  103084. * Context to enter xr with
  103085. */
  103086. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103087. /**
  103088. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103089. */
  103090. customButtons?: Array<WebXREnterExitUIButton>;
  103091. }
  103092. /**
  103093. * UI to allow the user to enter/exit XR mode
  103094. */
  103095. export class WebXREnterExitUI implements IDisposable {
  103096. private scene;
  103097. private _overlay;
  103098. private _buttons;
  103099. private _activeButton;
  103100. /**
  103101. * Fired every time the active button is changed.
  103102. *
  103103. * When xr is entered via a button that launches xr that button will be the callback parameter
  103104. *
  103105. * When exiting xr the callback parameter will be null)
  103106. */
  103107. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103108. /**
  103109. * Creates UI to allow the user to enter/exit XR mode
  103110. * @param scene the scene to add the ui to
  103111. * @param helper the xr experience helper to enter/exit xr with
  103112. * @param options options to configure the UI
  103113. * @returns the created ui
  103114. */
  103115. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103116. private constructor();
  103117. private _updateButtons;
  103118. /**
  103119. * Disposes of the object
  103120. */
  103121. dispose(): void;
  103122. }
  103123. }
  103124. declare module BABYLON {
  103125. /**
  103126. * Represents an XR input
  103127. */
  103128. export class WebXRController {
  103129. /**
  103130. * 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
  103131. */
  103132. grip?: AbstractMesh;
  103133. /**
  103134. * Pointer which can be used to select objects or attach a visible laser to
  103135. */
  103136. pointer: AbstractMesh;
  103137. /**
  103138. * Creates the controller
  103139. * @see https://doc.babylonjs.com/how_to/webxr
  103140. * @param scene the scene which the controller should be associated to
  103141. */
  103142. constructor(scene: Scene);
  103143. /**
  103144. * Disposes of the object
  103145. */
  103146. dispose(): void;
  103147. }
  103148. /**
  103149. * XR input used to track XR inputs such as controllers/rays
  103150. */
  103151. export class WebXRInput implements IDisposable {
  103152. private helper;
  103153. /**
  103154. * XR controllers being tracked
  103155. */
  103156. controllers: Array<WebXRController>;
  103157. private _tmpMatrix;
  103158. private _frameObserver;
  103159. /**
  103160. * Initializes the WebXRInput
  103161. * @param helper experience helper which the input should be created for
  103162. */
  103163. constructor(helper: WebXRExperienceHelper);
  103164. /**
  103165. * Disposes of the object
  103166. */
  103167. dispose(): void;
  103168. }
  103169. }
  103170. declare module BABYLON {
  103171. /**
  103172. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103173. */
  103174. export class WebXRManagedOutputCanvas implements IDisposable {
  103175. private _canvas;
  103176. /**
  103177. * xrpresent context of the canvas which can be used to display/mirror xr content
  103178. */
  103179. canvasContext: Nullable<WebGLRenderingContext>;
  103180. /**
  103181. * Initializes the canvas to be added/removed upon entering/exiting xr
  103182. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103183. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103184. */
  103185. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103186. /**
  103187. * Disposes of the object
  103188. */
  103189. dispose(): void;
  103190. private _setManagedOutputCanvas;
  103191. private _addCanvas;
  103192. private _removeCanvas;
  103193. }
  103194. }
  103195. declare module BABYLON {
  103196. /**
  103197. * Contains an array of blocks representing the octree
  103198. */
  103199. export interface IOctreeContainer<T> {
  103200. /**
  103201. * Blocks within the octree
  103202. */
  103203. blocks: Array<OctreeBlock<T>>;
  103204. }
  103205. /**
  103206. * Class used to store a cell in an octree
  103207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103208. */
  103209. export class OctreeBlock<T> {
  103210. /**
  103211. * Gets the content of the current block
  103212. */
  103213. entries: T[];
  103214. /**
  103215. * Gets the list of block children
  103216. */
  103217. blocks: Array<OctreeBlock<T>>;
  103218. private _depth;
  103219. private _maxDepth;
  103220. private _capacity;
  103221. private _minPoint;
  103222. private _maxPoint;
  103223. private _boundingVectors;
  103224. private _creationFunc;
  103225. /**
  103226. * Creates a new block
  103227. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103228. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103229. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103230. * @param depth defines the current depth of this block in the octree
  103231. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103232. * @param creationFunc defines a callback to call when an element is added to the block
  103233. */
  103234. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103235. /**
  103236. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103237. */
  103238. readonly capacity: number;
  103239. /**
  103240. * Gets the minimum vector (in world space) of the block's bounding box
  103241. */
  103242. readonly minPoint: Vector3;
  103243. /**
  103244. * Gets the maximum vector (in world space) of the block's bounding box
  103245. */
  103246. readonly maxPoint: Vector3;
  103247. /**
  103248. * Add a new element to this block
  103249. * @param entry defines the element to add
  103250. */
  103251. addEntry(entry: T): void;
  103252. /**
  103253. * Remove an element from this block
  103254. * @param entry defines the element to remove
  103255. */
  103256. removeEntry(entry: T): void;
  103257. /**
  103258. * Add an array of elements to this block
  103259. * @param entries defines the array of elements to add
  103260. */
  103261. addEntries(entries: T[]): void;
  103262. /**
  103263. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103264. * @param frustumPlanes defines the frustum planes to test
  103265. * @param selection defines the array to store current content if selection is positive
  103266. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103267. */
  103268. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103269. /**
  103270. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103271. * @param sphereCenter defines the bounding sphere center
  103272. * @param sphereRadius defines the bounding sphere radius
  103273. * @param selection defines the array to store current content if selection is positive
  103274. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103275. */
  103276. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103277. /**
  103278. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103279. * @param ray defines the ray to test with
  103280. * @param selection defines the array to store current content if selection is positive
  103281. */
  103282. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103283. /**
  103284. * Subdivide the content into child blocks (this block will then be empty)
  103285. */
  103286. createInnerBlocks(): void;
  103287. /**
  103288. * @hidden
  103289. */
  103290. 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;
  103291. }
  103292. }
  103293. declare module BABYLON {
  103294. /**
  103295. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103297. */
  103298. export class Octree<T> {
  103299. /** 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.) */
  103300. maxDepth: number;
  103301. /**
  103302. * Blocks within the octree containing objects
  103303. */
  103304. blocks: Array<OctreeBlock<T>>;
  103305. /**
  103306. * Content stored in the octree
  103307. */
  103308. dynamicContent: T[];
  103309. private _maxBlockCapacity;
  103310. private _selectionContent;
  103311. private _creationFunc;
  103312. /**
  103313. * Creates a octree
  103314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103315. * @param creationFunc function to be used to instatiate the octree
  103316. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103317. * @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.)
  103318. */
  103319. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103320. /** 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.) */
  103321. maxDepth?: number);
  103322. /**
  103323. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103324. * @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);
  103325. * @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);
  103326. * @param entries meshes to be added to the octree blocks
  103327. */
  103328. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103329. /**
  103330. * Adds a mesh to the octree
  103331. * @param entry Mesh to add to the octree
  103332. */
  103333. addMesh(entry: T): void;
  103334. /**
  103335. * Remove an element from the octree
  103336. * @param entry defines the element to remove
  103337. */
  103338. removeMesh(entry: T): void;
  103339. /**
  103340. * Selects an array of meshes within the frustum
  103341. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103342. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103343. * @returns array of meshes within the frustum
  103344. */
  103345. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103346. /**
  103347. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103348. * @param sphereCenter defines the bounding sphere center
  103349. * @param sphereRadius defines the bounding sphere radius
  103350. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103351. * @returns an array of objects that intersect the sphere
  103352. */
  103353. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103354. /**
  103355. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103356. * @param ray defines the ray to test with
  103357. * @returns array of intersected objects
  103358. */
  103359. intersectsRay(ray: Ray): SmartArray<T>;
  103360. /**
  103361. * Adds a mesh into the octree block if it intersects the block
  103362. */
  103363. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103364. /**
  103365. * Adds a submesh into the octree block if it intersects the block
  103366. */
  103367. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103368. }
  103369. }
  103370. declare module BABYLON {
  103371. interface Scene {
  103372. /**
  103373. * @hidden
  103374. * Backing Filed
  103375. */
  103376. _selectionOctree: Octree<AbstractMesh>;
  103377. /**
  103378. * Gets the octree used to boost mesh selection (picking)
  103379. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103380. */
  103381. selectionOctree: Octree<AbstractMesh>;
  103382. /**
  103383. * Creates or updates the octree used to boost selection (picking)
  103384. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103385. * @param maxCapacity defines the maximum capacity per leaf
  103386. * @param maxDepth defines the maximum depth of the octree
  103387. * @returns an octree of AbstractMesh
  103388. */
  103389. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103390. }
  103391. interface AbstractMesh {
  103392. /**
  103393. * @hidden
  103394. * Backing Field
  103395. */
  103396. _submeshesOctree: Octree<SubMesh>;
  103397. /**
  103398. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103399. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103400. * @param maxCapacity defines the maximum size of each block (64 by default)
  103401. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103402. * @returns the new octree
  103403. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103405. */
  103406. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103407. }
  103408. /**
  103409. * Defines the octree scene component responsible to manage any octrees
  103410. * in a given scene.
  103411. */
  103412. export class OctreeSceneComponent {
  103413. /**
  103414. * The component name help to identify the component in the list of scene components.
  103415. */
  103416. readonly name: string;
  103417. /**
  103418. * The scene the component belongs to.
  103419. */
  103420. scene: Scene;
  103421. /**
  103422. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103423. */
  103424. readonly checksIsEnabled: boolean;
  103425. /**
  103426. * Creates a new instance of the component for the given scene
  103427. * @param scene Defines the scene to register the component in
  103428. */
  103429. constructor(scene: Scene);
  103430. /**
  103431. * Registers the component in a given scene
  103432. */
  103433. register(): void;
  103434. /**
  103435. * Return the list of active meshes
  103436. * @returns the list of active meshes
  103437. */
  103438. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103439. /**
  103440. * Return the list of active sub meshes
  103441. * @param mesh The mesh to get the candidates sub meshes from
  103442. * @returns the list of active sub meshes
  103443. */
  103444. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103445. private _tempRay;
  103446. /**
  103447. * Return the list of sub meshes intersecting with a given local ray
  103448. * @param mesh defines the mesh to find the submesh for
  103449. * @param localRay defines the ray in local space
  103450. * @returns the list of intersecting sub meshes
  103451. */
  103452. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103453. /**
  103454. * Return the list of sub meshes colliding with a collider
  103455. * @param mesh defines the mesh to find the submesh for
  103456. * @param collider defines the collider to evaluate the collision against
  103457. * @returns the list of colliding sub meshes
  103458. */
  103459. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103460. /**
  103461. * Rebuilds the elements related to this component in case of
  103462. * context lost for instance.
  103463. */
  103464. rebuild(): void;
  103465. /**
  103466. * Disposes the component and the associated ressources.
  103467. */
  103468. dispose(): void;
  103469. }
  103470. }
  103471. declare module BABYLON {
  103472. /**
  103473. * Renders a layer on top of an existing scene
  103474. */
  103475. export class UtilityLayerRenderer implements IDisposable {
  103476. /** the original scene that will be rendered on top of */
  103477. originalScene: Scene;
  103478. private _pointerCaptures;
  103479. private _lastPointerEvents;
  103480. private static _DefaultUtilityLayer;
  103481. private static _DefaultKeepDepthUtilityLayer;
  103482. private _sharedGizmoLight;
  103483. private _renderCamera;
  103484. /**
  103485. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103486. * @returns the camera that is used when rendering the utility layer
  103487. */
  103488. getRenderCamera(): Nullable<Camera>;
  103489. /**
  103490. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103491. * @param cam the camera that should be used when rendering the utility layer
  103492. */
  103493. setRenderCamera(cam: Nullable<Camera>): void;
  103494. /**
  103495. * @hidden
  103496. * Light which used by gizmos to get light shading
  103497. */
  103498. _getSharedGizmoLight(): HemisphericLight;
  103499. /**
  103500. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103501. */
  103502. pickUtilitySceneFirst: boolean;
  103503. /**
  103504. * 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)
  103505. */
  103506. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103507. /**
  103508. * 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)
  103509. */
  103510. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103511. /**
  103512. * The scene that is rendered on top of the original scene
  103513. */
  103514. utilityLayerScene: Scene;
  103515. /**
  103516. * If the utility layer should automatically be rendered on top of existing scene
  103517. */
  103518. shouldRender: boolean;
  103519. /**
  103520. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103521. */
  103522. onlyCheckPointerDownEvents: boolean;
  103523. /**
  103524. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103525. */
  103526. processAllEvents: boolean;
  103527. /**
  103528. * Observable raised when the pointer move from the utility layer scene to the main scene
  103529. */
  103530. onPointerOutObservable: Observable<number>;
  103531. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103532. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103533. private _afterRenderObserver;
  103534. private _sceneDisposeObserver;
  103535. private _originalPointerObserver;
  103536. /**
  103537. * Instantiates a UtilityLayerRenderer
  103538. * @param originalScene the original scene that will be rendered on top of
  103539. * @param handleEvents boolean indicating if the utility layer should handle events
  103540. */
  103541. constructor(
  103542. /** the original scene that will be rendered on top of */
  103543. originalScene: Scene, handleEvents?: boolean);
  103544. private _notifyObservers;
  103545. /**
  103546. * Renders the utility layers scene on top of the original scene
  103547. */
  103548. render(): void;
  103549. /**
  103550. * Disposes of the renderer
  103551. */
  103552. dispose(): void;
  103553. private _updateCamera;
  103554. }
  103555. }
  103556. declare module BABYLON {
  103557. /**
  103558. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103559. */
  103560. export class Gizmo implements IDisposable {
  103561. /** The utility layer the gizmo will be added to */
  103562. gizmoLayer: UtilityLayerRenderer;
  103563. /**
  103564. * The root mesh of the gizmo
  103565. */
  103566. _rootMesh: Mesh;
  103567. private _attachedMesh;
  103568. /**
  103569. * Ratio for the scale of the gizmo (Default: 1)
  103570. */
  103571. scaleRatio: number;
  103572. /**
  103573. * If a custom mesh has been set (Default: false)
  103574. */
  103575. protected _customMeshSet: boolean;
  103576. /**
  103577. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103578. * * When set, interactions will be enabled
  103579. */
  103580. attachedMesh: Nullable<AbstractMesh>;
  103581. /**
  103582. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103583. * @param mesh The mesh to replace the default mesh of the gizmo
  103584. */
  103585. setCustomMesh(mesh: Mesh): void;
  103586. /**
  103587. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103588. */
  103589. updateGizmoRotationToMatchAttachedMesh: boolean;
  103590. /**
  103591. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103592. */
  103593. updateGizmoPositionToMatchAttachedMesh: boolean;
  103594. /**
  103595. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103596. */
  103597. protected _updateScale: boolean;
  103598. protected _interactionsEnabled: boolean;
  103599. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103600. private _beforeRenderObserver;
  103601. private _tempVector;
  103602. /**
  103603. * Creates a gizmo
  103604. * @param gizmoLayer The utility layer the gizmo will be added to
  103605. */
  103606. constructor(
  103607. /** The utility layer the gizmo will be added to */
  103608. gizmoLayer?: UtilityLayerRenderer);
  103609. /**
  103610. * Updates the gizmo to match the attached mesh's position/rotation
  103611. */
  103612. protected _update(): void;
  103613. /**
  103614. * Disposes of the gizmo
  103615. */
  103616. dispose(): void;
  103617. }
  103618. }
  103619. declare module BABYLON {
  103620. /**
  103621. * Single plane drag gizmo
  103622. */
  103623. export class PlaneDragGizmo extends Gizmo {
  103624. /**
  103625. * Drag behavior responsible for the gizmos dragging interactions
  103626. */
  103627. dragBehavior: PointerDragBehavior;
  103628. private _pointerObserver;
  103629. /**
  103630. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103631. */
  103632. snapDistance: number;
  103633. /**
  103634. * Event that fires each time the gizmo snaps to a new location.
  103635. * * snapDistance is the the change in distance
  103636. */
  103637. onSnapObservable: Observable<{
  103638. snapDistance: number;
  103639. }>;
  103640. private _plane;
  103641. private _coloredMaterial;
  103642. private _hoverMaterial;
  103643. private _isEnabled;
  103644. private _parent;
  103645. /** @hidden */
  103646. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103647. /** @hidden */
  103648. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103649. /**
  103650. * Creates a PlaneDragGizmo
  103651. * @param gizmoLayer The utility layer the gizmo will be added to
  103652. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103653. * @param color The color of the gizmo
  103654. */
  103655. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103656. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103657. /**
  103658. * If the gizmo is enabled
  103659. */
  103660. isEnabled: boolean;
  103661. /**
  103662. * Disposes of the gizmo
  103663. */
  103664. dispose(): void;
  103665. }
  103666. }
  103667. declare module BABYLON {
  103668. /**
  103669. * Gizmo that enables dragging a mesh along 3 axis
  103670. */
  103671. export class PositionGizmo extends Gizmo {
  103672. /**
  103673. * Internal gizmo used for interactions on the x axis
  103674. */
  103675. xGizmo: AxisDragGizmo;
  103676. /**
  103677. * Internal gizmo used for interactions on the y axis
  103678. */
  103679. yGizmo: AxisDragGizmo;
  103680. /**
  103681. * Internal gizmo used for interactions on the z axis
  103682. */
  103683. zGizmo: AxisDragGizmo;
  103684. /**
  103685. * Internal gizmo used for interactions on the yz plane
  103686. */
  103687. xPlaneGizmo: PlaneDragGizmo;
  103688. /**
  103689. * Internal gizmo used for interactions on the xz plane
  103690. */
  103691. yPlaneGizmo: PlaneDragGizmo;
  103692. /**
  103693. * Internal gizmo used for interactions on the xy plane
  103694. */
  103695. zPlaneGizmo: PlaneDragGizmo;
  103696. /**
  103697. * private variables
  103698. */
  103699. private _meshAttached;
  103700. private _updateGizmoRotationToMatchAttachedMesh;
  103701. private _snapDistance;
  103702. private _scaleRatio;
  103703. /** Fires an event when any of it's sub gizmos are dragged */
  103704. onDragStartObservable: Observable<{}>;
  103705. /** Fires an event when any of it's sub gizmos are released from dragging */
  103706. onDragEndObservable: Observable<{}>;
  103707. /**
  103708. * If set to true, planar drag is enabled
  103709. */
  103710. private _planarGizmoEnabled;
  103711. attachedMesh: Nullable<AbstractMesh>;
  103712. /**
  103713. * Creates a PositionGizmo
  103714. * @param gizmoLayer The utility layer the gizmo will be added to
  103715. */
  103716. constructor(gizmoLayer?: UtilityLayerRenderer);
  103717. /**
  103718. * If the planar drag gizmo is enabled
  103719. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103720. */
  103721. planarGizmoEnabled: boolean;
  103722. updateGizmoRotationToMatchAttachedMesh: boolean;
  103723. /**
  103724. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103725. */
  103726. snapDistance: number;
  103727. /**
  103728. * Ratio for the scale of the gizmo (Default: 1)
  103729. */
  103730. scaleRatio: number;
  103731. /**
  103732. * Disposes of the gizmo
  103733. */
  103734. dispose(): void;
  103735. /**
  103736. * CustomMeshes are not supported by this gizmo
  103737. * @param mesh The mesh to replace the default mesh of the gizmo
  103738. */
  103739. setCustomMesh(mesh: Mesh): void;
  103740. }
  103741. }
  103742. declare module BABYLON {
  103743. /**
  103744. * Single axis drag gizmo
  103745. */
  103746. export class AxisDragGizmo extends Gizmo {
  103747. /**
  103748. * Drag behavior responsible for the gizmos dragging interactions
  103749. */
  103750. dragBehavior: PointerDragBehavior;
  103751. private _pointerObserver;
  103752. /**
  103753. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103754. */
  103755. snapDistance: number;
  103756. /**
  103757. * Event that fires each time the gizmo snaps to a new location.
  103758. * * snapDistance is the the change in distance
  103759. */
  103760. onSnapObservable: Observable<{
  103761. snapDistance: number;
  103762. }>;
  103763. private _isEnabled;
  103764. private _parent;
  103765. private _arrow;
  103766. private _coloredMaterial;
  103767. private _hoverMaterial;
  103768. /** @hidden */
  103769. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  103770. /** @hidden */
  103771. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103772. /**
  103773. * Creates an AxisDragGizmo
  103774. * @param gizmoLayer The utility layer the gizmo will be added to
  103775. * @param dragAxis The axis which the gizmo will be able to drag on
  103776. * @param color The color of the gizmo
  103777. */
  103778. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103779. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103780. /**
  103781. * If the gizmo is enabled
  103782. */
  103783. isEnabled: boolean;
  103784. /**
  103785. * Disposes of the gizmo
  103786. */
  103787. dispose(): void;
  103788. }
  103789. }
  103790. declare module BABYLON.Debug {
  103791. /**
  103792. * The Axes viewer will show 3 axes in a specific point in space
  103793. */
  103794. export class AxesViewer {
  103795. private _xAxis;
  103796. private _yAxis;
  103797. private _zAxis;
  103798. private _scaleLinesFactor;
  103799. private _instanced;
  103800. /**
  103801. * Gets the hosting scene
  103802. */
  103803. scene: Scene;
  103804. /**
  103805. * Gets or sets a number used to scale line length
  103806. */
  103807. scaleLines: number;
  103808. /** Gets the node hierarchy used to render x-axis */
  103809. readonly xAxis: TransformNode;
  103810. /** Gets the node hierarchy used to render y-axis */
  103811. readonly yAxis: TransformNode;
  103812. /** Gets the node hierarchy used to render z-axis */
  103813. readonly zAxis: TransformNode;
  103814. /**
  103815. * Creates a new AxesViewer
  103816. * @param scene defines the hosting scene
  103817. * @param scaleLines defines a number used to scale line length (1 by default)
  103818. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  103819. * @param xAxis defines the node hierarchy used to render the x-axis
  103820. * @param yAxis defines the node hierarchy used to render the y-axis
  103821. * @param zAxis defines the node hierarchy used to render the z-axis
  103822. */
  103823. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  103824. /**
  103825. * Force the viewer to update
  103826. * @param position defines the position of the viewer
  103827. * @param xaxis defines the x axis of the viewer
  103828. * @param yaxis defines the y axis of the viewer
  103829. * @param zaxis defines the z axis of the viewer
  103830. */
  103831. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  103832. /**
  103833. * Creates an instance of this axes viewer.
  103834. * @returns a new axes viewer with instanced meshes
  103835. */
  103836. createInstance(): AxesViewer;
  103837. /** Releases resources */
  103838. dispose(): void;
  103839. private static _SetRenderingGroupId;
  103840. }
  103841. }
  103842. declare module BABYLON.Debug {
  103843. /**
  103844. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  103845. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  103846. */
  103847. export class BoneAxesViewer extends AxesViewer {
  103848. /**
  103849. * Gets or sets the target mesh where to display the axes viewer
  103850. */
  103851. mesh: Nullable<Mesh>;
  103852. /**
  103853. * Gets or sets the target bone where to display the axes viewer
  103854. */
  103855. bone: Nullable<Bone>;
  103856. /** Gets current position */
  103857. pos: Vector3;
  103858. /** Gets direction of X axis */
  103859. xaxis: Vector3;
  103860. /** Gets direction of Y axis */
  103861. yaxis: Vector3;
  103862. /** Gets direction of Z axis */
  103863. zaxis: Vector3;
  103864. /**
  103865. * Creates a new BoneAxesViewer
  103866. * @param scene defines the hosting scene
  103867. * @param bone defines the target bone
  103868. * @param mesh defines the target mesh
  103869. * @param scaleLines defines a scaling factor for line length (1 by default)
  103870. */
  103871. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  103872. /**
  103873. * Force the viewer to update
  103874. */
  103875. update(): void;
  103876. /** Releases resources */
  103877. dispose(): void;
  103878. }
  103879. }
  103880. declare module BABYLON {
  103881. /**
  103882. * Interface used to define scene explorer extensibility option
  103883. */
  103884. export interface IExplorerExtensibilityOption {
  103885. /**
  103886. * Define the option label
  103887. */
  103888. label: string;
  103889. /**
  103890. * Defines the action to execute on click
  103891. */
  103892. action: (entity: any) => void;
  103893. }
  103894. /**
  103895. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  103896. */
  103897. export interface IExplorerExtensibilityGroup {
  103898. /**
  103899. * Defines a predicate to test if a given type mut be extended
  103900. */
  103901. predicate: (entity: any) => boolean;
  103902. /**
  103903. * Gets the list of options added to a type
  103904. */
  103905. entries: IExplorerExtensibilityOption[];
  103906. }
  103907. /**
  103908. * Interface used to define the options to use to create the Inspector
  103909. */
  103910. export interface IInspectorOptions {
  103911. /**
  103912. * Display in overlay mode (default: false)
  103913. */
  103914. overlay?: boolean;
  103915. /**
  103916. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  103917. */
  103918. globalRoot?: HTMLElement;
  103919. /**
  103920. * Display the Scene explorer
  103921. */
  103922. showExplorer?: boolean;
  103923. /**
  103924. * Display the property inspector
  103925. */
  103926. showInspector?: boolean;
  103927. /**
  103928. * Display in embed mode (both panes on the right)
  103929. */
  103930. embedMode?: boolean;
  103931. /**
  103932. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  103933. */
  103934. handleResize?: boolean;
  103935. /**
  103936. * Allow the panes to popup (default: true)
  103937. */
  103938. enablePopup?: boolean;
  103939. /**
  103940. * Allow the panes to be closed by users (default: true)
  103941. */
  103942. enableClose?: boolean;
  103943. /**
  103944. * Optional list of extensibility entries
  103945. */
  103946. explorerExtensibility?: IExplorerExtensibilityGroup[];
  103947. /**
  103948. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  103949. */
  103950. inspectorURL?: string;
  103951. }
  103952. interface Scene {
  103953. /**
  103954. * @hidden
  103955. * Backing field
  103956. */
  103957. _debugLayer: DebugLayer;
  103958. /**
  103959. * Gets the debug layer (aka Inspector) associated with the scene
  103960. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103961. */
  103962. debugLayer: DebugLayer;
  103963. }
  103964. /**
  103965. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103966. * what is happening in your scene
  103967. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103968. */
  103969. export class DebugLayer {
  103970. /**
  103971. * Define the url to get the inspector script from.
  103972. * By default it uses the babylonjs CDN.
  103973. * @ignoreNaming
  103974. */
  103975. static InspectorURL: string;
  103976. private _scene;
  103977. private BJSINSPECTOR;
  103978. /**
  103979. * Observable triggered when a property is changed through the inspector.
  103980. */
  103981. onPropertyChangedObservable: Observable<{
  103982. object: any;
  103983. property: string;
  103984. value: any;
  103985. initialValue: any;
  103986. }>;
  103987. /**
  103988. * Instantiates a new debug layer.
  103989. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103990. * what is happening in your scene
  103991. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103992. * @param scene Defines the scene to inspect
  103993. */
  103994. constructor(scene: Scene);
  103995. /** Creates the inspector window. */
  103996. private _createInspector;
  103997. /**
  103998. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  103999. * @param entity defines the entity to select
  104000. * @param lineContainerTitle defines the specific block to highlight
  104001. */
  104002. select(entity: any, lineContainerTitle?: string): void;
  104003. /** Get the inspector from bundle or global */
  104004. private _getGlobalInspector;
  104005. /**
  104006. * Get if the inspector is visible or not.
  104007. * @returns true if visible otherwise, false
  104008. */
  104009. isVisible(): boolean;
  104010. /**
  104011. * Hide the inspector and close its window.
  104012. */
  104013. hide(): void;
  104014. /**
  104015. * Launch the debugLayer.
  104016. * @param config Define the configuration of the inspector
  104017. * @return a promise fulfilled when the debug layer is visible
  104018. */
  104019. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104020. }
  104021. }
  104022. declare module BABYLON {
  104023. /**
  104024. * Class containing static functions to help procedurally build meshes
  104025. */
  104026. export class BoxBuilder {
  104027. /**
  104028. * Creates a box mesh
  104029. * * The parameter `size` sets the size (float) of each box side (default 1)
  104030. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104031. * * 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)
  104032. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104036. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104037. * @param name defines the name of the mesh
  104038. * @param options defines the options used to create the mesh
  104039. * @param scene defines the hosting scene
  104040. * @returns the box mesh
  104041. */
  104042. static CreateBox(name: string, options: {
  104043. size?: number;
  104044. width?: number;
  104045. height?: number;
  104046. depth?: number;
  104047. faceUV?: Vector4[];
  104048. faceColors?: Color4[];
  104049. sideOrientation?: number;
  104050. frontUVs?: Vector4;
  104051. backUVs?: Vector4;
  104052. wrap?: boolean;
  104053. topBaseAt?: number;
  104054. bottomBaseAt?: number;
  104055. updatable?: boolean;
  104056. }, scene?: Nullable<Scene>): Mesh;
  104057. }
  104058. }
  104059. declare module BABYLON {
  104060. /**
  104061. * Class containing static functions to help procedurally build meshes
  104062. */
  104063. export class SphereBuilder {
  104064. /**
  104065. * Creates a sphere mesh
  104066. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104067. * * 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`)
  104068. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104069. * * 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
  104070. * * 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)
  104071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104074. * @param name defines the name of the mesh
  104075. * @param options defines the options used to create the mesh
  104076. * @param scene defines the hosting scene
  104077. * @returns the sphere mesh
  104078. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104079. */
  104080. static CreateSphere(name: string, options: {
  104081. segments?: number;
  104082. diameter?: number;
  104083. diameterX?: number;
  104084. diameterY?: number;
  104085. diameterZ?: number;
  104086. arc?: number;
  104087. slice?: number;
  104088. sideOrientation?: number;
  104089. frontUVs?: Vector4;
  104090. backUVs?: Vector4;
  104091. updatable?: boolean;
  104092. }, scene: any): Mesh;
  104093. }
  104094. }
  104095. declare module BABYLON.Debug {
  104096. /**
  104097. * Used to show the physics impostor around the specific mesh
  104098. */
  104099. export class PhysicsViewer {
  104100. /** @hidden */
  104101. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104102. /** @hidden */
  104103. protected _meshes: Array<Nullable<AbstractMesh>>;
  104104. /** @hidden */
  104105. protected _scene: Nullable<Scene>;
  104106. /** @hidden */
  104107. protected _numMeshes: number;
  104108. /** @hidden */
  104109. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104110. private _renderFunction;
  104111. private _utilityLayer;
  104112. private _debugBoxMesh;
  104113. private _debugSphereMesh;
  104114. private _debugCylinderMesh;
  104115. private _debugMaterial;
  104116. private _debugMeshMeshes;
  104117. /**
  104118. * Creates a new PhysicsViewer
  104119. * @param scene defines the hosting scene
  104120. */
  104121. constructor(scene: Scene);
  104122. /** @hidden */
  104123. protected _updateDebugMeshes(): void;
  104124. /**
  104125. * Renders a specified physic impostor
  104126. * @param impostor defines the impostor to render
  104127. * @param targetMesh defines the mesh represented by the impostor
  104128. * @returns the new debug mesh used to render the impostor
  104129. */
  104130. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104131. /**
  104132. * Hides a specified physic impostor
  104133. * @param impostor defines the impostor to hide
  104134. */
  104135. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104136. private _getDebugMaterial;
  104137. private _getDebugBoxMesh;
  104138. private _getDebugSphereMesh;
  104139. private _getDebugCylinderMesh;
  104140. private _getDebugMeshMesh;
  104141. private _getDebugMesh;
  104142. /** Releases all resources */
  104143. dispose(): void;
  104144. }
  104145. }
  104146. declare module BABYLON {
  104147. /**
  104148. * Class containing static functions to help procedurally build meshes
  104149. */
  104150. export class LinesBuilder {
  104151. /**
  104152. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104153. * * 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
  104154. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104155. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104156. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104157. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104158. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104159. * * 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
  104160. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104162. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104163. * @param name defines the name of the new line system
  104164. * @param options defines the options used to create the line system
  104165. * @param scene defines the hosting scene
  104166. * @returns a new line system mesh
  104167. */
  104168. static CreateLineSystem(name: string, options: {
  104169. lines: Vector3[][];
  104170. updatable?: boolean;
  104171. instance?: Nullable<LinesMesh>;
  104172. colors?: Nullable<Color4[][]>;
  104173. useVertexAlpha?: boolean;
  104174. }, scene: Nullable<Scene>): LinesMesh;
  104175. /**
  104176. * Creates a line mesh
  104177. * 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
  104178. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104179. * * The parameter `points` is an array successive Vector3
  104180. * * 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
  104181. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104182. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104183. * * When updating an instance, remember that only point positions can change, not the number of points
  104184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104186. * @param name defines the name of the new line system
  104187. * @param options defines the options used to create the line system
  104188. * @param scene defines the hosting scene
  104189. * @returns a new line mesh
  104190. */
  104191. static CreateLines(name: string, options: {
  104192. points: Vector3[];
  104193. updatable?: boolean;
  104194. instance?: Nullable<LinesMesh>;
  104195. colors?: Color4[];
  104196. useVertexAlpha?: boolean;
  104197. }, scene?: Nullable<Scene>): LinesMesh;
  104198. /**
  104199. * Creates a dashed line mesh
  104200. * * 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
  104201. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104202. * * The parameter `points` is an array successive Vector3
  104203. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104204. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104205. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104206. * * 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
  104207. * * When updating an instance, remember that only point positions can change, not the number of points
  104208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104209. * @param name defines the name of the mesh
  104210. * @param options defines the options used to create the mesh
  104211. * @param scene defines the hosting scene
  104212. * @returns the dashed line mesh
  104213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104214. */
  104215. static CreateDashedLines(name: string, options: {
  104216. points: Vector3[];
  104217. dashSize?: number;
  104218. gapSize?: number;
  104219. dashNb?: number;
  104220. updatable?: boolean;
  104221. instance?: LinesMesh;
  104222. }, scene?: Nullable<Scene>): LinesMesh;
  104223. }
  104224. }
  104225. declare module BABYLON {
  104226. /**
  104227. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104228. * in order to better appreciate the issue one might have.
  104229. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104230. */
  104231. export class RayHelper {
  104232. /**
  104233. * Defines the ray we are currently tryin to visualize.
  104234. */
  104235. ray: Nullable<Ray>;
  104236. private _renderPoints;
  104237. private _renderLine;
  104238. private _renderFunction;
  104239. private _scene;
  104240. private _updateToMeshFunction;
  104241. private _attachedToMesh;
  104242. private _meshSpaceDirection;
  104243. private _meshSpaceOrigin;
  104244. /**
  104245. * Helper function to create a colored helper in a scene in one line.
  104246. * @param ray Defines the ray we are currently tryin to visualize
  104247. * @param scene Defines the scene the ray is used in
  104248. * @param color Defines the color we want to see the ray in
  104249. * @returns The newly created ray helper.
  104250. */
  104251. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104252. /**
  104253. * Instantiate a new ray helper.
  104254. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104255. * in order to better appreciate the issue one might have.
  104256. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104257. * @param ray Defines the ray we are currently tryin to visualize
  104258. */
  104259. constructor(ray: Ray);
  104260. /**
  104261. * Shows the ray we are willing to debug.
  104262. * @param scene Defines the scene the ray needs to be rendered in
  104263. * @param color Defines the color the ray needs to be rendered in
  104264. */
  104265. show(scene: Scene, color?: Color3): void;
  104266. /**
  104267. * Hides the ray we are debugging.
  104268. */
  104269. hide(): void;
  104270. private _render;
  104271. /**
  104272. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104273. * @param mesh Defines the mesh we want the helper attached to
  104274. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104275. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104276. * @param length Defines the length of the ray
  104277. */
  104278. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104279. /**
  104280. * Detach the ray helper from the mesh it has previously been attached to.
  104281. */
  104282. detachFromMesh(): void;
  104283. private _updateToMesh;
  104284. /**
  104285. * Dispose the helper and release its associated resources.
  104286. */
  104287. dispose(): void;
  104288. }
  104289. }
  104290. declare module BABYLON.Debug {
  104291. /**
  104292. * Class used to render a debug view of a given skeleton
  104293. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104294. */
  104295. export class SkeletonViewer {
  104296. /** defines the skeleton to render */
  104297. skeleton: Skeleton;
  104298. /** defines the mesh attached to the skeleton */
  104299. mesh: AbstractMesh;
  104300. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104301. autoUpdateBonesMatrices: boolean;
  104302. /** defines the rendering group id to use with the viewer */
  104303. renderingGroupId: number;
  104304. /** Gets or sets the color used to render the skeleton */
  104305. color: Color3;
  104306. private _scene;
  104307. private _debugLines;
  104308. private _debugMesh;
  104309. private _isEnabled;
  104310. private _renderFunction;
  104311. private _utilityLayer;
  104312. /**
  104313. * Returns the mesh used to render the bones
  104314. */
  104315. readonly debugMesh: Nullable<LinesMesh>;
  104316. /**
  104317. * Creates a new SkeletonViewer
  104318. * @param skeleton defines the skeleton to render
  104319. * @param mesh defines the mesh attached to the skeleton
  104320. * @param scene defines the hosting scene
  104321. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104322. * @param renderingGroupId defines the rendering group id to use with the viewer
  104323. */
  104324. constructor(
  104325. /** defines the skeleton to render */
  104326. skeleton: Skeleton,
  104327. /** defines the mesh attached to the skeleton */
  104328. mesh: AbstractMesh, scene: Scene,
  104329. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104330. autoUpdateBonesMatrices?: boolean,
  104331. /** defines the rendering group id to use with the viewer */
  104332. renderingGroupId?: number);
  104333. /** Gets or sets a boolean indicating if the viewer is enabled */
  104334. isEnabled: boolean;
  104335. private _getBonePosition;
  104336. private _getLinesForBonesWithLength;
  104337. private _getLinesForBonesNoLength;
  104338. /** Update the viewer to sync with current skeleton state */
  104339. update(): void;
  104340. /** Release associated resources */
  104341. dispose(): void;
  104342. }
  104343. }
  104344. declare module BABYLON {
  104345. /**
  104346. * Options to create the null engine
  104347. */
  104348. export class NullEngineOptions {
  104349. /**
  104350. * Render width (Default: 512)
  104351. */
  104352. renderWidth: number;
  104353. /**
  104354. * Render height (Default: 256)
  104355. */
  104356. renderHeight: number;
  104357. /**
  104358. * Texture size (Default: 512)
  104359. */
  104360. textureSize: number;
  104361. /**
  104362. * If delta time between frames should be constant
  104363. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104364. */
  104365. deterministicLockstep: boolean;
  104366. /**
  104367. * Maximum about of steps between frames (Default: 4)
  104368. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104369. */
  104370. lockstepMaxSteps: number;
  104371. }
  104372. /**
  104373. * The null engine class provides support for headless version of babylon.js.
  104374. * This can be used in server side scenario or for testing purposes
  104375. */
  104376. export class NullEngine extends Engine {
  104377. private _options;
  104378. /**
  104379. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104380. */
  104381. isDeterministicLockStep(): boolean;
  104382. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104383. getLockstepMaxSteps(): number;
  104384. /**
  104385. * Sets hardware scaling, used to save performance if needed
  104386. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104387. */
  104388. getHardwareScalingLevel(): number;
  104389. constructor(options?: NullEngineOptions);
  104390. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104391. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104392. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104393. getRenderWidth(useScreen?: boolean): number;
  104394. getRenderHeight(useScreen?: boolean): number;
  104395. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104396. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104397. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104398. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104399. bindSamplers(effect: Effect): void;
  104400. enableEffect(effect: Effect): void;
  104401. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104402. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104403. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104404. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104405. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104406. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104407. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104408. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104409. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104410. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104411. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104412. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104413. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104414. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104415. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104416. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104417. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104418. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104419. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104420. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104421. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104422. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104423. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104424. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104425. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104426. bindBuffers(vertexBuffers: {
  104427. [key: string]: VertexBuffer;
  104428. }, indexBuffer: DataBuffer, effect: Effect): void;
  104429. wipeCaches(bruteForce?: boolean): void;
  104430. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104431. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104432. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104433. /** @hidden */
  104434. _createTexture(): WebGLTexture;
  104435. /** @hidden */
  104436. _releaseTexture(texture: InternalTexture): void;
  104437. 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;
  104438. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104439. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104440. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104441. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104442. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104443. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104444. areAllEffectsReady(): boolean;
  104445. /**
  104446. * @hidden
  104447. * Get the current error code of the webGL context
  104448. * @returns the error code
  104449. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104450. */
  104451. getError(): number;
  104452. /** @hidden */
  104453. _getUnpackAlignement(): number;
  104454. /** @hidden */
  104455. _unpackFlipY(value: boolean): void;
  104456. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104457. /**
  104458. * Updates a dynamic vertex buffer.
  104459. * @param vertexBuffer the vertex buffer to update
  104460. * @param data the data used to update the vertex buffer
  104461. * @param byteOffset the byte offset of the data (optional)
  104462. * @param byteLength the byte length of the data (optional)
  104463. */
  104464. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104465. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104466. /** @hidden */
  104467. _bindTexture(channel: number, texture: InternalTexture): void;
  104468. /** @hidden */
  104469. _releaseBuffer(buffer: DataBuffer): boolean;
  104470. releaseEffects(): void;
  104471. displayLoadingUI(): void;
  104472. hideLoadingUI(): void;
  104473. /** @hidden */
  104474. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104475. /** @hidden */
  104476. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104477. /** @hidden */
  104478. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104479. /** @hidden */
  104480. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104481. }
  104482. }
  104483. declare module BABYLON {
  104484. /** @hidden */
  104485. export class _OcclusionDataStorage {
  104486. /** @hidden */
  104487. occlusionInternalRetryCounter: number;
  104488. /** @hidden */
  104489. isOcclusionQueryInProgress: boolean;
  104490. /** @hidden */
  104491. isOccluded: boolean;
  104492. /** @hidden */
  104493. occlusionRetryCount: number;
  104494. /** @hidden */
  104495. occlusionType: number;
  104496. /** @hidden */
  104497. occlusionQueryAlgorithmType: number;
  104498. }
  104499. interface Engine {
  104500. /**
  104501. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104502. * @return the new query
  104503. */
  104504. createQuery(): WebGLQuery;
  104505. /**
  104506. * Delete and release a webGL query
  104507. * @param query defines the query to delete
  104508. * @return the current engine
  104509. */
  104510. deleteQuery(query: WebGLQuery): Engine;
  104511. /**
  104512. * Check if a given query has resolved and got its value
  104513. * @param query defines the query to check
  104514. * @returns true if the query got its value
  104515. */
  104516. isQueryResultAvailable(query: WebGLQuery): boolean;
  104517. /**
  104518. * Gets the value of a given query
  104519. * @param query defines the query to check
  104520. * @returns the value of the query
  104521. */
  104522. getQueryResult(query: WebGLQuery): number;
  104523. /**
  104524. * Initiates an occlusion query
  104525. * @param algorithmType defines the algorithm to use
  104526. * @param query defines the query to use
  104527. * @returns the current engine
  104528. * @see http://doc.babylonjs.com/features/occlusionquery
  104529. */
  104530. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104531. /**
  104532. * Ends an occlusion query
  104533. * @see http://doc.babylonjs.com/features/occlusionquery
  104534. * @param algorithmType defines the algorithm to use
  104535. * @returns the current engine
  104536. */
  104537. endOcclusionQuery(algorithmType: number): Engine;
  104538. /**
  104539. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104540. * Please note that only one query can be issued at a time
  104541. * @returns a time token used to track the time span
  104542. */
  104543. startTimeQuery(): Nullable<_TimeToken>;
  104544. /**
  104545. * Ends a time query
  104546. * @param token defines the token used to measure the time span
  104547. * @returns the time spent (in ns)
  104548. */
  104549. endTimeQuery(token: _TimeToken): int;
  104550. /** @hidden */
  104551. _currentNonTimestampToken: Nullable<_TimeToken>;
  104552. /** @hidden */
  104553. _createTimeQuery(): WebGLQuery;
  104554. /** @hidden */
  104555. _deleteTimeQuery(query: WebGLQuery): void;
  104556. /** @hidden */
  104557. _getGlAlgorithmType(algorithmType: number): number;
  104558. /** @hidden */
  104559. _getTimeQueryResult(query: WebGLQuery): any;
  104560. /** @hidden */
  104561. _getTimeQueryAvailability(query: WebGLQuery): any;
  104562. }
  104563. interface AbstractMesh {
  104564. /**
  104565. * Backing filed
  104566. * @hidden
  104567. */
  104568. __occlusionDataStorage: _OcclusionDataStorage;
  104569. /**
  104570. * Access property
  104571. * @hidden
  104572. */
  104573. _occlusionDataStorage: _OcclusionDataStorage;
  104574. /**
  104575. * 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.
  104576. * The default value is -1 which means don't break the query and wait till the result
  104577. * @see http://doc.babylonjs.com/features/occlusionquery
  104578. */
  104579. occlusionRetryCount: number;
  104580. /**
  104581. * 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:
  104582. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104583. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104584. * * 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.
  104585. * @see http://doc.babylonjs.com/features/occlusionquery
  104586. */
  104587. occlusionType: number;
  104588. /**
  104589. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104590. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104591. * * 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.
  104592. * @see http://doc.babylonjs.com/features/occlusionquery
  104593. */
  104594. occlusionQueryAlgorithmType: number;
  104595. /**
  104596. * 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
  104597. * @see http://doc.babylonjs.com/features/occlusionquery
  104598. */
  104599. isOccluded: boolean;
  104600. /**
  104601. * Flag to check the progress status of the query
  104602. * @see http://doc.babylonjs.com/features/occlusionquery
  104603. */
  104604. isOcclusionQueryInProgress: boolean;
  104605. }
  104606. }
  104607. declare module BABYLON {
  104608. /** @hidden */
  104609. export var _forceTransformFeedbackToBundle: boolean;
  104610. interface Engine {
  104611. /**
  104612. * Creates a webGL transform feedback object
  104613. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104614. * @returns the webGL transform feedback object
  104615. */
  104616. createTransformFeedback(): WebGLTransformFeedback;
  104617. /**
  104618. * Delete a webGL transform feedback object
  104619. * @param value defines the webGL transform feedback object to delete
  104620. */
  104621. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104622. /**
  104623. * Bind a webGL transform feedback object to the webgl context
  104624. * @param value defines the webGL transform feedback object to bind
  104625. */
  104626. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104627. /**
  104628. * Begins a transform feedback operation
  104629. * @param usePoints defines if points or triangles must be used
  104630. */
  104631. beginTransformFeedback(usePoints: boolean): void;
  104632. /**
  104633. * Ends a transform feedback operation
  104634. */
  104635. endTransformFeedback(): void;
  104636. /**
  104637. * Specify the varyings to use with transform feedback
  104638. * @param program defines the associated webGL program
  104639. * @param value defines the list of strings representing the varying names
  104640. */
  104641. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104642. /**
  104643. * Bind a webGL buffer for a transform feedback operation
  104644. * @param value defines the webGL buffer to bind
  104645. */
  104646. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104647. }
  104648. }
  104649. declare module BABYLON {
  104650. /**
  104651. * Creation options of the multi render target texture.
  104652. */
  104653. export interface IMultiRenderTargetOptions {
  104654. /**
  104655. * Define if the texture needs to create mip maps after render.
  104656. */
  104657. generateMipMaps?: boolean;
  104658. /**
  104659. * Define the types of all the draw buffers we want to create
  104660. */
  104661. types?: number[];
  104662. /**
  104663. * Define the sampling modes of all the draw buffers we want to create
  104664. */
  104665. samplingModes?: number[];
  104666. /**
  104667. * Define if a depth buffer is required
  104668. */
  104669. generateDepthBuffer?: boolean;
  104670. /**
  104671. * Define if a stencil buffer is required
  104672. */
  104673. generateStencilBuffer?: boolean;
  104674. /**
  104675. * Define if a depth texture is required instead of a depth buffer
  104676. */
  104677. generateDepthTexture?: boolean;
  104678. /**
  104679. * Define the number of desired draw buffers
  104680. */
  104681. textureCount?: number;
  104682. /**
  104683. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104684. */
  104685. doNotChangeAspectRatio?: boolean;
  104686. /**
  104687. * Define the default type of the buffers we are creating
  104688. */
  104689. defaultType?: number;
  104690. }
  104691. /**
  104692. * A multi render target, like a render target provides the ability to render to a texture.
  104693. * Unlike the render target, it can render to several draw buffers in one draw.
  104694. * This is specially interesting in deferred rendering or for any effects requiring more than
  104695. * just one color from a single pass.
  104696. */
  104697. export class MultiRenderTarget extends RenderTargetTexture {
  104698. private _internalTextures;
  104699. private _textures;
  104700. private _multiRenderTargetOptions;
  104701. /**
  104702. * Get if draw buffers are currently supported by the used hardware and browser.
  104703. */
  104704. readonly isSupported: boolean;
  104705. /**
  104706. * Get the list of textures generated by the multi render target.
  104707. */
  104708. readonly textures: Texture[];
  104709. /**
  104710. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104711. */
  104712. readonly depthTexture: Texture;
  104713. /**
  104714. * Set the wrapping mode on U of all the textures we are rendering to.
  104715. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104716. */
  104717. wrapU: number;
  104718. /**
  104719. * Set the wrapping mode on V of all the textures we are rendering to.
  104720. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104721. */
  104722. wrapV: number;
  104723. /**
  104724. * Instantiate a new multi render target texture.
  104725. * A multi render target, like a render target provides the ability to render to a texture.
  104726. * Unlike the render target, it can render to several draw buffers in one draw.
  104727. * This is specially interesting in deferred rendering or for any effects requiring more than
  104728. * just one color from a single pass.
  104729. * @param name Define the name of the texture
  104730. * @param size Define the size of the buffers to render to
  104731. * @param count Define the number of target we are rendering into
  104732. * @param scene Define the scene the texture belongs to
  104733. * @param options Define the options used to create the multi render target
  104734. */
  104735. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104736. /** @hidden */
  104737. _rebuild(): void;
  104738. private _createInternalTextures;
  104739. private _createTextures;
  104740. /**
  104741. * Define the number of samples used if MSAA is enabled.
  104742. */
  104743. samples: number;
  104744. /**
  104745. * Resize all the textures in the multi render target.
  104746. * Be carrefull as it will recreate all the data in the new texture.
  104747. * @param size Define the new size
  104748. */
  104749. resize(size: any): void;
  104750. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104751. /**
  104752. * Dispose the render targets and their associated resources
  104753. */
  104754. dispose(): void;
  104755. /**
  104756. * Release all the underlying texture used as draw buffers.
  104757. */
  104758. releaseInternalTextures(): void;
  104759. }
  104760. }
  104761. declare module BABYLON {
  104762. interface Engine {
  104763. /**
  104764. * Unbind a list of render target textures from the webGL context
  104765. * This is used only when drawBuffer extension or webGL2 are active
  104766. * @param textures defines the render target textures to unbind
  104767. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104768. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104769. */
  104770. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104771. /**
  104772. * Create a multi render target texture
  104773. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  104774. * @param size defines the size of the texture
  104775. * @param options defines the creation options
  104776. * @returns the cube texture as an InternalTexture
  104777. */
  104778. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104779. /**
  104780. * Update the sample count for a given multiple render target texture
  104781. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104782. * @param textures defines the textures to update
  104783. * @param samples defines the sample count to set
  104784. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104785. */
  104786. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104787. }
  104788. }
  104789. declare module BABYLON {
  104790. /**
  104791. * Gather the list of clipboard event types as constants.
  104792. */
  104793. export class ClipboardEventTypes {
  104794. /**
  104795. * The clipboard event is fired when a copy command is active (pressed).
  104796. */
  104797. static readonly COPY: number;
  104798. /**
  104799. * The clipboard event is fired when a cut command is active (pressed).
  104800. */
  104801. static readonly CUT: number;
  104802. /**
  104803. * The clipboard event is fired when a paste command is active (pressed).
  104804. */
  104805. static readonly PASTE: number;
  104806. }
  104807. /**
  104808. * This class is used to store clipboard related info for the onClipboardObservable event.
  104809. */
  104810. export class ClipboardInfo {
  104811. /**
  104812. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104813. */
  104814. type: number;
  104815. /**
  104816. * Defines the related dom event
  104817. */
  104818. event: ClipboardEvent;
  104819. /**
  104820. *Creates an instance of ClipboardInfo.
  104821. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  104822. * @param event Defines the related dom event
  104823. */
  104824. constructor(
  104825. /**
  104826. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104827. */
  104828. type: number,
  104829. /**
  104830. * Defines the related dom event
  104831. */
  104832. event: ClipboardEvent);
  104833. /**
  104834. * Get the clipboard event's type from the keycode.
  104835. * @param keyCode Defines the keyCode for the current keyboard event.
  104836. * @return {number}
  104837. */
  104838. static GetTypeFromCharacter(keyCode: number): number;
  104839. }
  104840. }
  104841. declare module BABYLON {
  104842. /**
  104843. * Class used to represent data loading progression
  104844. */
  104845. export class SceneLoaderProgressEvent {
  104846. /** defines if data length to load can be evaluated */
  104847. readonly lengthComputable: boolean;
  104848. /** defines the loaded data length */
  104849. readonly loaded: number;
  104850. /** defines the data length to load */
  104851. readonly total: number;
  104852. /**
  104853. * Create a new progress event
  104854. * @param lengthComputable defines if data length to load can be evaluated
  104855. * @param loaded defines the loaded data length
  104856. * @param total defines the data length to load
  104857. */
  104858. constructor(
  104859. /** defines if data length to load can be evaluated */
  104860. lengthComputable: boolean,
  104861. /** defines the loaded data length */
  104862. loaded: number,
  104863. /** defines the data length to load */
  104864. total: number);
  104865. /**
  104866. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104867. * @param event defines the source event
  104868. * @returns a new SceneLoaderProgressEvent
  104869. */
  104870. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104871. }
  104872. /**
  104873. * Interface used by SceneLoader plugins to define supported file extensions
  104874. */
  104875. export interface ISceneLoaderPluginExtensions {
  104876. /**
  104877. * Defines the list of supported extensions
  104878. */
  104879. [extension: string]: {
  104880. isBinary: boolean;
  104881. };
  104882. }
  104883. /**
  104884. * Interface used by SceneLoader plugin factory
  104885. */
  104886. export interface ISceneLoaderPluginFactory {
  104887. /**
  104888. * Defines the name of the factory
  104889. */
  104890. name: string;
  104891. /**
  104892. * Function called to create a new plugin
  104893. * @return the new plugin
  104894. */
  104895. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104896. /**
  104897. * Boolean indicating if the plugin can direct load specific data
  104898. */
  104899. canDirectLoad?: (data: string) => boolean;
  104900. }
  104901. /**
  104902. * Interface used to define a SceneLoader plugin
  104903. */
  104904. export interface ISceneLoaderPlugin {
  104905. /**
  104906. * The friendly name of this plugin.
  104907. */
  104908. name: string;
  104909. /**
  104910. * The file extensions supported by this plugin.
  104911. */
  104912. extensions: string | ISceneLoaderPluginExtensions;
  104913. /**
  104914. * Import meshes into a scene.
  104915. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104916. * @param scene The scene to import into
  104917. * @param data The data to import
  104918. * @param rootUrl The root url for scene and resources
  104919. * @param meshes The meshes array to import into
  104920. * @param particleSystems The particle systems array to import into
  104921. * @param skeletons The skeletons array to import into
  104922. * @param onError The callback when import fails
  104923. * @returns True if successful or false otherwise
  104924. */
  104925. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104926. /**
  104927. * Load into a scene.
  104928. * @param scene The scene to load into
  104929. * @param data The data to import
  104930. * @param rootUrl The root url for scene and resources
  104931. * @param onError The callback when import fails
  104932. * @returns true if successful or false otherwise
  104933. */
  104934. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104935. /**
  104936. * The callback that returns true if the data can be directly loaded.
  104937. */
  104938. canDirectLoad?: (data: string) => boolean;
  104939. /**
  104940. * The callback that allows custom handling of the root url based on the response url.
  104941. */
  104942. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104943. /**
  104944. * Load into an asset container.
  104945. * @param scene The scene to load into
  104946. * @param data The data to import
  104947. * @param rootUrl The root url for scene and resources
  104948. * @param onError The callback when import fails
  104949. * @returns The loaded asset container
  104950. */
  104951. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104952. }
  104953. /**
  104954. * Interface used to define an async SceneLoader plugin
  104955. */
  104956. export interface ISceneLoaderPluginAsync {
  104957. /**
  104958. * The friendly name of this plugin.
  104959. */
  104960. name: string;
  104961. /**
  104962. * The file extensions supported by this plugin.
  104963. */
  104964. extensions: string | ISceneLoaderPluginExtensions;
  104965. /**
  104966. * Import meshes into a scene.
  104967. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104968. * @param scene The scene to import into
  104969. * @param data The data to import
  104970. * @param rootUrl The root url for scene and resources
  104971. * @param onProgress The callback when the load progresses
  104972. * @param fileName Defines the name of the file to load
  104973. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  104974. */
  104975. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  104976. meshes: AbstractMesh[];
  104977. particleSystems: IParticleSystem[];
  104978. skeletons: Skeleton[];
  104979. animationGroups: AnimationGroup[];
  104980. }>;
  104981. /**
  104982. * Load into a scene.
  104983. * @param scene The scene to load into
  104984. * @param data The data to import
  104985. * @param rootUrl The root url for scene and resources
  104986. * @param onProgress The callback when the load progresses
  104987. * @param fileName Defines the name of the file to load
  104988. * @returns Nothing
  104989. */
  104990. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  104991. /**
  104992. * The callback that returns true if the data can be directly loaded.
  104993. */
  104994. canDirectLoad?: (data: string) => boolean;
  104995. /**
  104996. * The callback that allows custom handling of the root url based on the response url.
  104997. */
  104998. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104999. /**
  105000. * Load into an asset container.
  105001. * @param scene The scene to load into
  105002. * @param data The data to import
  105003. * @param rootUrl The root url for scene and resources
  105004. * @param onProgress The callback when the load progresses
  105005. * @param fileName Defines the name of the file to load
  105006. * @returns The loaded asset container
  105007. */
  105008. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105009. }
  105010. /**
  105011. * Class used to load scene from various file formats using registered plugins
  105012. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105013. */
  105014. export class SceneLoader {
  105015. /**
  105016. * No logging while loading
  105017. */
  105018. static readonly NO_LOGGING: number;
  105019. /**
  105020. * Minimal logging while loading
  105021. */
  105022. static readonly MINIMAL_LOGGING: number;
  105023. /**
  105024. * Summary logging while loading
  105025. */
  105026. static readonly SUMMARY_LOGGING: number;
  105027. /**
  105028. * Detailled logging while loading
  105029. */
  105030. static readonly DETAILED_LOGGING: number;
  105031. /**
  105032. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105033. */
  105034. static ForceFullSceneLoadingForIncremental: boolean;
  105035. /**
  105036. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105037. */
  105038. static ShowLoadingScreen: boolean;
  105039. /**
  105040. * Defines the current logging level (while loading the scene)
  105041. * @ignorenaming
  105042. */
  105043. static loggingLevel: number;
  105044. /**
  105045. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105046. */
  105047. static CleanBoneMatrixWeights: boolean;
  105048. /**
  105049. * Event raised when a plugin is used to load a scene
  105050. */
  105051. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105052. private static _registeredPlugins;
  105053. private static _getDefaultPlugin;
  105054. private static _getPluginForExtension;
  105055. private static _getPluginForDirectLoad;
  105056. private static _getPluginForFilename;
  105057. private static _getDirectLoad;
  105058. private static _loadData;
  105059. private static _getFileInfo;
  105060. /**
  105061. * Gets a plugin that can load the given extension
  105062. * @param extension defines the extension to load
  105063. * @returns a plugin or null if none works
  105064. */
  105065. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105066. /**
  105067. * Gets a boolean indicating that the given extension can be loaded
  105068. * @param extension defines the extension to load
  105069. * @returns true if the extension is supported
  105070. */
  105071. static IsPluginForExtensionAvailable(extension: string): boolean;
  105072. /**
  105073. * Adds a new plugin to the list of registered plugins
  105074. * @param plugin defines the plugin to add
  105075. */
  105076. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105077. /**
  105078. * Import meshes into a scene
  105079. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105080. * @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)
  105081. * @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)
  105082. * @param scene the instance of BABYLON.Scene to append to
  105083. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105084. * @param onProgress a callback with a progress event for each file being loaded
  105085. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105086. * @param pluginExtension the extension used to determine the plugin
  105087. * @returns The loaded plugin
  105088. */
  105089. 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>;
  105090. /**
  105091. * Import meshes into a scene
  105092. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105093. * @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)
  105094. * @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)
  105095. * @param scene the instance of BABYLON.Scene to append to
  105096. * @param onProgress a callback with a progress event for each file being loaded
  105097. * @param pluginExtension the extension used to determine the plugin
  105098. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105099. */
  105100. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105101. meshes: AbstractMesh[];
  105102. particleSystems: IParticleSystem[];
  105103. skeletons: Skeleton[];
  105104. animationGroups: AnimationGroup[];
  105105. }>;
  105106. /**
  105107. * Load a scene
  105108. * @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)
  105109. * @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)
  105110. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105111. * @param onSuccess a callback with the scene when import succeeds
  105112. * @param onProgress a callback with a progress event for each file being loaded
  105113. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105114. * @param pluginExtension the extension used to determine the plugin
  105115. * @returns The loaded plugin
  105116. */
  105117. 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>;
  105118. /**
  105119. * Load a scene
  105120. * @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)
  105121. * @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)
  105122. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105123. * @param onProgress a callback with a progress event for each file being loaded
  105124. * @param pluginExtension the extension used to determine the plugin
  105125. * @returns The loaded scene
  105126. */
  105127. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105128. /**
  105129. * Append a scene
  105130. * @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)
  105131. * @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)
  105132. * @param scene is the instance of BABYLON.Scene to append to
  105133. * @param onSuccess a callback with the scene when import succeeds
  105134. * @param onProgress a callback with a progress event for each file being loaded
  105135. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105136. * @param pluginExtension the extension used to determine the plugin
  105137. * @returns The loaded plugin
  105138. */
  105139. 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>;
  105140. /**
  105141. * Append a scene
  105142. * @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)
  105143. * @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)
  105144. * @param scene is the instance of BABYLON.Scene to append to
  105145. * @param onProgress a callback with a progress event for each file being loaded
  105146. * @param pluginExtension the extension used to determine the plugin
  105147. * @returns The given scene
  105148. */
  105149. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105150. /**
  105151. * Load a scene into an asset container
  105152. * @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)
  105153. * @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)
  105154. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105155. * @param onSuccess a callback with the scene when import succeeds
  105156. * @param onProgress a callback with a progress event for each file being loaded
  105157. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105158. * @param pluginExtension the extension used to determine the plugin
  105159. * @returns The loaded plugin
  105160. */
  105161. 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>;
  105162. /**
  105163. * Load a scene into an asset container
  105164. * @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)
  105165. * @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)
  105166. * @param scene is the instance of Scene to append to
  105167. * @param onProgress a callback with a progress event for each file being loaded
  105168. * @param pluginExtension the extension used to determine the plugin
  105169. * @returns The loaded asset container
  105170. */
  105171. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105172. }
  105173. }
  105174. declare module BABYLON {
  105175. /**
  105176. * Google Daydream controller
  105177. */
  105178. export class DaydreamController extends WebVRController {
  105179. /**
  105180. * Base Url for the controller model.
  105181. */
  105182. static MODEL_BASE_URL: string;
  105183. /**
  105184. * File name for the controller model.
  105185. */
  105186. static MODEL_FILENAME: string;
  105187. /**
  105188. * Gamepad Id prefix used to identify Daydream Controller.
  105189. */
  105190. static readonly GAMEPAD_ID_PREFIX: string;
  105191. /**
  105192. * Creates a new DaydreamController from a gamepad
  105193. * @param vrGamepad the gamepad that the controller should be created from
  105194. */
  105195. constructor(vrGamepad: any);
  105196. /**
  105197. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105198. * @param scene scene in which to add meshes
  105199. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105200. */
  105201. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105202. /**
  105203. * Called once for each button that changed state since the last frame
  105204. * @param buttonIdx Which button index changed
  105205. * @param state New state of the button
  105206. * @param changes Which properties on the state changed since last frame
  105207. */
  105208. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105209. }
  105210. }
  105211. declare module BABYLON {
  105212. /**
  105213. * Gear VR Controller
  105214. */
  105215. export class GearVRController extends WebVRController {
  105216. /**
  105217. * Base Url for the controller model.
  105218. */
  105219. static MODEL_BASE_URL: string;
  105220. /**
  105221. * File name for the controller model.
  105222. */
  105223. static MODEL_FILENAME: string;
  105224. /**
  105225. * Gamepad Id prefix used to identify this controller.
  105226. */
  105227. static readonly GAMEPAD_ID_PREFIX: string;
  105228. private readonly _buttonIndexToObservableNameMap;
  105229. /**
  105230. * Creates a new GearVRController from a gamepad
  105231. * @param vrGamepad the gamepad that the controller should be created from
  105232. */
  105233. constructor(vrGamepad: any);
  105234. /**
  105235. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105236. * @param scene scene in which to add meshes
  105237. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105238. */
  105239. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105240. /**
  105241. * Called once for each button that changed state since the last frame
  105242. * @param buttonIdx Which button index changed
  105243. * @param state New state of the button
  105244. * @param changes Which properties on the state changed since last frame
  105245. */
  105246. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105247. }
  105248. }
  105249. declare module BABYLON {
  105250. /**
  105251. * Generic Controller
  105252. */
  105253. export class GenericController extends WebVRController {
  105254. /**
  105255. * Base Url for the controller model.
  105256. */
  105257. static readonly MODEL_BASE_URL: string;
  105258. /**
  105259. * File name for the controller model.
  105260. */
  105261. static readonly MODEL_FILENAME: string;
  105262. /**
  105263. * Creates a new GenericController from a gamepad
  105264. * @param vrGamepad the gamepad that the controller should be created from
  105265. */
  105266. constructor(vrGamepad: any);
  105267. /**
  105268. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105269. * @param scene scene in which to add meshes
  105270. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105271. */
  105272. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105273. /**
  105274. * Called once for each button that changed state since the last frame
  105275. * @param buttonIdx Which button index changed
  105276. * @param state New state of the button
  105277. * @param changes Which properties on the state changed since last frame
  105278. */
  105279. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105280. }
  105281. }
  105282. declare module BABYLON {
  105283. /**
  105284. * Oculus Touch Controller
  105285. */
  105286. export class OculusTouchController extends WebVRController {
  105287. /**
  105288. * Base Url for the controller model.
  105289. */
  105290. static MODEL_BASE_URL: string;
  105291. /**
  105292. * File name for the left controller model.
  105293. */
  105294. static MODEL_LEFT_FILENAME: string;
  105295. /**
  105296. * File name for the right controller model.
  105297. */
  105298. static MODEL_RIGHT_FILENAME: string;
  105299. /**
  105300. * Fired when the secondary trigger on this controller is modified
  105301. */
  105302. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105303. /**
  105304. * Fired when the thumb rest on this controller is modified
  105305. */
  105306. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105307. /**
  105308. * Creates a new OculusTouchController from a gamepad
  105309. * @param vrGamepad the gamepad that the controller should be created from
  105310. */
  105311. constructor(vrGamepad: any);
  105312. /**
  105313. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105314. * @param scene scene in which to add meshes
  105315. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105316. */
  105317. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105318. /**
  105319. * Fired when the A button on this controller is modified
  105320. */
  105321. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105322. /**
  105323. * Fired when the B button on this controller is modified
  105324. */
  105325. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105326. /**
  105327. * Fired when the X button on this controller is modified
  105328. */
  105329. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105330. /**
  105331. * Fired when the Y button on this controller is modified
  105332. */
  105333. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105334. /**
  105335. * Called once for each button that changed state since the last frame
  105336. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105337. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105338. * 2) secondary trigger (same)
  105339. * 3) A (right) X (left), touch, pressed = value
  105340. * 4) B / Y
  105341. * 5) thumb rest
  105342. * @param buttonIdx Which button index changed
  105343. * @param state New state of the button
  105344. * @param changes Which properties on the state changed since last frame
  105345. */
  105346. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105347. }
  105348. }
  105349. declare module BABYLON {
  105350. /**
  105351. * Vive Controller
  105352. */
  105353. export class ViveController extends WebVRController {
  105354. /**
  105355. * Base Url for the controller model.
  105356. */
  105357. static MODEL_BASE_URL: string;
  105358. /**
  105359. * File name for the controller model.
  105360. */
  105361. static MODEL_FILENAME: string;
  105362. /**
  105363. * Creates a new ViveController from a gamepad
  105364. * @param vrGamepad the gamepad that the controller should be created from
  105365. */
  105366. constructor(vrGamepad: any);
  105367. /**
  105368. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105369. * @param scene scene in which to add meshes
  105370. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105371. */
  105372. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105373. /**
  105374. * Fired when the left button on this controller is modified
  105375. */
  105376. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105377. /**
  105378. * Fired when the right button on this controller is modified
  105379. */
  105380. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105381. /**
  105382. * Fired when the menu button on this controller is modified
  105383. */
  105384. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105385. /**
  105386. * Called once for each button that changed state since the last frame
  105387. * Vive mapping:
  105388. * 0: touchpad
  105389. * 1: trigger
  105390. * 2: left AND right buttons
  105391. * 3: menu button
  105392. * @param buttonIdx Which button index changed
  105393. * @param state New state of the button
  105394. * @param changes Which properties on the state changed since last frame
  105395. */
  105396. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105397. }
  105398. }
  105399. declare module BABYLON {
  105400. /**
  105401. * Defines the WindowsMotionController object that the state of the windows motion controller
  105402. */
  105403. export class WindowsMotionController extends WebVRController {
  105404. /**
  105405. * The base url used to load the left and right controller models
  105406. */
  105407. static MODEL_BASE_URL: string;
  105408. /**
  105409. * The name of the left controller model file
  105410. */
  105411. static MODEL_LEFT_FILENAME: string;
  105412. /**
  105413. * The name of the right controller model file
  105414. */
  105415. static MODEL_RIGHT_FILENAME: string;
  105416. /**
  105417. * The controller name prefix for this controller type
  105418. */
  105419. static readonly GAMEPAD_ID_PREFIX: string;
  105420. /**
  105421. * The controller id pattern for this controller type
  105422. */
  105423. private static readonly GAMEPAD_ID_PATTERN;
  105424. private _loadedMeshInfo;
  105425. private readonly _mapping;
  105426. /**
  105427. * Fired when the trackpad on this controller is clicked
  105428. */
  105429. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105430. /**
  105431. * Fired when the trackpad on this controller is modified
  105432. */
  105433. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105434. /**
  105435. * The current x and y values of this controller's trackpad
  105436. */
  105437. trackpad: StickValues;
  105438. /**
  105439. * Creates a new WindowsMotionController from a gamepad
  105440. * @param vrGamepad the gamepad that the controller should be created from
  105441. */
  105442. constructor(vrGamepad: any);
  105443. /**
  105444. * Fired when the trigger on this controller is modified
  105445. */
  105446. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105447. /**
  105448. * Fired when the menu button on this controller is modified
  105449. */
  105450. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105451. /**
  105452. * Fired when the grip button on this controller is modified
  105453. */
  105454. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105455. /**
  105456. * Fired when the thumbstick button on this controller is modified
  105457. */
  105458. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105459. /**
  105460. * Fired when the touchpad button on this controller is modified
  105461. */
  105462. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105463. /**
  105464. * Fired when the touchpad values on this controller are modified
  105465. */
  105466. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105467. private _updateTrackpad;
  105468. /**
  105469. * Called once per frame by the engine.
  105470. */
  105471. update(): void;
  105472. /**
  105473. * Called once for each button that changed state since the last frame
  105474. * @param buttonIdx Which button index changed
  105475. * @param state New state of the button
  105476. * @param changes Which properties on the state changed since last frame
  105477. */
  105478. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105479. /**
  105480. * Moves the buttons on the controller mesh based on their current state
  105481. * @param buttonName the name of the button to move
  105482. * @param buttonValue the value of the button which determines the buttons new position
  105483. */
  105484. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105485. /**
  105486. * Moves the axis on the controller mesh based on its current state
  105487. * @param axis the index of the axis
  105488. * @param axisValue the value of the axis which determines the meshes new position
  105489. * @hidden
  105490. */
  105491. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105492. /**
  105493. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105494. * @param scene scene in which to add meshes
  105495. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105496. */
  105497. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105498. /**
  105499. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105500. * can be transformed by button presses and axes values, based on this._mapping.
  105501. *
  105502. * @param scene scene in which the meshes exist
  105503. * @param meshes list of meshes that make up the controller model to process
  105504. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105505. */
  105506. private processModel;
  105507. private createMeshInfo;
  105508. /**
  105509. * Gets the ray of the controller in the direction the controller is pointing
  105510. * @param length the length the resulting ray should be
  105511. * @returns a ray in the direction the controller is pointing
  105512. */
  105513. getForwardRay(length?: number): Ray;
  105514. /**
  105515. * Disposes of the controller
  105516. */
  105517. dispose(): void;
  105518. }
  105519. }
  105520. declare module BABYLON {
  105521. /**
  105522. * Class containing static functions to help procedurally build meshes
  105523. */
  105524. export class PolyhedronBuilder {
  105525. /**
  105526. * Creates a polyhedron mesh
  105527. * * 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
  105528. * * The parameter `size` (positive float, default 1) sets the polygon size
  105529. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105530. * * 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`
  105531. * * 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
  105532. * * 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)`)
  105533. * * 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
  105534. * * 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
  105535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105538. * @param name defines the name of the mesh
  105539. * @param options defines the options used to create the mesh
  105540. * @param scene defines the hosting scene
  105541. * @returns the polyhedron mesh
  105542. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105543. */
  105544. static CreatePolyhedron(name: string, options: {
  105545. type?: number;
  105546. size?: number;
  105547. sizeX?: number;
  105548. sizeY?: number;
  105549. sizeZ?: number;
  105550. custom?: any;
  105551. faceUV?: Vector4[];
  105552. faceColors?: Color4[];
  105553. flat?: boolean;
  105554. updatable?: boolean;
  105555. sideOrientation?: number;
  105556. frontUVs?: Vector4;
  105557. backUVs?: Vector4;
  105558. }, scene?: Nullable<Scene>): Mesh;
  105559. }
  105560. }
  105561. declare module BABYLON {
  105562. /**
  105563. * Gizmo that enables scaling a mesh along 3 axis
  105564. */
  105565. export class ScaleGizmo extends Gizmo {
  105566. /**
  105567. * Internal gizmo used for interactions on the x axis
  105568. */
  105569. xGizmo: AxisScaleGizmo;
  105570. /**
  105571. * Internal gizmo used for interactions on the y axis
  105572. */
  105573. yGizmo: AxisScaleGizmo;
  105574. /**
  105575. * Internal gizmo used for interactions on the z axis
  105576. */
  105577. zGizmo: AxisScaleGizmo;
  105578. /**
  105579. * Internal gizmo used to scale all axis equally
  105580. */
  105581. uniformScaleGizmo: AxisScaleGizmo;
  105582. private _meshAttached;
  105583. private _updateGizmoRotationToMatchAttachedMesh;
  105584. private _snapDistance;
  105585. private _scaleRatio;
  105586. private _uniformScalingMesh;
  105587. private _octahedron;
  105588. /** Fires an event when any of it's sub gizmos are dragged */
  105589. onDragStartObservable: Observable<{}>;
  105590. /** Fires an event when any of it's sub gizmos are released from dragging */
  105591. onDragEndObservable: Observable<{}>;
  105592. attachedMesh: Nullable<AbstractMesh>;
  105593. /**
  105594. * Creates a ScaleGizmo
  105595. * @param gizmoLayer The utility layer the gizmo will be added to
  105596. */
  105597. constructor(gizmoLayer?: UtilityLayerRenderer);
  105598. updateGizmoRotationToMatchAttachedMesh: boolean;
  105599. /**
  105600. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105601. */
  105602. snapDistance: number;
  105603. /**
  105604. * Ratio for the scale of the gizmo (Default: 1)
  105605. */
  105606. scaleRatio: number;
  105607. /**
  105608. * Disposes of the gizmo
  105609. */
  105610. dispose(): void;
  105611. }
  105612. }
  105613. declare module BABYLON {
  105614. /**
  105615. * Single axis scale gizmo
  105616. */
  105617. export class AxisScaleGizmo extends Gizmo {
  105618. /**
  105619. * Drag behavior responsible for the gizmos dragging interactions
  105620. */
  105621. dragBehavior: PointerDragBehavior;
  105622. private _pointerObserver;
  105623. /**
  105624. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105625. */
  105626. snapDistance: number;
  105627. /**
  105628. * Event that fires each time the gizmo snaps to a new location.
  105629. * * snapDistance is the the change in distance
  105630. */
  105631. onSnapObservable: Observable<{
  105632. snapDistance: number;
  105633. }>;
  105634. /**
  105635. * If the scaling operation should be done on all axis (default: false)
  105636. */
  105637. uniformScaling: boolean;
  105638. private _isEnabled;
  105639. private _parent;
  105640. private _arrow;
  105641. private _coloredMaterial;
  105642. private _hoverMaterial;
  105643. /**
  105644. * Creates an AxisScaleGizmo
  105645. * @param gizmoLayer The utility layer the gizmo will be added to
  105646. * @param dragAxis The axis which the gizmo will be able to scale on
  105647. * @param color The color of the gizmo
  105648. */
  105649. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105650. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105651. /**
  105652. * If the gizmo is enabled
  105653. */
  105654. isEnabled: boolean;
  105655. /**
  105656. * Disposes of the gizmo
  105657. */
  105658. dispose(): void;
  105659. /**
  105660. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105661. * @param mesh The mesh to replace the default mesh of the gizmo
  105662. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105663. */
  105664. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105665. }
  105666. }
  105667. declare module BABYLON {
  105668. /**
  105669. * Bounding box gizmo
  105670. */
  105671. export class BoundingBoxGizmo extends Gizmo {
  105672. private _lineBoundingBox;
  105673. private _rotateSpheresParent;
  105674. private _scaleBoxesParent;
  105675. private _boundingDimensions;
  105676. private _renderObserver;
  105677. private _pointerObserver;
  105678. private _scaleDragSpeed;
  105679. private _tmpQuaternion;
  105680. private _tmpVector;
  105681. private _tmpRotationMatrix;
  105682. /**
  105683. * 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)
  105684. */
  105685. ignoreChildren: boolean;
  105686. /**
  105687. * 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)
  105688. */
  105689. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105690. /**
  105691. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105692. */
  105693. rotationSphereSize: number;
  105694. /**
  105695. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105696. */
  105697. scaleBoxSize: number;
  105698. /**
  105699. * 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)
  105700. */
  105701. fixedDragMeshScreenSize: boolean;
  105702. /**
  105703. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105704. */
  105705. fixedDragMeshScreenSizeDistanceFactor: number;
  105706. /**
  105707. * Fired when a rotation sphere or scale box is dragged
  105708. */
  105709. onDragStartObservable: Observable<{}>;
  105710. /**
  105711. * Fired when a scale box is dragged
  105712. */
  105713. onScaleBoxDragObservable: Observable<{}>;
  105714. /**
  105715. * Fired when a scale box drag is ended
  105716. */
  105717. onScaleBoxDragEndObservable: Observable<{}>;
  105718. /**
  105719. * Fired when a rotation sphere is dragged
  105720. */
  105721. onRotationSphereDragObservable: Observable<{}>;
  105722. /**
  105723. * Fired when a rotation sphere drag is ended
  105724. */
  105725. onRotationSphereDragEndObservable: Observable<{}>;
  105726. /**
  105727. * 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)
  105728. */
  105729. scalePivot: Nullable<Vector3>;
  105730. /**
  105731. * Mesh used as a pivot to rotate the attached mesh
  105732. */
  105733. private _anchorMesh;
  105734. private _existingMeshScale;
  105735. private _dragMesh;
  105736. private pointerDragBehavior;
  105737. private coloredMaterial;
  105738. private hoverColoredMaterial;
  105739. /**
  105740. * Sets the color of the bounding box gizmo
  105741. * @param color the color to set
  105742. */
  105743. setColor(color: Color3): void;
  105744. /**
  105745. * Creates an BoundingBoxGizmo
  105746. * @param gizmoLayer The utility layer the gizmo will be added to
  105747. * @param color The color of the gizmo
  105748. */
  105749. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  105750. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105751. private _selectNode;
  105752. /**
  105753. * Updates the bounding box information for the Gizmo
  105754. */
  105755. updateBoundingBox(): void;
  105756. private _updateRotationSpheres;
  105757. private _updateScaleBoxes;
  105758. /**
  105759. * Enables rotation on the specified axis and disables rotation on the others
  105760. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  105761. */
  105762. setEnabledRotationAxis(axis: string): void;
  105763. /**
  105764. * Enables/disables scaling
  105765. * @param enable if scaling should be enabled
  105766. */
  105767. setEnabledScaling(enable: boolean): void;
  105768. private _updateDummy;
  105769. /**
  105770. * Enables a pointer drag behavior on the bounding box of the gizmo
  105771. */
  105772. enableDragBehavior(): void;
  105773. /**
  105774. * Disposes of the gizmo
  105775. */
  105776. dispose(): void;
  105777. /**
  105778. * 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)
  105779. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  105780. * @returns the bounding box mesh with the passed in mesh as a child
  105781. */
  105782. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  105783. /**
  105784. * CustomMeshes are not supported by this gizmo
  105785. * @param mesh The mesh to replace the default mesh of the gizmo
  105786. */
  105787. setCustomMesh(mesh: Mesh): void;
  105788. }
  105789. }
  105790. declare module BABYLON {
  105791. /**
  105792. * Single plane rotation gizmo
  105793. */
  105794. export class PlaneRotationGizmo extends Gizmo {
  105795. /**
  105796. * Drag behavior responsible for the gizmos dragging interactions
  105797. */
  105798. dragBehavior: PointerDragBehavior;
  105799. private _pointerObserver;
  105800. /**
  105801. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  105802. */
  105803. snapDistance: number;
  105804. /**
  105805. * Event that fires each time the gizmo snaps to a new location.
  105806. * * snapDistance is the the change in distance
  105807. */
  105808. onSnapObservable: Observable<{
  105809. snapDistance: number;
  105810. }>;
  105811. private _isEnabled;
  105812. private _parent;
  105813. /**
  105814. * Creates a PlaneRotationGizmo
  105815. * @param gizmoLayer The utility layer the gizmo will be added to
  105816. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  105817. * @param color The color of the gizmo
  105818. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105819. */
  105820. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  105821. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105822. /**
  105823. * If the gizmo is enabled
  105824. */
  105825. isEnabled: boolean;
  105826. /**
  105827. * Disposes of the gizmo
  105828. */
  105829. dispose(): void;
  105830. }
  105831. }
  105832. declare module BABYLON {
  105833. /**
  105834. * Gizmo that enables rotating a mesh along 3 axis
  105835. */
  105836. export class RotationGizmo extends Gizmo {
  105837. /**
  105838. * Internal gizmo used for interactions on the x axis
  105839. */
  105840. xGizmo: PlaneRotationGizmo;
  105841. /**
  105842. * Internal gizmo used for interactions on the y axis
  105843. */
  105844. yGizmo: PlaneRotationGizmo;
  105845. /**
  105846. * Internal gizmo used for interactions on the z axis
  105847. */
  105848. zGizmo: PlaneRotationGizmo;
  105849. /** Fires an event when any of it's sub gizmos are dragged */
  105850. onDragStartObservable: Observable<{}>;
  105851. /** Fires an event when any of it's sub gizmos are released from dragging */
  105852. onDragEndObservable: Observable<{}>;
  105853. private _meshAttached;
  105854. attachedMesh: Nullable<AbstractMesh>;
  105855. /**
  105856. * Creates a RotationGizmo
  105857. * @param gizmoLayer The utility layer the gizmo will be added to
  105858. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105859. */
  105860. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  105861. updateGizmoRotationToMatchAttachedMesh: boolean;
  105862. /**
  105863. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105864. */
  105865. snapDistance: number;
  105866. /**
  105867. * Ratio for the scale of the gizmo (Default: 1)
  105868. */
  105869. scaleRatio: number;
  105870. /**
  105871. * Disposes of the gizmo
  105872. */
  105873. dispose(): void;
  105874. /**
  105875. * CustomMeshes are not supported by this gizmo
  105876. * @param mesh The mesh to replace the default mesh of the gizmo
  105877. */
  105878. setCustomMesh(mesh: Mesh): void;
  105879. }
  105880. }
  105881. declare module BABYLON {
  105882. /**
  105883. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  105884. */
  105885. export class GizmoManager implements IDisposable {
  105886. private scene;
  105887. /**
  105888. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  105889. */
  105890. gizmos: {
  105891. positionGizmo: Nullable<PositionGizmo>;
  105892. rotationGizmo: Nullable<RotationGizmo>;
  105893. scaleGizmo: Nullable<ScaleGizmo>;
  105894. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  105895. };
  105896. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  105897. clearGizmoOnEmptyPointerEvent: boolean;
  105898. /** Fires an event when the manager is attached to a mesh */
  105899. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  105900. private _gizmosEnabled;
  105901. private _pointerObserver;
  105902. private _attachedMesh;
  105903. private _boundingBoxColor;
  105904. private _defaultUtilityLayer;
  105905. private _defaultKeepDepthUtilityLayer;
  105906. /**
  105907. * When bounding box gizmo is enabled, this can be used to track drag/end events
  105908. */
  105909. boundingBoxDragBehavior: SixDofDragBehavior;
  105910. /**
  105911. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  105912. */
  105913. attachableMeshes: Nullable<Array<AbstractMesh>>;
  105914. /**
  105915. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  105916. */
  105917. usePointerToAttachGizmos: boolean;
  105918. /**
  105919. * Utility layer that the bounding box gizmo belongs to
  105920. */
  105921. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  105922. /**
  105923. * Utility layer that all gizmos besides bounding box belong to
  105924. */
  105925. readonly utilityLayer: UtilityLayerRenderer;
  105926. /**
  105927. * Instatiates a gizmo manager
  105928. * @param scene the scene to overlay the gizmos on top of
  105929. */
  105930. constructor(scene: Scene);
  105931. /**
  105932. * Attaches a set of gizmos to the specified mesh
  105933. * @param mesh The mesh the gizmo's should be attached to
  105934. */
  105935. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105936. /**
  105937. * If the position gizmo is enabled
  105938. */
  105939. positionGizmoEnabled: boolean;
  105940. /**
  105941. * If the rotation gizmo is enabled
  105942. */
  105943. rotationGizmoEnabled: boolean;
  105944. /**
  105945. * If the scale gizmo is enabled
  105946. */
  105947. scaleGizmoEnabled: boolean;
  105948. /**
  105949. * If the boundingBox gizmo is enabled
  105950. */
  105951. boundingBoxGizmoEnabled: boolean;
  105952. /**
  105953. * Disposes of the gizmo manager
  105954. */
  105955. dispose(): void;
  105956. }
  105957. }
  105958. declare module BABYLON {
  105959. /**
  105960. * A directional light is defined by a direction (what a surprise!).
  105961. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105962. * 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.
  105963. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105964. */
  105965. export class DirectionalLight extends ShadowLight {
  105966. private _shadowFrustumSize;
  105967. /**
  105968. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105969. */
  105970. /**
  105971. * Specifies a fix frustum size for the shadow generation.
  105972. */
  105973. shadowFrustumSize: number;
  105974. private _shadowOrthoScale;
  105975. /**
  105976. * Gets the shadow projection scale against the optimal computed one.
  105977. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105978. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105979. */
  105980. /**
  105981. * Sets the shadow projection scale against the optimal computed one.
  105982. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105983. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105984. */
  105985. shadowOrthoScale: number;
  105986. /**
  105987. * Automatically compute the projection matrix to best fit (including all the casters)
  105988. * on each frame.
  105989. */
  105990. autoUpdateExtends: boolean;
  105991. private _orthoLeft;
  105992. private _orthoRight;
  105993. private _orthoTop;
  105994. private _orthoBottom;
  105995. /**
  105996. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105997. * The directional light is emitted from everywhere in the given direction.
  105998. * It can cast shadows.
  105999. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106000. * @param name The friendly name of the light
  106001. * @param direction The direction of the light
  106002. * @param scene The scene the light belongs to
  106003. */
  106004. constructor(name: string, direction: Vector3, scene: Scene);
  106005. /**
  106006. * Returns the string "DirectionalLight".
  106007. * @return The class name
  106008. */
  106009. getClassName(): string;
  106010. /**
  106011. * Returns the integer 1.
  106012. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106013. */
  106014. getTypeID(): number;
  106015. /**
  106016. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106017. * Returns the DirectionalLight Shadow projection matrix.
  106018. */
  106019. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106020. /**
  106021. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106022. * Returns the DirectionalLight Shadow projection matrix.
  106023. */
  106024. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106025. /**
  106026. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106027. * Returns the DirectionalLight Shadow projection matrix.
  106028. */
  106029. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106030. protected _buildUniformLayout(): void;
  106031. /**
  106032. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106033. * @param effect The effect to update
  106034. * @param lightIndex The index of the light in the effect to update
  106035. * @returns The directional light
  106036. */
  106037. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106038. /**
  106039. * Gets the minZ used for shadow according to both the scene and the light.
  106040. *
  106041. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106042. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106043. * @param activeCamera The camera we are returning the min for
  106044. * @returns the depth min z
  106045. */
  106046. getDepthMinZ(activeCamera: Camera): number;
  106047. /**
  106048. * Gets the maxZ used for shadow according to both the scene and the light.
  106049. *
  106050. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106051. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106052. * @param activeCamera The camera we are returning the max for
  106053. * @returns the depth max z
  106054. */
  106055. getDepthMaxZ(activeCamera: Camera): number;
  106056. /**
  106057. * Prepares the list of defines specific to the light type.
  106058. * @param defines the list of defines
  106059. * @param lightIndex defines the index of the light for the effect
  106060. */
  106061. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106062. }
  106063. }
  106064. declare module BABYLON {
  106065. /**
  106066. * Class containing static functions to help procedurally build meshes
  106067. */
  106068. export class HemisphereBuilder {
  106069. /**
  106070. * Creates a hemisphere mesh
  106071. * @param name defines the name of the mesh
  106072. * @param options defines the options used to create the mesh
  106073. * @param scene defines the hosting scene
  106074. * @returns the hemisphere mesh
  106075. */
  106076. static CreateHemisphere(name: string, options: {
  106077. segments?: number;
  106078. diameter?: number;
  106079. sideOrientation?: number;
  106080. }, scene: any): Mesh;
  106081. }
  106082. }
  106083. declare module BABYLON {
  106084. /**
  106085. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106086. * These values define a cone of light starting from the position, emitting toward the direction.
  106087. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106088. * and the exponent defines the speed of the decay of the light with distance (reach).
  106089. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106090. */
  106091. export class SpotLight extends ShadowLight {
  106092. private _angle;
  106093. private _innerAngle;
  106094. private _cosHalfAngle;
  106095. private _lightAngleScale;
  106096. private _lightAngleOffset;
  106097. /**
  106098. * Gets the cone angle of the spot light in Radians.
  106099. */
  106100. /**
  106101. * Sets the cone angle of the spot light in Radians.
  106102. */
  106103. angle: number;
  106104. /**
  106105. * Only used in gltf falloff mode, this defines the angle where
  106106. * the directional falloff will start before cutting at angle which could be seen
  106107. * as outer angle.
  106108. */
  106109. /**
  106110. * Only used in gltf falloff mode, this defines the angle where
  106111. * the directional falloff will start before cutting at angle which could be seen
  106112. * as outer angle.
  106113. */
  106114. innerAngle: number;
  106115. private _shadowAngleScale;
  106116. /**
  106117. * Allows scaling the angle of the light for shadow generation only.
  106118. */
  106119. /**
  106120. * Allows scaling the angle of the light for shadow generation only.
  106121. */
  106122. shadowAngleScale: number;
  106123. /**
  106124. * The light decay speed with the distance from the emission spot.
  106125. */
  106126. exponent: number;
  106127. private _projectionTextureMatrix;
  106128. /**
  106129. * Allows reading the projecton texture
  106130. */
  106131. readonly projectionTextureMatrix: Matrix;
  106132. protected _projectionTextureLightNear: number;
  106133. /**
  106134. * Gets the near clip of the Spotlight for texture projection.
  106135. */
  106136. /**
  106137. * Sets the near clip of the Spotlight for texture projection.
  106138. */
  106139. projectionTextureLightNear: number;
  106140. protected _projectionTextureLightFar: number;
  106141. /**
  106142. * Gets the far clip of the Spotlight for texture projection.
  106143. */
  106144. /**
  106145. * Sets the far clip of the Spotlight for texture projection.
  106146. */
  106147. projectionTextureLightFar: number;
  106148. protected _projectionTextureUpDirection: Vector3;
  106149. /**
  106150. * Gets the Up vector of the Spotlight for texture projection.
  106151. */
  106152. /**
  106153. * Sets the Up vector of the Spotlight for texture projection.
  106154. */
  106155. projectionTextureUpDirection: Vector3;
  106156. private _projectionTexture;
  106157. /**
  106158. * Gets the projection texture of the light.
  106159. */
  106160. /**
  106161. * Sets the projection texture of the light.
  106162. */
  106163. projectionTexture: Nullable<BaseTexture>;
  106164. private _projectionTextureViewLightDirty;
  106165. private _projectionTextureProjectionLightDirty;
  106166. private _projectionTextureDirty;
  106167. private _projectionTextureViewTargetVector;
  106168. private _projectionTextureViewLightMatrix;
  106169. private _projectionTextureProjectionLightMatrix;
  106170. private _projectionTextureScalingMatrix;
  106171. /**
  106172. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106173. * It can cast shadows.
  106174. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106175. * @param name The light friendly name
  106176. * @param position The position of the spot light in the scene
  106177. * @param direction The direction of the light in the scene
  106178. * @param angle The cone angle of the light in Radians
  106179. * @param exponent The light decay speed with the distance from the emission spot
  106180. * @param scene The scene the lights belongs to
  106181. */
  106182. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106183. /**
  106184. * Returns the string "SpotLight".
  106185. * @returns the class name
  106186. */
  106187. getClassName(): string;
  106188. /**
  106189. * Returns the integer 2.
  106190. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106191. */
  106192. getTypeID(): number;
  106193. /**
  106194. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106195. */
  106196. protected _setDirection(value: Vector3): void;
  106197. /**
  106198. * Overrides the position setter to recompute the projection texture view light Matrix.
  106199. */
  106200. protected _setPosition(value: Vector3): void;
  106201. /**
  106202. * 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.
  106203. * Returns the SpotLight.
  106204. */
  106205. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106206. protected _computeProjectionTextureViewLightMatrix(): void;
  106207. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106208. /**
  106209. * Main function for light texture projection matrix computing.
  106210. */
  106211. protected _computeProjectionTextureMatrix(): void;
  106212. protected _buildUniformLayout(): void;
  106213. private _computeAngleValues;
  106214. /**
  106215. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106216. * @param effect The effect to update
  106217. * @param lightIndex The index of the light in the effect to update
  106218. * @returns The spot light
  106219. */
  106220. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106221. /**
  106222. * Disposes the light and the associated resources.
  106223. */
  106224. dispose(): void;
  106225. /**
  106226. * Prepares the list of defines specific to the light type.
  106227. * @param defines the list of defines
  106228. * @param lightIndex defines the index of the light for the effect
  106229. */
  106230. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106231. }
  106232. }
  106233. declare module BABYLON {
  106234. /**
  106235. * Gizmo that enables viewing a light
  106236. */
  106237. export class LightGizmo extends Gizmo {
  106238. private _lightMesh;
  106239. private _material;
  106240. private cachedPosition;
  106241. private cachedForward;
  106242. /**
  106243. * Creates a LightGizmo
  106244. * @param gizmoLayer The utility layer the gizmo will be added to
  106245. */
  106246. constructor(gizmoLayer?: UtilityLayerRenderer);
  106247. private _light;
  106248. /**
  106249. * The light that the gizmo is attached to
  106250. */
  106251. light: Nullable<Light>;
  106252. /**
  106253. * @hidden
  106254. * Updates the gizmo to match the attached mesh's position/rotation
  106255. */
  106256. protected _update(): void;
  106257. private static _Scale;
  106258. /**
  106259. * Creates the lines for a light mesh
  106260. */
  106261. private static _createLightLines;
  106262. /**
  106263. * Disposes of the light gizmo
  106264. */
  106265. dispose(): void;
  106266. private static _CreateHemisphericLightMesh;
  106267. private static _CreatePointLightMesh;
  106268. private static _CreateSpotLightMesh;
  106269. private static _CreateDirectionalLightMesh;
  106270. }
  106271. }
  106272. declare module BABYLON {
  106273. /** @hidden */
  106274. export var backgroundFragmentDeclaration: {
  106275. name: string;
  106276. shader: string;
  106277. };
  106278. }
  106279. declare module BABYLON {
  106280. /** @hidden */
  106281. export var backgroundUboDeclaration: {
  106282. name: string;
  106283. shader: string;
  106284. };
  106285. }
  106286. declare module BABYLON {
  106287. /** @hidden */
  106288. export var backgroundPixelShader: {
  106289. name: string;
  106290. shader: string;
  106291. };
  106292. }
  106293. declare module BABYLON {
  106294. /** @hidden */
  106295. export var backgroundVertexDeclaration: {
  106296. name: string;
  106297. shader: string;
  106298. };
  106299. }
  106300. declare module BABYLON {
  106301. /** @hidden */
  106302. export var backgroundVertexShader: {
  106303. name: string;
  106304. shader: string;
  106305. };
  106306. }
  106307. declare module BABYLON {
  106308. /**
  106309. * Background material used to create an efficient environement around your scene.
  106310. */
  106311. export class BackgroundMaterial extends PushMaterial {
  106312. /**
  106313. * Standard reflectance value at parallel view angle.
  106314. */
  106315. static StandardReflectance0: number;
  106316. /**
  106317. * Standard reflectance value at grazing angle.
  106318. */
  106319. static StandardReflectance90: number;
  106320. protected _primaryColor: Color3;
  106321. /**
  106322. * Key light Color (multiply against the environement texture)
  106323. */
  106324. primaryColor: Color3;
  106325. protected __perceptualColor: Nullable<Color3>;
  106326. /**
  106327. * Experimental Internal Use Only.
  106328. *
  106329. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106330. * This acts as a helper to set the primary color to a more "human friendly" value.
  106331. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106332. * output color as close as possible from the chosen value.
  106333. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106334. * part of lighting setup.)
  106335. */
  106336. _perceptualColor: Nullable<Color3>;
  106337. protected _primaryColorShadowLevel: float;
  106338. /**
  106339. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106340. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106341. */
  106342. primaryColorShadowLevel: float;
  106343. protected _primaryColorHighlightLevel: float;
  106344. /**
  106345. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106346. * The primary color is used at the level chosen to define what the white area would look.
  106347. */
  106348. primaryColorHighlightLevel: float;
  106349. protected _reflectionTexture: Nullable<BaseTexture>;
  106350. /**
  106351. * Reflection Texture used in the material.
  106352. * Should be author in a specific way for the best result (refer to the documentation).
  106353. */
  106354. reflectionTexture: Nullable<BaseTexture>;
  106355. protected _reflectionBlur: float;
  106356. /**
  106357. * Reflection Texture level of blur.
  106358. *
  106359. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106360. * texture twice.
  106361. */
  106362. reflectionBlur: float;
  106363. protected _diffuseTexture: Nullable<BaseTexture>;
  106364. /**
  106365. * Diffuse Texture used in the material.
  106366. * Should be author in a specific way for the best result (refer to the documentation).
  106367. */
  106368. diffuseTexture: Nullable<BaseTexture>;
  106369. protected _shadowLights: Nullable<IShadowLight[]>;
  106370. /**
  106371. * Specify the list of lights casting shadow on the material.
  106372. * All scene shadow lights will be included if null.
  106373. */
  106374. shadowLights: Nullable<IShadowLight[]>;
  106375. protected _shadowLevel: float;
  106376. /**
  106377. * Helps adjusting the shadow to a softer level if required.
  106378. * 0 means black shadows and 1 means no shadows.
  106379. */
  106380. shadowLevel: float;
  106381. protected _sceneCenter: Vector3;
  106382. /**
  106383. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106384. * It is usually zero but might be interesting to modify according to your setup.
  106385. */
  106386. sceneCenter: Vector3;
  106387. protected _opacityFresnel: boolean;
  106388. /**
  106389. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106390. * This helps ensuring a nice transition when the camera goes under the ground.
  106391. */
  106392. opacityFresnel: boolean;
  106393. protected _reflectionFresnel: boolean;
  106394. /**
  106395. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106396. * This helps adding a mirror texture on the ground.
  106397. */
  106398. reflectionFresnel: boolean;
  106399. protected _reflectionFalloffDistance: number;
  106400. /**
  106401. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106402. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106403. */
  106404. reflectionFalloffDistance: number;
  106405. protected _reflectionAmount: number;
  106406. /**
  106407. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106408. */
  106409. reflectionAmount: number;
  106410. protected _reflectionReflectance0: number;
  106411. /**
  106412. * This specifies the weight of the reflection at grazing angle.
  106413. */
  106414. reflectionReflectance0: number;
  106415. protected _reflectionReflectance90: number;
  106416. /**
  106417. * This specifies the weight of the reflection at a perpendicular point of view.
  106418. */
  106419. reflectionReflectance90: number;
  106420. /**
  106421. * Sets the reflection reflectance fresnel values according to the default standard
  106422. * empirically know to work well :-)
  106423. */
  106424. reflectionStandardFresnelWeight: number;
  106425. protected _useRGBColor: boolean;
  106426. /**
  106427. * Helps to directly use the maps channels instead of their level.
  106428. */
  106429. useRGBColor: boolean;
  106430. protected _enableNoise: boolean;
  106431. /**
  106432. * This helps reducing the banding effect that could occur on the background.
  106433. */
  106434. enableNoise: boolean;
  106435. /**
  106436. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106437. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106438. * Recommended to be keep at 1.0 except for special cases.
  106439. */
  106440. fovMultiplier: number;
  106441. private _fovMultiplier;
  106442. /**
  106443. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106444. */
  106445. useEquirectangularFOV: boolean;
  106446. private _maxSimultaneousLights;
  106447. /**
  106448. * Number of Simultaneous lights allowed on the material.
  106449. */
  106450. maxSimultaneousLights: int;
  106451. /**
  106452. * Default configuration related to image processing available in the Background Material.
  106453. */
  106454. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106455. /**
  106456. * Keep track of the image processing observer to allow dispose and replace.
  106457. */
  106458. private _imageProcessingObserver;
  106459. /**
  106460. * Attaches a new image processing configuration to the PBR Material.
  106461. * @param configuration (if null the scene configuration will be use)
  106462. */
  106463. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106464. /**
  106465. * Gets the image processing configuration used either in this material.
  106466. */
  106467. /**
  106468. * Sets the Default image processing configuration used either in the this material.
  106469. *
  106470. * If sets to null, the scene one is in use.
  106471. */
  106472. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106473. /**
  106474. * Gets wether the color curves effect is enabled.
  106475. */
  106476. /**
  106477. * Sets wether the color curves effect is enabled.
  106478. */
  106479. cameraColorCurvesEnabled: boolean;
  106480. /**
  106481. * Gets wether the color grading effect is enabled.
  106482. */
  106483. /**
  106484. * Gets wether the color grading effect is enabled.
  106485. */
  106486. cameraColorGradingEnabled: boolean;
  106487. /**
  106488. * Gets wether tonemapping is enabled or not.
  106489. */
  106490. /**
  106491. * Sets wether tonemapping is enabled or not
  106492. */
  106493. cameraToneMappingEnabled: boolean;
  106494. /**
  106495. * The camera exposure used on this material.
  106496. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106497. * This corresponds to a photographic exposure.
  106498. */
  106499. /**
  106500. * The camera exposure used on this material.
  106501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106502. * This corresponds to a photographic exposure.
  106503. */
  106504. cameraExposure: float;
  106505. /**
  106506. * Gets The camera contrast used on this material.
  106507. */
  106508. /**
  106509. * Sets The camera contrast used on this material.
  106510. */
  106511. cameraContrast: float;
  106512. /**
  106513. * Gets the Color Grading 2D Lookup Texture.
  106514. */
  106515. /**
  106516. * Sets the Color Grading 2D Lookup Texture.
  106517. */
  106518. cameraColorGradingTexture: Nullable<BaseTexture>;
  106519. /**
  106520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106522. * 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;
  106523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106524. */
  106525. /**
  106526. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106527. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106528. * 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;
  106529. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106530. */
  106531. cameraColorCurves: Nullable<ColorCurves>;
  106532. /**
  106533. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106534. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106535. */
  106536. switchToBGR: boolean;
  106537. private _renderTargets;
  106538. private _reflectionControls;
  106539. private _white;
  106540. private _primaryShadowColor;
  106541. private _primaryHighlightColor;
  106542. /**
  106543. * Instantiates a Background Material in the given scene
  106544. * @param name The friendly name of the material
  106545. * @param scene The scene to add the material to
  106546. */
  106547. constructor(name: string, scene: Scene);
  106548. /**
  106549. * Gets a boolean indicating that current material needs to register RTT
  106550. */
  106551. readonly hasRenderTargetTextures: boolean;
  106552. /**
  106553. * The entire material has been created in order to prevent overdraw.
  106554. * @returns false
  106555. */
  106556. needAlphaTesting(): boolean;
  106557. /**
  106558. * The entire material has been created in order to prevent overdraw.
  106559. * @returns true if blending is enable
  106560. */
  106561. needAlphaBlending(): boolean;
  106562. /**
  106563. * Checks wether the material is ready to be rendered for a given mesh.
  106564. * @param mesh The mesh to render
  106565. * @param subMesh The submesh to check against
  106566. * @param useInstances Specify wether or not the material is used with instances
  106567. * @returns true if all the dependencies are ready (Textures, Effects...)
  106568. */
  106569. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106570. /**
  106571. * Compute the primary color according to the chosen perceptual color.
  106572. */
  106573. private _computePrimaryColorFromPerceptualColor;
  106574. /**
  106575. * Compute the highlights and shadow colors according to their chosen levels.
  106576. */
  106577. private _computePrimaryColors;
  106578. /**
  106579. * Build the uniform buffer used in the material.
  106580. */
  106581. buildUniformLayout(): void;
  106582. /**
  106583. * Unbind the material.
  106584. */
  106585. unbind(): void;
  106586. /**
  106587. * Bind only the world matrix to the material.
  106588. * @param world The world matrix to bind.
  106589. */
  106590. bindOnlyWorldMatrix(world: Matrix): void;
  106591. /**
  106592. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106593. * @param world The world matrix to bind.
  106594. * @param subMesh The submesh to bind for.
  106595. */
  106596. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106597. /**
  106598. * Dispose the material.
  106599. * @param forceDisposeEffect Force disposal of the associated effect.
  106600. * @param forceDisposeTextures Force disposal of the associated textures.
  106601. */
  106602. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106603. /**
  106604. * Clones the material.
  106605. * @param name The cloned name.
  106606. * @returns The cloned material.
  106607. */
  106608. clone(name: string): BackgroundMaterial;
  106609. /**
  106610. * Serializes the current material to its JSON representation.
  106611. * @returns The JSON representation.
  106612. */
  106613. serialize(): any;
  106614. /**
  106615. * Gets the class name of the material
  106616. * @returns "BackgroundMaterial"
  106617. */
  106618. getClassName(): string;
  106619. /**
  106620. * Parse a JSON input to create back a background material.
  106621. * @param source The JSON data to parse
  106622. * @param scene The scene to create the parsed material in
  106623. * @param rootUrl The root url of the assets the material depends upon
  106624. * @returns the instantiated BackgroundMaterial.
  106625. */
  106626. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106627. }
  106628. }
  106629. declare module BABYLON {
  106630. /**
  106631. * Represents the different options available during the creation of
  106632. * a Environment helper.
  106633. *
  106634. * This can control the default ground, skybox and image processing setup of your scene.
  106635. */
  106636. export interface IEnvironmentHelperOptions {
  106637. /**
  106638. * Specifies wether or not to create a ground.
  106639. * True by default.
  106640. */
  106641. createGround: boolean;
  106642. /**
  106643. * Specifies the ground size.
  106644. * 15 by default.
  106645. */
  106646. groundSize: number;
  106647. /**
  106648. * The texture used on the ground for the main color.
  106649. * Comes from the BabylonJS CDN by default.
  106650. *
  106651. * Remarks: Can be either a texture or a url.
  106652. */
  106653. groundTexture: string | BaseTexture;
  106654. /**
  106655. * The color mixed in the ground texture by default.
  106656. * BabylonJS clearColor by default.
  106657. */
  106658. groundColor: Color3;
  106659. /**
  106660. * Specifies the ground opacity.
  106661. * 1 by default.
  106662. */
  106663. groundOpacity: number;
  106664. /**
  106665. * Enables the ground to receive shadows.
  106666. * True by default.
  106667. */
  106668. enableGroundShadow: boolean;
  106669. /**
  106670. * Helps preventing the shadow to be fully black on the ground.
  106671. * 0.5 by default.
  106672. */
  106673. groundShadowLevel: number;
  106674. /**
  106675. * Creates a mirror texture attach to the ground.
  106676. * false by default.
  106677. */
  106678. enableGroundMirror: boolean;
  106679. /**
  106680. * Specifies the ground mirror size ratio.
  106681. * 0.3 by default as the default kernel is 64.
  106682. */
  106683. groundMirrorSizeRatio: number;
  106684. /**
  106685. * Specifies the ground mirror blur kernel size.
  106686. * 64 by default.
  106687. */
  106688. groundMirrorBlurKernel: number;
  106689. /**
  106690. * Specifies the ground mirror visibility amount.
  106691. * 1 by default
  106692. */
  106693. groundMirrorAmount: number;
  106694. /**
  106695. * Specifies the ground mirror reflectance weight.
  106696. * This uses the standard weight of the background material to setup the fresnel effect
  106697. * of the mirror.
  106698. * 1 by default.
  106699. */
  106700. groundMirrorFresnelWeight: number;
  106701. /**
  106702. * Specifies the ground mirror Falloff distance.
  106703. * This can helps reducing the size of the reflection.
  106704. * 0 by Default.
  106705. */
  106706. groundMirrorFallOffDistance: number;
  106707. /**
  106708. * Specifies the ground mirror texture type.
  106709. * Unsigned Int by Default.
  106710. */
  106711. groundMirrorTextureType: number;
  106712. /**
  106713. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106714. * the shown objects.
  106715. */
  106716. groundYBias: number;
  106717. /**
  106718. * Specifies wether or not to create a skybox.
  106719. * True by default.
  106720. */
  106721. createSkybox: boolean;
  106722. /**
  106723. * Specifies the skybox size.
  106724. * 20 by default.
  106725. */
  106726. skyboxSize: number;
  106727. /**
  106728. * The texture used on the skybox for the main color.
  106729. * Comes from the BabylonJS CDN by default.
  106730. *
  106731. * Remarks: Can be either a texture or a url.
  106732. */
  106733. skyboxTexture: string | BaseTexture;
  106734. /**
  106735. * The color mixed in the skybox texture by default.
  106736. * BabylonJS clearColor by default.
  106737. */
  106738. skyboxColor: Color3;
  106739. /**
  106740. * The background rotation around the Y axis of the scene.
  106741. * This helps aligning the key lights of your scene with the background.
  106742. * 0 by default.
  106743. */
  106744. backgroundYRotation: number;
  106745. /**
  106746. * Compute automatically the size of the elements to best fit with the scene.
  106747. */
  106748. sizeAuto: boolean;
  106749. /**
  106750. * Default position of the rootMesh if autoSize is not true.
  106751. */
  106752. rootPosition: Vector3;
  106753. /**
  106754. * Sets up the image processing in the scene.
  106755. * true by default.
  106756. */
  106757. setupImageProcessing: boolean;
  106758. /**
  106759. * The texture used as your environment texture in the scene.
  106760. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  106761. *
  106762. * Remarks: Can be either a texture or a url.
  106763. */
  106764. environmentTexture: string | BaseTexture;
  106765. /**
  106766. * The value of the exposure to apply to the scene.
  106767. * 0.6 by default if setupImageProcessing is true.
  106768. */
  106769. cameraExposure: number;
  106770. /**
  106771. * The value of the contrast to apply to the scene.
  106772. * 1.6 by default if setupImageProcessing is true.
  106773. */
  106774. cameraContrast: number;
  106775. /**
  106776. * Specifies wether or not tonemapping should be enabled in the scene.
  106777. * true by default if setupImageProcessing is true.
  106778. */
  106779. toneMappingEnabled: boolean;
  106780. }
  106781. /**
  106782. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  106783. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  106784. * It also helps with the default setup of your imageProcessing configuration.
  106785. */
  106786. export class EnvironmentHelper {
  106787. /**
  106788. * Default ground texture URL.
  106789. */
  106790. private static _groundTextureCDNUrl;
  106791. /**
  106792. * Default skybox texture URL.
  106793. */
  106794. private static _skyboxTextureCDNUrl;
  106795. /**
  106796. * Default environment texture URL.
  106797. */
  106798. private static _environmentTextureCDNUrl;
  106799. /**
  106800. * Creates the default options for the helper.
  106801. */
  106802. private static _getDefaultOptions;
  106803. private _rootMesh;
  106804. /**
  106805. * Gets the root mesh created by the helper.
  106806. */
  106807. readonly rootMesh: Mesh;
  106808. private _skybox;
  106809. /**
  106810. * Gets the skybox created by the helper.
  106811. */
  106812. readonly skybox: Nullable<Mesh>;
  106813. private _skyboxTexture;
  106814. /**
  106815. * Gets the skybox texture created by the helper.
  106816. */
  106817. readonly skyboxTexture: Nullable<BaseTexture>;
  106818. private _skyboxMaterial;
  106819. /**
  106820. * Gets the skybox material created by the helper.
  106821. */
  106822. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  106823. private _ground;
  106824. /**
  106825. * Gets the ground mesh created by the helper.
  106826. */
  106827. readonly ground: Nullable<Mesh>;
  106828. private _groundTexture;
  106829. /**
  106830. * Gets the ground texture created by the helper.
  106831. */
  106832. readonly groundTexture: Nullable<BaseTexture>;
  106833. private _groundMirror;
  106834. /**
  106835. * Gets the ground mirror created by the helper.
  106836. */
  106837. readonly groundMirror: Nullable<MirrorTexture>;
  106838. /**
  106839. * Gets the ground mirror render list to helps pushing the meshes
  106840. * you wish in the ground reflection.
  106841. */
  106842. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  106843. private _groundMaterial;
  106844. /**
  106845. * Gets the ground material created by the helper.
  106846. */
  106847. readonly groundMaterial: Nullable<BackgroundMaterial>;
  106848. /**
  106849. * Stores the creation options.
  106850. */
  106851. private readonly _scene;
  106852. private _options;
  106853. /**
  106854. * This observable will be notified with any error during the creation of the environment,
  106855. * mainly texture creation errors.
  106856. */
  106857. onErrorObservable: Observable<{
  106858. message?: string;
  106859. exception?: any;
  106860. }>;
  106861. /**
  106862. * constructor
  106863. * @param options Defines the options we want to customize the helper
  106864. * @param scene The scene to add the material to
  106865. */
  106866. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  106867. /**
  106868. * Updates the background according to the new options
  106869. * @param options
  106870. */
  106871. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  106872. /**
  106873. * Sets the primary color of all the available elements.
  106874. * @param color the main color to affect to the ground and the background
  106875. */
  106876. setMainColor(color: Color3): void;
  106877. /**
  106878. * Setup the image processing according to the specified options.
  106879. */
  106880. private _setupImageProcessing;
  106881. /**
  106882. * Setup the environment texture according to the specified options.
  106883. */
  106884. private _setupEnvironmentTexture;
  106885. /**
  106886. * Setup the background according to the specified options.
  106887. */
  106888. private _setupBackground;
  106889. /**
  106890. * Get the scene sizes according to the setup.
  106891. */
  106892. private _getSceneSize;
  106893. /**
  106894. * Setup the ground according to the specified options.
  106895. */
  106896. private _setupGround;
  106897. /**
  106898. * Setup the ground material according to the specified options.
  106899. */
  106900. private _setupGroundMaterial;
  106901. /**
  106902. * Setup the ground diffuse texture according to the specified options.
  106903. */
  106904. private _setupGroundDiffuseTexture;
  106905. /**
  106906. * Setup the ground mirror texture according to the specified options.
  106907. */
  106908. private _setupGroundMirrorTexture;
  106909. /**
  106910. * Setup the ground to receive the mirror texture.
  106911. */
  106912. private _setupMirrorInGroundMaterial;
  106913. /**
  106914. * Setup the skybox according to the specified options.
  106915. */
  106916. private _setupSkybox;
  106917. /**
  106918. * Setup the skybox material according to the specified options.
  106919. */
  106920. private _setupSkyboxMaterial;
  106921. /**
  106922. * Setup the skybox reflection texture according to the specified options.
  106923. */
  106924. private _setupSkyboxReflectionTexture;
  106925. private _errorHandler;
  106926. /**
  106927. * Dispose all the elements created by the Helper.
  106928. */
  106929. dispose(): void;
  106930. }
  106931. }
  106932. declare module BABYLON {
  106933. /**
  106934. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  106935. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  106936. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  106937. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106938. */
  106939. export class PhotoDome extends TransformNode {
  106940. /**
  106941. * Define the image as a Monoscopic panoramic 360 image.
  106942. */
  106943. static readonly MODE_MONOSCOPIC: number;
  106944. /**
  106945. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106946. */
  106947. static readonly MODE_TOPBOTTOM: number;
  106948. /**
  106949. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106950. */
  106951. static readonly MODE_SIDEBYSIDE: number;
  106952. private _useDirectMapping;
  106953. /**
  106954. * The texture being displayed on the sphere
  106955. */
  106956. protected _photoTexture: Texture;
  106957. /**
  106958. * Gets or sets the texture being displayed on the sphere
  106959. */
  106960. photoTexture: Texture;
  106961. /**
  106962. * Observable raised when an error occured while loading the 360 image
  106963. */
  106964. onLoadErrorObservable: Observable<string>;
  106965. /**
  106966. * The skybox material
  106967. */
  106968. protected _material: BackgroundMaterial;
  106969. /**
  106970. * The surface used for the skybox
  106971. */
  106972. protected _mesh: Mesh;
  106973. /**
  106974. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106975. * Also see the options.resolution property.
  106976. */
  106977. fovMultiplier: number;
  106978. private _imageMode;
  106979. /**
  106980. * Gets or set the current video mode for the video. It can be:
  106981. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  106982. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106983. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106984. */
  106985. imageMode: number;
  106986. /**
  106987. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  106988. * @param name Element's name, child elements will append suffixes for their own names.
  106989. * @param urlsOfPhoto defines the url of the photo to display
  106990. * @param options defines an object containing optional or exposed sub element properties
  106991. * @param onError defines a callback called when an error occured while loading the texture
  106992. */
  106993. constructor(name: string, urlOfPhoto: string, options: {
  106994. resolution?: number;
  106995. size?: number;
  106996. useDirectMapping?: boolean;
  106997. faceForward?: boolean;
  106998. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  106999. private _onBeforeCameraRenderObserver;
  107000. private _changeImageMode;
  107001. /**
  107002. * Releases resources associated with this node.
  107003. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107004. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107005. */
  107006. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107007. }
  107008. }
  107009. declare module BABYLON {
  107010. /** @hidden */
  107011. export var rgbdDecodePixelShader: {
  107012. name: string;
  107013. shader: string;
  107014. };
  107015. }
  107016. declare module BABYLON {
  107017. /**
  107018. * Class used to host texture specific utilities
  107019. */
  107020. export class BRDFTextureTools {
  107021. /**
  107022. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107023. * @param texture the texture to expand.
  107024. */
  107025. private static _ExpandDefaultBRDFTexture;
  107026. /**
  107027. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107028. * @param scene defines the hosting scene
  107029. * @returns the environment BRDF texture
  107030. */
  107031. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107032. private static _environmentBRDFBase64Texture;
  107033. }
  107034. }
  107035. declare module BABYLON {
  107036. /**
  107037. * @hidden
  107038. */
  107039. export interface IMaterialClearCoatDefines {
  107040. CLEARCOAT: boolean;
  107041. CLEARCOAT_DEFAULTIOR: boolean;
  107042. CLEARCOAT_TEXTURE: boolean;
  107043. CLEARCOAT_TEXTUREDIRECTUV: number;
  107044. CLEARCOAT_BUMP: boolean;
  107045. CLEARCOAT_BUMPDIRECTUV: number;
  107046. CLEARCOAT_TINT: boolean;
  107047. CLEARCOAT_TINT_TEXTURE: boolean;
  107048. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107049. /** @hidden */
  107050. _areTexturesDirty: boolean;
  107051. }
  107052. /**
  107053. * Define the code related to the clear coat parameters of the pbr material.
  107054. */
  107055. export class PBRClearCoatConfiguration {
  107056. /**
  107057. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107058. * The default fits with a polyurethane material.
  107059. */
  107060. private static readonly _DefaultIndexOfRefraction;
  107061. private _isEnabled;
  107062. /**
  107063. * Defines if the clear coat is enabled in the material.
  107064. */
  107065. isEnabled: boolean;
  107066. /**
  107067. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107068. */
  107069. intensity: number;
  107070. /**
  107071. * Defines the clear coat layer roughness.
  107072. */
  107073. roughness: number;
  107074. private _indexOfRefraction;
  107075. /**
  107076. * Defines the index of refraction of the clear coat.
  107077. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107078. * The default fits with a polyurethane material.
  107079. * Changing the default value is more performance intensive.
  107080. */
  107081. indexOfRefraction: number;
  107082. private _texture;
  107083. /**
  107084. * Stores the clear coat values in a texture.
  107085. */
  107086. texture: Nullable<BaseTexture>;
  107087. private _bumpTexture;
  107088. /**
  107089. * Define the clear coat specific bump texture.
  107090. */
  107091. bumpTexture: Nullable<BaseTexture>;
  107092. private _isTintEnabled;
  107093. /**
  107094. * Defines if the clear coat tint is enabled in the material.
  107095. */
  107096. isTintEnabled: boolean;
  107097. /**
  107098. * Defines the clear coat tint of the material.
  107099. * This is only use if tint is enabled
  107100. */
  107101. tintColor: Color3;
  107102. /**
  107103. * Defines the distance at which the tint color should be found in the
  107104. * clear coat media.
  107105. * This is only use if tint is enabled
  107106. */
  107107. tintColorAtDistance: number;
  107108. /**
  107109. * Defines the clear coat layer thickness.
  107110. * This is only use if tint is enabled
  107111. */
  107112. tintThickness: number;
  107113. private _tintTexture;
  107114. /**
  107115. * Stores the clear tint values in a texture.
  107116. * rgb is tint
  107117. * a is a thickness factor
  107118. */
  107119. tintTexture: Nullable<BaseTexture>;
  107120. /** @hidden */
  107121. private _internalMarkAllSubMeshesAsTexturesDirty;
  107122. /** @hidden */
  107123. _markAllSubMeshesAsTexturesDirty(): void;
  107124. /**
  107125. * Instantiate a new istance of clear coat configuration.
  107126. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107127. */
  107128. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107129. /**
  107130. * Gets wehter the submesh is ready to be used or not.
  107131. * @param defines the list of "defines" to update.
  107132. * @param scene defines the scene the material belongs to.
  107133. * @param engine defines the engine the material belongs to.
  107134. * @param disableBumpMap defines wether the material disables bump or not.
  107135. * @returns - boolean indicating that the submesh is ready or not.
  107136. */
  107137. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107138. /**
  107139. * Checks to see if a texture is used in the material.
  107140. * @param defines the list of "defines" to update.
  107141. * @param scene defines the scene to the material belongs to.
  107142. */
  107143. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107144. /**
  107145. * Binds the material data.
  107146. * @param uniformBuffer defines the Uniform buffer to fill in.
  107147. * @param scene defines the scene the material belongs to.
  107148. * @param engine defines the engine the material belongs to.
  107149. * @param disableBumpMap defines wether the material disables bump or not.
  107150. * @param isFrozen defines wether the material is frozen or not.
  107151. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107152. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107153. */
  107154. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107155. /**
  107156. * Checks to see if a texture is used in the material.
  107157. * @param texture - Base texture to use.
  107158. * @returns - Boolean specifying if a texture is used in the material.
  107159. */
  107160. hasTexture(texture: BaseTexture): boolean;
  107161. /**
  107162. * Returns an array of the actively used textures.
  107163. * @param activeTextures Array of BaseTextures
  107164. */
  107165. getActiveTextures(activeTextures: BaseTexture[]): void;
  107166. /**
  107167. * Returns the animatable textures.
  107168. * @param animatables Array of animatable textures.
  107169. */
  107170. getAnimatables(animatables: IAnimatable[]): void;
  107171. /**
  107172. * Disposes the resources of the material.
  107173. * @param forceDisposeTextures - Forces the disposal of all textures.
  107174. */
  107175. dispose(forceDisposeTextures?: boolean): void;
  107176. /**
  107177. * Get the current class name of the texture useful for serialization or dynamic coding.
  107178. * @returns "PBRClearCoatConfiguration"
  107179. */
  107180. getClassName(): string;
  107181. /**
  107182. * Add fallbacks to the effect fallbacks list.
  107183. * @param defines defines the Base texture to use.
  107184. * @param fallbacks defines the current fallback list.
  107185. * @param currentRank defines the current fallback rank.
  107186. * @returns the new fallback rank.
  107187. */
  107188. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107189. /**
  107190. * Add the required uniforms to the current list.
  107191. * @param uniforms defines the current uniform list.
  107192. */
  107193. static AddUniforms(uniforms: string[]): void;
  107194. /**
  107195. * Add the required samplers to the current list.
  107196. * @param samplers defines the current sampler list.
  107197. */
  107198. static AddSamplers(samplers: string[]): void;
  107199. /**
  107200. * Add the required uniforms to the current buffer.
  107201. * @param uniformBuffer defines the current uniform buffer.
  107202. */
  107203. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107204. /**
  107205. * Makes a duplicate of the current configuration into another one.
  107206. * @param clearCoatConfiguration define the config where to copy the info
  107207. */
  107208. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107209. /**
  107210. * Serializes this clear coat configuration.
  107211. * @returns - An object with the serialized config.
  107212. */
  107213. serialize(): any;
  107214. /**
  107215. * Parses a Clear Coat Configuration from a serialized object.
  107216. * @param source - Serialized object.
  107217. */
  107218. parse(source: any): void;
  107219. }
  107220. }
  107221. declare module BABYLON {
  107222. /**
  107223. * @hidden
  107224. */
  107225. export interface IMaterialAnisotropicDefines {
  107226. ANISOTROPIC: boolean;
  107227. ANISOTROPIC_TEXTURE: boolean;
  107228. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107229. MAINUV1: boolean;
  107230. _areTexturesDirty: boolean;
  107231. _needUVs: boolean;
  107232. }
  107233. /**
  107234. * Define the code related to the anisotropic parameters of the pbr material.
  107235. */
  107236. export class PBRAnisotropicConfiguration {
  107237. private _isEnabled;
  107238. /**
  107239. * Defines if the anisotropy is enabled in the material.
  107240. */
  107241. isEnabled: boolean;
  107242. /**
  107243. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107244. */
  107245. intensity: number;
  107246. /**
  107247. * Defines if the effect is along the tangents, bitangents or in between.
  107248. * By default, the effect is "strectching" the highlights along the tangents.
  107249. */
  107250. direction: Vector2;
  107251. private _texture;
  107252. /**
  107253. * Stores the anisotropy values in a texture.
  107254. * rg is direction (like normal from -1 to 1)
  107255. * b is a intensity
  107256. */
  107257. texture: Nullable<BaseTexture>;
  107258. /** @hidden */
  107259. private _internalMarkAllSubMeshesAsTexturesDirty;
  107260. /** @hidden */
  107261. _markAllSubMeshesAsTexturesDirty(): void;
  107262. /**
  107263. * Instantiate a new istance of anisotropy configuration.
  107264. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107265. */
  107266. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107267. /**
  107268. * Specifies that the submesh is ready to be used.
  107269. * @param defines the list of "defines" to update.
  107270. * @param scene defines the scene the material belongs to.
  107271. * @returns - boolean indicating that the submesh is ready or not.
  107272. */
  107273. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107274. /**
  107275. * Checks to see if a texture is used in the material.
  107276. * @param defines the list of "defines" to update.
  107277. * @param mesh the mesh we are preparing the defines for.
  107278. * @param scene defines the scene the material belongs to.
  107279. */
  107280. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107281. /**
  107282. * Binds the material data.
  107283. * @param uniformBuffer defines the Uniform buffer to fill in.
  107284. * @param scene defines the scene the material belongs to.
  107285. * @param isFrozen defines wether the material is frozen or not.
  107286. */
  107287. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107288. /**
  107289. * Checks to see if a texture is used in the material.
  107290. * @param texture - Base texture to use.
  107291. * @returns - Boolean specifying if a texture is used in the material.
  107292. */
  107293. hasTexture(texture: BaseTexture): boolean;
  107294. /**
  107295. * Returns an array of the actively used textures.
  107296. * @param activeTextures Array of BaseTextures
  107297. */
  107298. getActiveTextures(activeTextures: BaseTexture[]): void;
  107299. /**
  107300. * Returns the animatable textures.
  107301. * @param animatables Array of animatable textures.
  107302. */
  107303. getAnimatables(animatables: IAnimatable[]): void;
  107304. /**
  107305. * Disposes the resources of the material.
  107306. * @param forceDisposeTextures - Forces the disposal of all textures.
  107307. */
  107308. dispose(forceDisposeTextures?: boolean): void;
  107309. /**
  107310. * Get the current class name of the texture useful for serialization or dynamic coding.
  107311. * @returns "PBRAnisotropicConfiguration"
  107312. */
  107313. getClassName(): string;
  107314. /**
  107315. * Add fallbacks to the effect fallbacks list.
  107316. * @param defines defines the Base texture to use.
  107317. * @param fallbacks defines the current fallback list.
  107318. * @param currentRank defines the current fallback rank.
  107319. * @returns the new fallback rank.
  107320. */
  107321. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107322. /**
  107323. * Add the required uniforms to the current list.
  107324. * @param uniforms defines the current uniform list.
  107325. */
  107326. static AddUniforms(uniforms: string[]): void;
  107327. /**
  107328. * Add the required uniforms to the current buffer.
  107329. * @param uniformBuffer defines the current uniform buffer.
  107330. */
  107331. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107332. /**
  107333. * Add the required samplers to the current list.
  107334. * @param samplers defines the current sampler list.
  107335. */
  107336. static AddSamplers(samplers: string[]): void;
  107337. /**
  107338. * Makes a duplicate of the current configuration into another one.
  107339. * @param anisotropicConfiguration define the config where to copy the info
  107340. */
  107341. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107342. /**
  107343. * Serializes this anisotropy configuration.
  107344. * @returns - An object with the serialized config.
  107345. */
  107346. serialize(): any;
  107347. /**
  107348. * Parses a anisotropy Configuration from a serialized object.
  107349. * @param source - Serialized object.
  107350. */
  107351. parse(source: any): void;
  107352. }
  107353. }
  107354. declare module BABYLON {
  107355. /**
  107356. * @hidden
  107357. */
  107358. export interface IMaterialBRDFDefines {
  107359. BRDF_V_HEIGHT_CORRELATED: boolean;
  107360. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107361. SPHERICAL_HARMONICS: boolean;
  107362. /** @hidden */
  107363. _areMiscDirty: boolean;
  107364. }
  107365. /**
  107366. * Define the code related to the BRDF parameters of the pbr material.
  107367. */
  107368. export class PBRBRDFConfiguration {
  107369. /**
  107370. * Default value used for the energy conservation.
  107371. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107372. */
  107373. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107374. /**
  107375. * Default value used for the Smith Visibility Height Correlated mode.
  107376. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107377. */
  107378. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107379. /**
  107380. * Default value used for the IBL diffuse part.
  107381. * This can help switching back to the polynomials mode globally which is a tiny bit
  107382. * less GPU intensive at the drawback of a lower quality.
  107383. */
  107384. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107385. private _useEnergyConservation;
  107386. /**
  107387. * Defines if the material uses energy conservation.
  107388. */
  107389. useEnergyConservation: boolean;
  107390. private _useSmithVisibilityHeightCorrelated;
  107391. /**
  107392. * LEGACY Mode set to false
  107393. * Defines if the material uses height smith correlated visibility term.
  107394. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107395. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107396. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107397. * Not relying on height correlated will also disable energy conservation.
  107398. */
  107399. useSmithVisibilityHeightCorrelated: boolean;
  107400. private _useSphericalHarmonics;
  107401. /**
  107402. * LEGACY Mode set to false
  107403. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107404. * diffuse part of the IBL.
  107405. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107406. * to the ground truth.
  107407. */
  107408. useSphericalHarmonics: boolean;
  107409. /** @hidden */
  107410. private _internalMarkAllSubMeshesAsMiscDirty;
  107411. /** @hidden */
  107412. _markAllSubMeshesAsMiscDirty(): void;
  107413. /**
  107414. * Instantiate a new istance of clear coat configuration.
  107415. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107416. */
  107417. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107418. /**
  107419. * Checks to see if a texture is used in the material.
  107420. * @param defines the list of "defines" to update.
  107421. */
  107422. prepareDefines(defines: IMaterialBRDFDefines): void;
  107423. /**
  107424. * Get the current class name of the texture useful for serialization or dynamic coding.
  107425. * @returns "PBRClearCoatConfiguration"
  107426. */
  107427. getClassName(): string;
  107428. /**
  107429. * Makes a duplicate of the current configuration into another one.
  107430. * @param brdfConfiguration define the config where to copy the info
  107431. */
  107432. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107433. /**
  107434. * Serializes this BRDF configuration.
  107435. * @returns - An object with the serialized config.
  107436. */
  107437. serialize(): any;
  107438. /**
  107439. * Parses a BRDF Configuration from a serialized object.
  107440. * @param source - Serialized object.
  107441. */
  107442. parse(source: any): void;
  107443. }
  107444. }
  107445. declare module BABYLON {
  107446. /**
  107447. * @hidden
  107448. */
  107449. export interface IMaterialSheenDefines {
  107450. SHEEN: boolean;
  107451. SHEEN_TEXTURE: boolean;
  107452. SHEEN_TEXTUREDIRECTUV: number;
  107453. SHEEN_LINKWITHALBEDO: boolean;
  107454. /** @hidden */
  107455. _areTexturesDirty: boolean;
  107456. }
  107457. /**
  107458. * Define the code related to the Sheen parameters of the pbr material.
  107459. */
  107460. export class PBRSheenConfiguration {
  107461. private _isEnabled;
  107462. /**
  107463. * Defines if the material uses sheen.
  107464. */
  107465. isEnabled: boolean;
  107466. private _linkSheenWithAlbedo;
  107467. /**
  107468. * Defines if the sheen is linked to the sheen color.
  107469. */
  107470. linkSheenWithAlbedo: boolean;
  107471. /**
  107472. * Defines the sheen intensity.
  107473. */
  107474. intensity: number;
  107475. /**
  107476. * Defines the sheen color.
  107477. */
  107478. color: Color3;
  107479. private _texture;
  107480. /**
  107481. * Stores the sheen tint values in a texture.
  107482. * rgb is tint
  107483. * a is a intensity
  107484. */
  107485. texture: Nullable<BaseTexture>;
  107486. /** @hidden */
  107487. private _internalMarkAllSubMeshesAsTexturesDirty;
  107488. /** @hidden */
  107489. _markAllSubMeshesAsTexturesDirty(): void;
  107490. /**
  107491. * Instantiate a new istance of clear coat configuration.
  107492. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107493. */
  107494. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107495. /**
  107496. * Specifies that the submesh is ready to be used.
  107497. * @param defines the list of "defines" to update.
  107498. * @param scene defines the scene the material belongs to.
  107499. * @returns - boolean indicating that the submesh is ready or not.
  107500. */
  107501. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107502. /**
  107503. * Checks to see if a texture is used in the material.
  107504. * @param defines the list of "defines" to update.
  107505. * @param scene defines the scene the material belongs to.
  107506. */
  107507. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107508. /**
  107509. * Binds the material data.
  107510. * @param uniformBuffer defines the Uniform buffer to fill in.
  107511. * @param scene defines the scene the material belongs to.
  107512. * @param isFrozen defines wether the material is frozen or not.
  107513. */
  107514. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107515. /**
  107516. * Checks to see if a texture is used in the material.
  107517. * @param texture - Base texture to use.
  107518. * @returns - Boolean specifying if a texture is used in the material.
  107519. */
  107520. hasTexture(texture: BaseTexture): boolean;
  107521. /**
  107522. * Returns an array of the actively used textures.
  107523. * @param activeTextures Array of BaseTextures
  107524. */
  107525. getActiveTextures(activeTextures: BaseTexture[]): void;
  107526. /**
  107527. * Returns the animatable textures.
  107528. * @param animatables Array of animatable textures.
  107529. */
  107530. getAnimatables(animatables: IAnimatable[]): void;
  107531. /**
  107532. * Disposes the resources of the material.
  107533. * @param forceDisposeTextures - Forces the disposal of all textures.
  107534. */
  107535. dispose(forceDisposeTextures?: boolean): void;
  107536. /**
  107537. * Get the current class name of the texture useful for serialization or dynamic coding.
  107538. * @returns "PBRSheenConfiguration"
  107539. */
  107540. getClassName(): string;
  107541. /**
  107542. * Add fallbacks to the effect fallbacks list.
  107543. * @param defines defines the Base texture to use.
  107544. * @param fallbacks defines the current fallback list.
  107545. * @param currentRank defines the current fallback rank.
  107546. * @returns the new fallback rank.
  107547. */
  107548. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107549. /**
  107550. * Add the required uniforms to the current list.
  107551. * @param uniforms defines the current uniform list.
  107552. */
  107553. static AddUniforms(uniforms: string[]): void;
  107554. /**
  107555. * Add the required uniforms to the current buffer.
  107556. * @param uniformBuffer defines the current uniform buffer.
  107557. */
  107558. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107559. /**
  107560. * Add the required samplers to the current list.
  107561. * @param samplers defines the current sampler list.
  107562. */
  107563. static AddSamplers(samplers: string[]): void;
  107564. /**
  107565. * Makes a duplicate of the current configuration into another one.
  107566. * @param sheenConfiguration define the config where to copy the info
  107567. */
  107568. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107569. /**
  107570. * Serializes this BRDF configuration.
  107571. * @returns - An object with the serialized config.
  107572. */
  107573. serialize(): any;
  107574. /**
  107575. * Parses a Sheen Configuration from a serialized object.
  107576. * @param source - Serialized object.
  107577. */
  107578. parse(source: any): void;
  107579. }
  107580. }
  107581. declare module BABYLON {
  107582. /**
  107583. * @hidden
  107584. */
  107585. export interface IMaterialSubSurfaceDefines {
  107586. SUBSURFACE: boolean;
  107587. SS_REFRACTION: boolean;
  107588. SS_TRANSLUCENCY: boolean;
  107589. SS_SCATERRING: boolean;
  107590. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107591. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107592. SS_REFRACTIONMAP_3D: boolean;
  107593. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107594. SS_LODINREFRACTIONALPHA: boolean;
  107595. SS_GAMMAREFRACTION: boolean;
  107596. SS_RGBDREFRACTION: boolean;
  107597. SS_LINEARSPECULARREFRACTION: boolean;
  107598. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107599. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107600. /** @hidden */
  107601. _areTexturesDirty: boolean;
  107602. }
  107603. /**
  107604. * Define the code related to the sub surface parameters of the pbr material.
  107605. */
  107606. export class PBRSubSurfaceConfiguration {
  107607. private _isRefractionEnabled;
  107608. /**
  107609. * Defines if the refraction is enabled in the material.
  107610. */
  107611. isRefractionEnabled: boolean;
  107612. private _isTranslucencyEnabled;
  107613. /**
  107614. * Defines if the translucency is enabled in the material.
  107615. */
  107616. isTranslucencyEnabled: boolean;
  107617. private _isScatteringEnabled;
  107618. /**
  107619. * Defines the refraction intensity of the material.
  107620. * The refraction when enabled replaces the Diffuse part of the material.
  107621. * The intensity helps transitionning between diffuse and refraction.
  107622. */
  107623. refractionIntensity: number;
  107624. /**
  107625. * Defines the translucency intensity of the material.
  107626. * When translucency has been enabled, this defines how much of the "translucency"
  107627. * is addded to the diffuse part of the material.
  107628. */
  107629. translucencyIntensity: number;
  107630. /**
  107631. * Defines the scattering intensity of the material.
  107632. * When scattering has been enabled, this defines how much of the "scattered light"
  107633. * is addded to the diffuse part of the material.
  107634. */
  107635. scatteringIntensity: number;
  107636. private _thicknessTexture;
  107637. /**
  107638. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107639. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107640. * 0 would mean minimumThickness
  107641. * 1 would mean maximumThickness
  107642. * The other channels might be use as a mask to vary the different effects intensity.
  107643. */
  107644. thicknessTexture: Nullable<BaseTexture>;
  107645. private _refractionTexture;
  107646. /**
  107647. * Defines the texture to use for refraction.
  107648. */
  107649. refractionTexture: Nullable<BaseTexture>;
  107650. private _indexOfRefraction;
  107651. /**
  107652. * Defines the index of refraction used in the material.
  107653. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107654. */
  107655. indexOfRefraction: number;
  107656. private _invertRefractionY;
  107657. /**
  107658. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107659. */
  107660. invertRefractionY: boolean;
  107661. private _linkRefractionWithTransparency;
  107662. /**
  107663. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107664. * Materials half opaque for instance using refraction could benefit from this control.
  107665. */
  107666. linkRefractionWithTransparency: boolean;
  107667. /**
  107668. * Defines the minimum thickness stored in the thickness map.
  107669. * If no thickness map is defined, this value will be used to simulate thickness.
  107670. */
  107671. minimumThickness: number;
  107672. /**
  107673. * Defines the maximum thickness stored in the thickness map.
  107674. */
  107675. maximumThickness: number;
  107676. /**
  107677. * Defines the volume tint of the material.
  107678. * This is used for both translucency and scattering.
  107679. */
  107680. tintColor: Color3;
  107681. /**
  107682. * Defines the distance at which the tint color should be found in the media.
  107683. * This is used for refraction only.
  107684. */
  107685. tintColorAtDistance: number;
  107686. /**
  107687. * Defines how far each channel transmit through the media.
  107688. * It is defined as a color to simplify it selection.
  107689. */
  107690. diffusionDistance: Color3;
  107691. private _useMaskFromThicknessTexture;
  107692. /**
  107693. * Stores the intensity of the different subsurface effects in the thickness texture.
  107694. * * the green channel is the translucency intensity.
  107695. * * the blue channel is the scattering intensity.
  107696. * * the alpha channel is the refraction intensity.
  107697. */
  107698. useMaskFromThicknessTexture: boolean;
  107699. /** @hidden */
  107700. private _internalMarkAllSubMeshesAsTexturesDirty;
  107701. /** @hidden */
  107702. _markAllSubMeshesAsTexturesDirty(): void;
  107703. /**
  107704. * Instantiate a new istance of sub surface configuration.
  107705. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107706. */
  107707. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107708. /**
  107709. * Gets wehter the submesh is ready to be used or not.
  107710. * @param defines the list of "defines" to update.
  107711. * @param scene defines the scene the material belongs to.
  107712. * @returns - boolean indicating that the submesh is ready or not.
  107713. */
  107714. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  107715. /**
  107716. * Checks to see if a texture is used in the material.
  107717. * @param defines the list of "defines" to update.
  107718. * @param scene defines the scene to the material belongs to.
  107719. */
  107720. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  107721. /**
  107722. * Binds the material data.
  107723. * @param uniformBuffer defines the Uniform buffer to fill in.
  107724. * @param scene defines the scene the material belongs to.
  107725. * @param engine defines the engine the material belongs to.
  107726. * @param isFrozen defines wether the material is frozen or not.
  107727. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  107728. */
  107729. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  107730. /**
  107731. * Unbinds the material from the mesh.
  107732. * @param activeEffect defines the effect that should be unbound from.
  107733. * @returns true if unbound, otherwise false
  107734. */
  107735. unbind(activeEffect: Effect): boolean;
  107736. /**
  107737. * Returns the texture used for refraction or null if none is used.
  107738. * @param scene defines the scene the material belongs to.
  107739. * @returns - Refraction texture if present. If no refraction texture and refraction
  107740. * is linked with transparency, returns environment texture. Otherwise, returns null.
  107741. */
  107742. private _getRefractionTexture;
  107743. /**
  107744. * Returns true if alpha blending should be disabled.
  107745. */
  107746. readonly disableAlphaBlending: boolean;
  107747. /**
  107748. * Fills the list of render target textures.
  107749. * @param renderTargets the list of render targets to update
  107750. */
  107751. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  107752. /**
  107753. * Checks to see if a texture is used in the material.
  107754. * @param texture - Base texture to use.
  107755. * @returns - Boolean specifying if a texture is used in the material.
  107756. */
  107757. hasTexture(texture: BaseTexture): boolean;
  107758. /**
  107759. * Gets a boolean indicating that current material needs to register RTT
  107760. * @returns true if this uses a render target otherwise false.
  107761. */
  107762. hasRenderTargetTextures(): boolean;
  107763. /**
  107764. * Returns an array of the actively used textures.
  107765. * @param activeTextures Array of BaseTextures
  107766. */
  107767. getActiveTextures(activeTextures: BaseTexture[]): void;
  107768. /**
  107769. * Returns the animatable textures.
  107770. * @param animatables Array of animatable textures.
  107771. */
  107772. getAnimatables(animatables: IAnimatable[]): void;
  107773. /**
  107774. * Disposes the resources of the material.
  107775. * @param forceDisposeTextures - Forces the disposal of all textures.
  107776. */
  107777. dispose(forceDisposeTextures?: boolean): void;
  107778. /**
  107779. * Get the current class name of the texture useful for serialization or dynamic coding.
  107780. * @returns "PBRSubSurfaceConfiguration"
  107781. */
  107782. getClassName(): string;
  107783. /**
  107784. * Add fallbacks to the effect fallbacks list.
  107785. * @param defines defines the Base texture to use.
  107786. * @param fallbacks defines the current fallback list.
  107787. * @param currentRank defines the current fallback rank.
  107788. * @returns the new fallback rank.
  107789. */
  107790. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107791. /**
  107792. * Add the required uniforms to the current list.
  107793. * @param uniforms defines the current uniform list.
  107794. */
  107795. static AddUniforms(uniforms: string[]): void;
  107796. /**
  107797. * Add the required samplers to the current list.
  107798. * @param samplers defines the current sampler list.
  107799. */
  107800. static AddSamplers(samplers: string[]): void;
  107801. /**
  107802. * Add the required uniforms to the current buffer.
  107803. * @param uniformBuffer defines the current uniform buffer.
  107804. */
  107805. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107806. /**
  107807. * Makes a duplicate of the current configuration into another one.
  107808. * @param configuration define the config where to copy the info
  107809. */
  107810. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  107811. /**
  107812. * Serializes this Sub Surface configuration.
  107813. * @returns - An object with the serialized config.
  107814. */
  107815. serialize(): any;
  107816. /**
  107817. * Parses a Sub Surface Configuration from a serialized object.
  107818. * @param source - Serialized object.
  107819. */
  107820. parse(source: any): void;
  107821. }
  107822. }
  107823. declare module BABYLON {
  107824. /** @hidden */
  107825. export var pbrFragmentDeclaration: {
  107826. name: string;
  107827. shader: string;
  107828. };
  107829. }
  107830. declare module BABYLON {
  107831. /** @hidden */
  107832. export var pbrUboDeclaration: {
  107833. name: string;
  107834. shader: string;
  107835. };
  107836. }
  107837. declare module BABYLON {
  107838. /** @hidden */
  107839. export var pbrFragmentExtraDeclaration: {
  107840. name: string;
  107841. shader: string;
  107842. };
  107843. }
  107844. declare module BABYLON {
  107845. /** @hidden */
  107846. export var pbrFragmentSamplersDeclaration: {
  107847. name: string;
  107848. shader: string;
  107849. };
  107850. }
  107851. declare module BABYLON {
  107852. /** @hidden */
  107853. export var pbrHelperFunctions: {
  107854. name: string;
  107855. shader: string;
  107856. };
  107857. }
  107858. declare module BABYLON {
  107859. /** @hidden */
  107860. export var harmonicsFunctions: {
  107861. name: string;
  107862. shader: string;
  107863. };
  107864. }
  107865. declare module BABYLON {
  107866. /** @hidden */
  107867. export var pbrDirectLightingSetupFunctions: {
  107868. name: string;
  107869. shader: string;
  107870. };
  107871. }
  107872. declare module BABYLON {
  107873. /** @hidden */
  107874. export var pbrDirectLightingFalloffFunctions: {
  107875. name: string;
  107876. shader: string;
  107877. };
  107878. }
  107879. declare module BABYLON {
  107880. /** @hidden */
  107881. export var pbrBRDFFunctions: {
  107882. name: string;
  107883. shader: string;
  107884. };
  107885. }
  107886. declare module BABYLON {
  107887. /** @hidden */
  107888. export var pbrDirectLightingFunctions: {
  107889. name: string;
  107890. shader: string;
  107891. };
  107892. }
  107893. declare module BABYLON {
  107894. /** @hidden */
  107895. export var pbrIBLFunctions: {
  107896. name: string;
  107897. shader: string;
  107898. };
  107899. }
  107900. declare module BABYLON {
  107901. /** @hidden */
  107902. export var pbrDebug: {
  107903. name: string;
  107904. shader: string;
  107905. };
  107906. }
  107907. declare module BABYLON {
  107908. /** @hidden */
  107909. export var pbrPixelShader: {
  107910. name: string;
  107911. shader: string;
  107912. };
  107913. }
  107914. declare module BABYLON {
  107915. /** @hidden */
  107916. export var pbrVertexDeclaration: {
  107917. name: string;
  107918. shader: string;
  107919. };
  107920. }
  107921. declare module BABYLON {
  107922. /** @hidden */
  107923. export var pbrVertexShader: {
  107924. name: string;
  107925. shader: string;
  107926. };
  107927. }
  107928. declare module BABYLON {
  107929. /**
  107930. * Manages the defines for the PBR Material.
  107931. * @hidden
  107932. */
  107933. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  107934. PBR: boolean;
  107935. MAINUV1: boolean;
  107936. MAINUV2: boolean;
  107937. UV1: boolean;
  107938. UV2: boolean;
  107939. ALBEDO: boolean;
  107940. ALBEDODIRECTUV: number;
  107941. VERTEXCOLOR: boolean;
  107942. AMBIENT: boolean;
  107943. AMBIENTDIRECTUV: number;
  107944. AMBIENTINGRAYSCALE: boolean;
  107945. OPACITY: boolean;
  107946. VERTEXALPHA: boolean;
  107947. OPACITYDIRECTUV: number;
  107948. OPACITYRGB: boolean;
  107949. ALPHATEST: boolean;
  107950. DEPTHPREPASS: boolean;
  107951. ALPHABLEND: boolean;
  107952. ALPHAFROMALBEDO: boolean;
  107953. ALPHATESTVALUE: string;
  107954. SPECULAROVERALPHA: boolean;
  107955. RADIANCEOVERALPHA: boolean;
  107956. ALPHAFRESNEL: boolean;
  107957. LINEARALPHAFRESNEL: boolean;
  107958. PREMULTIPLYALPHA: boolean;
  107959. EMISSIVE: boolean;
  107960. EMISSIVEDIRECTUV: number;
  107961. REFLECTIVITY: boolean;
  107962. REFLECTIVITYDIRECTUV: number;
  107963. SPECULARTERM: boolean;
  107964. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107965. MICROSURFACEAUTOMATIC: boolean;
  107966. LODBASEDMICROSFURACE: boolean;
  107967. MICROSURFACEMAP: boolean;
  107968. MICROSURFACEMAPDIRECTUV: number;
  107969. METALLICWORKFLOW: boolean;
  107970. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107971. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107972. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107973. AOSTOREINMETALMAPRED: boolean;
  107974. ENVIRONMENTBRDF: boolean;
  107975. ENVIRONMENTBRDF_RGBD: boolean;
  107976. NORMAL: boolean;
  107977. TANGENT: boolean;
  107978. BUMP: boolean;
  107979. BUMPDIRECTUV: number;
  107980. OBJECTSPACE_NORMALMAP: boolean;
  107981. PARALLAX: boolean;
  107982. PARALLAXOCCLUSION: boolean;
  107983. NORMALXYSCALE: boolean;
  107984. LIGHTMAP: boolean;
  107985. LIGHTMAPDIRECTUV: number;
  107986. USELIGHTMAPASSHADOWMAP: boolean;
  107987. GAMMALIGHTMAP: boolean;
  107988. REFLECTION: boolean;
  107989. REFLECTIONMAP_3D: boolean;
  107990. REFLECTIONMAP_SPHERICAL: boolean;
  107991. REFLECTIONMAP_PLANAR: boolean;
  107992. REFLECTIONMAP_CUBIC: boolean;
  107993. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107994. REFLECTIONMAP_PROJECTION: boolean;
  107995. REFLECTIONMAP_SKYBOX: boolean;
  107996. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107997. REFLECTIONMAP_EXPLICIT: boolean;
  107998. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107999. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108000. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108001. INVERTCUBICMAP: boolean;
  108002. USESPHERICALFROMREFLECTIONMAP: boolean;
  108003. USEIRRADIANCEMAP: boolean;
  108004. SPHERICAL_HARMONICS: boolean;
  108005. USESPHERICALINVERTEX: boolean;
  108006. REFLECTIONMAP_OPPOSITEZ: boolean;
  108007. LODINREFLECTIONALPHA: boolean;
  108008. GAMMAREFLECTION: boolean;
  108009. RGBDREFLECTION: boolean;
  108010. LINEARSPECULARREFLECTION: boolean;
  108011. RADIANCEOCCLUSION: boolean;
  108012. HORIZONOCCLUSION: boolean;
  108013. INSTANCES: boolean;
  108014. NUM_BONE_INFLUENCERS: number;
  108015. BonesPerMesh: number;
  108016. BONETEXTURE: boolean;
  108017. NONUNIFORMSCALING: boolean;
  108018. MORPHTARGETS: boolean;
  108019. MORPHTARGETS_NORMAL: boolean;
  108020. MORPHTARGETS_TANGENT: boolean;
  108021. NUM_MORPH_INFLUENCERS: number;
  108022. IMAGEPROCESSING: boolean;
  108023. VIGNETTE: boolean;
  108024. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108025. VIGNETTEBLENDMODEOPAQUE: boolean;
  108026. TONEMAPPING: boolean;
  108027. TONEMAPPING_ACES: boolean;
  108028. CONTRAST: boolean;
  108029. COLORCURVES: boolean;
  108030. COLORGRADING: boolean;
  108031. COLORGRADING3D: boolean;
  108032. SAMPLER3DGREENDEPTH: boolean;
  108033. SAMPLER3DBGRMAP: boolean;
  108034. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108035. EXPOSURE: boolean;
  108036. MULTIVIEW: boolean;
  108037. USEPHYSICALLIGHTFALLOFF: boolean;
  108038. USEGLTFLIGHTFALLOFF: boolean;
  108039. TWOSIDEDLIGHTING: boolean;
  108040. SHADOWFLOAT: boolean;
  108041. CLIPPLANE: boolean;
  108042. CLIPPLANE2: boolean;
  108043. CLIPPLANE3: boolean;
  108044. CLIPPLANE4: boolean;
  108045. POINTSIZE: boolean;
  108046. FOG: boolean;
  108047. LOGARITHMICDEPTH: boolean;
  108048. FORCENORMALFORWARD: boolean;
  108049. SPECULARAA: boolean;
  108050. CLEARCOAT: boolean;
  108051. CLEARCOAT_DEFAULTIOR: boolean;
  108052. CLEARCOAT_TEXTURE: boolean;
  108053. CLEARCOAT_TEXTUREDIRECTUV: number;
  108054. CLEARCOAT_BUMP: boolean;
  108055. CLEARCOAT_BUMPDIRECTUV: number;
  108056. CLEARCOAT_TINT: boolean;
  108057. CLEARCOAT_TINT_TEXTURE: boolean;
  108058. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108059. ANISOTROPIC: boolean;
  108060. ANISOTROPIC_TEXTURE: boolean;
  108061. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108062. BRDF_V_HEIGHT_CORRELATED: boolean;
  108063. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108064. SHEEN: boolean;
  108065. SHEEN_TEXTURE: boolean;
  108066. SHEEN_TEXTUREDIRECTUV: number;
  108067. SHEEN_LINKWITHALBEDO: boolean;
  108068. SUBSURFACE: boolean;
  108069. SS_REFRACTION: boolean;
  108070. SS_TRANSLUCENCY: boolean;
  108071. SS_SCATERRING: boolean;
  108072. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108073. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108074. SS_REFRACTIONMAP_3D: boolean;
  108075. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108076. SS_LODINREFRACTIONALPHA: boolean;
  108077. SS_GAMMAREFRACTION: boolean;
  108078. SS_RGBDREFRACTION: boolean;
  108079. SS_LINEARSPECULARREFRACTION: boolean;
  108080. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108081. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108082. UNLIT: boolean;
  108083. DEBUGMODE: number;
  108084. /**
  108085. * Initializes the PBR Material defines.
  108086. */
  108087. constructor();
  108088. /**
  108089. * Resets the PBR Material defines.
  108090. */
  108091. reset(): void;
  108092. }
  108093. /**
  108094. * The Physically based material base class of BJS.
  108095. *
  108096. * This offers the main features of a standard PBR material.
  108097. * For more information, please refer to the documentation :
  108098. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108099. */
  108100. export abstract class PBRBaseMaterial extends PushMaterial {
  108101. /**
  108102. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108103. */
  108104. static readonly PBRMATERIAL_OPAQUE: number;
  108105. /**
  108106. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108107. */
  108108. static readonly PBRMATERIAL_ALPHATEST: number;
  108109. /**
  108110. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108111. */
  108112. static readonly PBRMATERIAL_ALPHABLEND: number;
  108113. /**
  108114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108115. * They are also discarded below the alpha cutoff threshold to improve performances.
  108116. */
  108117. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108118. /**
  108119. * Defines the default value of how much AO map is occluding the analytical lights
  108120. * (point spot...).
  108121. */
  108122. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108123. /**
  108124. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108125. */
  108126. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108127. /**
  108128. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108129. * to enhance interoperability with other engines.
  108130. */
  108131. static readonly LIGHTFALLOFF_GLTF: number;
  108132. /**
  108133. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108134. * to enhance interoperability with other materials.
  108135. */
  108136. static readonly LIGHTFALLOFF_STANDARD: number;
  108137. /**
  108138. * Intensity of the direct lights e.g. the four lights available in your scene.
  108139. * This impacts both the direct diffuse and specular highlights.
  108140. */
  108141. protected _directIntensity: number;
  108142. /**
  108143. * Intensity of the emissive part of the material.
  108144. * This helps controlling the emissive effect without modifying the emissive color.
  108145. */
  108146. protected _emissiveIntensity: number;
  108147. /**
  108148. * Intensity of the environment e.g. how much the environment will light the object
  108149. * either through harmonics for rough material or through the refelction for shiny ones.
  108150. */
  108151. protected _environmentIntensity: number;
  108152. /**
  108153. * This is a special control allowing the reduction of the specular highlights coming from the
  108154. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108155. */
  108156. protected _specularIntensity: number;
  108157. /**
  108158. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108159. */
  108160. private _lightingInfos;
  108161. /**
  108162. * Debug Control allowing disabling the bump map on this material.
  108163. */
  108164. protected _disableBumpMap: boolean;
  108165. /**
  108166. * AKA Diffuse Texture in standard nomenclature.
  108167. */
  108168. protected _albedoTexture: Nullable<BaseTexture>;
  108169. /**
  108170. * AKA Occlusion Texture in other nomenclature.
  108171. */
  108172. protected _ambientTexture: Nullable<BaseTexture>;
  108173. /**
  108174. * AKA Occlusion Texture Intensity in other nomenclature.
  108175. */
  108176. protected _ambientTextureStrength: number;
  108177. /**
  108178. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108179. * 1 means it completely occludes it
  108180. * 0 mean it has no impact
  108181. */
  108182. protected _ambientTextureImpactOnAnalyticalLights: number;
  108183. /**
  108184. * Stores the alpha values in a texture.
  108185. */
  108186. protected _opacityTexture: Nullable<BaseTexture>;
  108187. /**
  108188. * Stores the reflection values in a texture.
  108189. */
  108190. protected _reflectionTexture: Nullable<BaseTexture>;
  108191. /**
  108192. * Stores the emissive values in a texture.
  108193. */
  108194. protected _emissiveTexture: Nullable<BaseTexture>;
  108195. /**
  108196. * AKA Specular texture in other nomenclature.
  108197. */
  108198. protected _reflectivityTexture: Nullable<BaseTexture>;
  108199. /**
  108200. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108201. */
  108202. protected _metallicTexture: Nullable<BaseTexture>;
  108203. /**
  108204. * Specifies the metallic scalar of the metallic/roughness workflow.
  108205. * Can also be used to scale the metalness values of the metallic texture.
  108206. */
  108207. protected _metallic: Nullable<number>;
  108208. /**
  108209. * Specifies the roughness scalar of the metallic/roughness workflow.
  108210. * Can also be used to scale the roughness values of the metallic texture.
  108211. */
  108212. protected _roughness: Nullable<number>;
  108213. /**
  108214. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108215. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108216. */
  108217. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108218. /**
  108219. * Stores surface normal data used to displace a mesh in a texture.
  108220. */
  108221. protected _bumpTexture: Nullable<BaseTexture>;
  108222. /**
  108223. * Stores the pre-calculated light information of a mesh in a texture.
  108224. */
  108225. protected _lightmapTexture: Nullable<BaseTexture>;
  108226. /**
  108227. * The color of a material in ambient lighting.
  108228. */
  108229. protected _ambientColor: Color3;
  108230. /**
  108231. * AKA Diffuse Color in other nomenclature.
  108232. */
  108233. protected _albedoColor: Color3;
  108234. /**
  108235. * AKA Specular Color in other nomenclature.
  108236. */
  108237. protected _reflectivityColor: Color3;
  108238. /**
  108239. * The color applied when light is reflected from a material.
  108240. */
  108241. protected _reflectionColor: Color3;
  108242. /**
  108243. * The color applied when light is emitted from a material.
  108244. */
  108245. protected _emissiveColor: Color3;
  108246. /**
  108247. * AKA Glossiness in other nomenclature.
  108248. */
  108249. protected _microSurface: number;
  108250. /**
  108251. * Specifies that the material will use the light map as a show map.
  108252. */
  108253. protected _useLightmapAsShadowmap: boolean;
  108254. /**
  108255. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108256. * makes the reflect vector face the model (under horizon).
  108257. */
  108258. protected _useHorizonOcclusion: boolean;
  108259. /**
  108260. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108261. * too much the area relying on ambient texture to define their ambient occlusion.
  108262. */
  108263. protected _useRadianceOcclusion: boolean;
  108264. /**
  108265. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108266. */
  108267. protected _useAlphaFromAlbedoTexture: boolean;
  108268. /**
  108269. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108270. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108271. */
  108272. protected _useSpecularOverAlpha: boolean;
  108273. /**
  108274. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108275. */
  108276. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108277. /**
  108278. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108279. */
  108280. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108281. /**
  108282. * Specifies if the metallic texture contains the roughness information in its green channel.
  108283. */
  108284. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108285. /**
  108286. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108287. */
  108288. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108289. /**
  108290. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108291. */
  108292. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108293. /**
  108294. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108295. */
  108296. protected _useAmbientInGrayScale: boolean;
  108297. /**
  108298. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108299. * The material will try to infer what glossiness each pixel should be.
  108300. */
  108301. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108302. /**
  108303. * Defines the falloff type used in this material.
  108304. * It by default is Physical.
  108305. */
  108306. protected _lightFalloff: number;
  108307. /**
  108308. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108309. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108310. */
  108311. protected _useRadianceOverAlpha: boolean;
  108312. /**
  108313. * Allows using an object space normal map (instead of tangent space).
  108314. */
  108315. protected _useObjectSpaceNormalMap: boolean;
  108316. /**
  108317. * Allows using the bump map in parallax mode.
  108318. */
  108319. protected _useParallax: boolean;
  108320. /**
  108321. * Allows using the bump map in parallax occlusion mode.
  108322. */
  108323. protected _useParallaxOcclusion: boolean;
  108324. /**
  108325. * Controls the scale bias of the parallax mode.
  108326. */
  108327. protected _parallaxScaleBias: number;
  108328. /**
  108329. * If sets to true, disables all the lights affecting the material.
  108330. */
  108331. protected _disableLighting: boolean;
  108332. /**
  108333. * Number of Simultaneous lights allowed on the material.
  108334. */
  108335. protected _maxSimultaneousLights: number;
  108336. /**
  108337. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108338. */
  108339. protected _invertNormalMapX: boolean;
  108340. /**
  108341. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108342. */
  108343. protected _invertNormalMapY: boolean;
  108344. /**
  108345. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108346. */
  108347. protected _twoSidedLighting: boolean;
  108348. /**
  108349. * Defines the alpha limits in alpha test mode.
  108350. */
  108351. protected _alphaCutOff: number;
  108352. /**
  108353. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108354. */
  108355. protected _forceAlphaTest: boolean;
  108356. /**
  108357. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108358. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108359. */
  108360. protected _useAlphaFresnel: boolean;
  108361. /**
  108362. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108363. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108364. */
  108365. protected _useLinearAlphaFresnel: boolean;
  108366. /**
  108367. * The transparency mode of the material.
  108368. */
  108369. protected _transparencyMode: Nullable<number>;
  108370. /**
  108371. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108372. * from cos thetav and roughness:
  108373. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108374. */
  108375. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108376. /**
  108377. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108378. */
  108379. protected _forceIrradianceInFragment: boolean;
  108380. /**
  108381. * Force normal to face away from face.
  108382. */
  108383. protected _forceNormalForward: boolean;
  108384. /**
  108385. * Enables specular anti aliasing in the PBR shader.
  108386. * It will both interacts on the Geometry for analytical and IBL lighting.
  108387. * It also prefilter the roughness map based on the bump values.
  108388. */
  108389. protected _enableSpecularAntiAliasing: boolean;
  108390. /**
  108391. * Default configuration related to image processing available in the PBR Material.
  108392. */
  108393. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108394. /**
  108395. * Keep track of the image processing observer to allow dispose and replace.
  108396. */
  108397. private _imageProcessingObserver;
  108398. /**
  108399. * Attaches a new image processing configuration to the PBR Material.
  108400. * @param configuration
  108401. */
  108402. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108403. /**
  108404. * Stores the available render targets.
  108405. */
  108406. private _renderTargets;
  108407. /**
  108408. * Sets the global ambient color for the material used in lighting calculations.
  108409. */
  108410. private _globalAmbientColor;
  108411. /**
  108412. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108413. */
  108414. private _useLogarithmicDepth;
  108415. /**
  108416. * If set to true, no lighting calculations will be applied.
  108417. */
  108418. private _unlit;
  108419. private _debugMode;
  108420. /**
  108421. * @hidden
  108422. * This is reserved for the inspector.
  108423. * Defines the material debug mode.
  108424. * It helps seeing only some components of the material while troubleshooting.
  108425. */
  108426. debugMode: number;
  108427. /**
  108428. * @hidden
  108429. * This is reserved for the inspector.
  108430. * Specify from where on screen the debug mode should start.
  108431. * The value goes from -1 (full screen) to 1 (not visible)
  108432. * It helps with side by side comparison against the final render
  108433. * This defaults to -1
  108434. */
  108435. private debugLimit;
  108436. /**
  108437. * @hidden
  108438. * This is reserved for the inspector.
  108439. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108440. * You can use the factor to better multiply the final value.
  108441. */
  108442. private debugFactor;
  108443. /**
  108444. * Defines the clear coat layer parameters for the material.
  108445. */
  108446. readonly clearCoat: PBRClearCoatConfiguration;
  108447. /**
  108448. * Defines the anisotropic parameters for the material.
  108449. */
  108450. readonly anisotropy: PBRAnisotropicConfiguration;
  108451. /**
  108452. * Defines the BRDF parameters for the material.
  108453. */
  108454. readonly brdf: PBRBRDFConfiguration;
  108455. /**
  108456. * Defines the Sheen parameters for the material.
  108457. */
  108458. readonly sheen: PBRSheenConfiguration;
  108459. /**
  108460. * Defines the SubSurface parameters for the material.
  108461. */
  108462. readonly subSurface: PBRSubSurfaceConfiguration;
  108463. /**
  108464. * Custom callback helping to override the default shader used in the material.
  108465. */
  108466. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108467. /**
  108468. * Instantiates a new PBRMaterial instance.
  108469. *
  108470. * @param name The material name
  108471. * @param scene The scene the material will be use in.
  108472. */
  108473. constructor(name: string, scene: Scene);
  108474. /**
  108475. * Gets a boolean indicating that current material needs to register RTT
  108476. */
  108477. readonly hasRenderTargetTextures: boolean;
  108478. /**
  108479. * Gets the name of the material class.
  108480. */
  108481. getClassName(): string;
  108482. /**
  108483. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108484. */
  108485. /**
  108486. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108487. */
  108488. useLogarithmicDepth: boolean;
  108489. /**
  108490. * Gets the current transparency mode.
  108491. */
  108492. /**
  108493. * Sets the transparency mode of the material.
  108494. *
  108495. * | Value | Type | Description |
  108496. * | ----- | ----------------------------------- | ----------- |
  108497. * | 0 | OPAQUE | |
  108498. * | 1 | ALPHATEST | |
  108499. * | 2 | ALPHABLEND | |
  108500. * | 3 | ALPHATESTANDBLEND | |
  108501. *
  108502. */
  108503. transparencyMode: Nullable<number>;
  108504. /**
  108505. * Returns true if alpha blending should be disabled.
  108506. */
  108507. private readonly _disableAlphaBlending;
  108508. /**
  108509. * Specifies whether or not this material should be rendered in alpha blend mode.
  108510. */
  108511. needAlphaBlending(): boolean;
  108512. /**
  108513. * Specifies if the mesh will require alpha blending.
  108514. * @param mesh - BJS mesh.
  108515. */
  108516. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108517. /**
  108518. * Specifies whether or not this material should be rendered in alpha test mode.
  108519. */
  108520. needAlphaTesting(): boolean;
  108521. /**
  108522. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108523. */
  108524. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108525. /**
  108526. * Gets the texture used for the alpha test.
  108527. */
  108528. getAlphaTestTexture(): Nullable<BaseTexture>;
  108529. /**
  108530. * Specifies that the submesh is ready to be used.
  108531. * @param mesh - BJS mesh.
  108532. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108533. * @param useInstances - Specifies that instances should be used.
  108534. * @returns - boolean indicating that the submesh is ready or not.
  108535. */
  108536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108537. /**
  108538. * Specifies if the material uses metallic roughness workflow.
  108539. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108540. */
  108541. isMetallicWorkflow(): boolean;
  108542. private _prepareEffect;
  108543. private _prepareDefines;
  108544. /**
  108545. * Force shader compilation
  108546. */
  108547. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108548. clipPlane: boolean;
  108549. }>): void;
  108550. /**
  108551. * Initializes the uniform buffer layout for the shader.
  108552. */
  108553. buildUniformLayout(): void;
  108554. /**
  108555. * Unbinds the material from the mesh
  108556. */
  108557. unbind(): void;
  108558. /**
  108559. * Binds the submesh data.
  108560. * @param world - The world matrix.
  108561. * @param mesh - The BJS mesh.
  108562. * @param subMesh - A submesh of the BJS mesh.
  108563. */
  108564. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108565. /**
  108566. * Returns the animatable textures.
  108567. * @returns - Array of animatable textures.
  108568. */
  108569. getAnimatables(): IAnimatable[];
  108570. /**
  108571. * Returns the texture used for reflections.
  108572. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108573. */
  108574. private _getReflectionTexture;
  108575. /**
  108576. * Returns an array of the actively used textures.
  108577. * @returns - Array of BaseTextures
  108578. */
  108579. getActiveTextures(): BaseTexture[];
  108580. /**
  108581. * Checks to see if a texture is used in the material.
  108582. * @param texture - Base texture to use.
  108583. * @returns - Boolean specifying if a texture is used in the material.
  108584. */
  108585. hasTexture(texture: BaseTexture): boolean;
  108586. /**
  108587. * Disposes the resources of the material.
  108588. * @param forceDisposeEffect - Forces the disposal of effects.
  108589. * @param forceDisposeTextures - Forces the disposal of all textures.
  108590. */
  108591. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108592. }
  108593. }
  108594. declare module BABYLON {
  108595. /**
  108596. * The Physically based material of BJS.
  108597. *
  108598. * This offers the main features of a standard PBR material.
  108599. * For more information, please refer to the documentation :
  108600. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108601. */
  108602. export class PBRMaterial extends PBRBaseMaterial {
  108603. /**
  108604. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108605. */
  108606. static readonly PBRMATERIAL_OPAQUE: number;
  108607. /**
  108608. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108609. */
  108610. static readonly PBRMATERIAL_ALPHATEST: number;
  108611. /**
  108612. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108613. */
  108614. static readonly PBRMATERIAL_ALPHABLEND: number;
  108615. /**
  108616. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108617. * They are also discarded below the alpha cutoff threshold to improve performances.
  108618. */
  108619. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108620. /**
  108621. * Defines the default value of how much AO map is occluding the analytical lights
  108622. * (point spot...).
  108623. */
  108624. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108625. /**
  108626. * Intensity of the direct lights e.g. the four lights available in your scene.
  108627. * This impacts both the direct diffuse and specular highlights.
  108628. */
  108629. directIntensity: number;
  108630. /**
  108631. * Intensity of the emissive part of the material.
  108632. * This helps controlling the emissive effect without modifying the emissive color.
  108633. */
  108634. emissiveIntensity: number;
  108635. /**
  108636. * Intensity of the environment e.g. how much the environment will light the object
  108637. * either through harmonics for rough material or through the refelction for shiny ones.
  108638. */
  108639. environmentIntensity: number;
  108640. /**
  108641. * This is a special control allowing the reduction of the specular highlights coming from the
  108642. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108643. */
  108644. specularIntensity: number;
  108645. /**
  108646. * Debug Control allowing disabling the bump map on this material.
  108647. */
  108648. disableBumpMap: boolean;
  108649. /**
  108650. * AKA Diffuse Texture in standard nomenclature.
  108651. */
  108652. albedoTexture: BaseTexture;
  108653. /**
  108654. * AKA Occlusion Texture in other nomenclature.
  108655. */
  108656. ambientTexture: BaseTexture;
  108657. /**
  108658. * AKA Occlusion Texture Intensity in other nomenclature.
  108659. */
  108660. ambientTextureStrength: number;
  108661. /**
  108662. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108663. * 1 means it completely occludes it
  108664. * 0 mean it has no impact
  108665. */
  108666. ambientTextureImpactOnAnalyticalLights: number;
  108667. /**
  108668. * Stores the alpha values in a texture.
  108669. */
  108670. opacityTexture: BaseTexture;
  108671. /**
  108672. * Stores the reflection values in a texture.
  108673. */
  108674. reflectionTexture: Nullable<BaseTexture>;
  108675. /**
  108676. * Stores the emissive values in a texture.
  108677. */
  108678. emissiveTexture: BaseTexture;
  108679. /**
  108680. * AKA Specular texture in other nomenclature.
  108681. */
  108682. reflectivityTexture: BaseTexture;
  108683. /**
  108684. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108685. */
  108686. metallicTexture: BaseTexture;
  108687. /**
  108688. * Specifies the metallic scalar of the metallic/roughness workflow.
  108689. * Can also be used to scale the metalness values of the metallic texture.
  108690. */
  108691. metallic: Nullable<number>;
  108692. /**
  108693. * Specifies the roughness scalar of the metallic/roughness workflow.
  108694. * Can also be used to scale the roughness values of the metallic texture.
  108695. */
  108696. roughness: Nullable<number>;
  108697. /**
  108698. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108699. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108700. */
  108701. microSurfaceTexture: BaseTexture;
  108702. /**
  108703. * Stores surface normal data used to displace a mesh in a texture.
  108704. */
  108705. bumpTexture: BaseTexture;
  108706. /**
  108707. * Stores the pre-calculated light information of a mesh in a texture.
  108708. */
  108709. lightmapTexture: BaseTexture;
  108710. /**
  108711. * Stores the refracted light information in a texture.
  108712. */
  108713. refractionTexture: Nullable<BaseTexture>;
  108714. /**
  108715. * The color of a material in ambient lighting.
  108716. */
  108717. ambientColor: Color3;
  108718. /**
  108719. * AKA Diffuse Color in other nomenclature.
  108720. */
  108721. albedoColor: Color3;
  108722. /**
  108723. * AKA Specular Color in other nomenclature.
  108724. */
  108725. reflectivityColor: Color3;
  108726. /**
  108727. * The color reflected from the material.
  108728. */
  108729. reflectionColor: Color3;
  108730. /**
  108731. * The color emitted from the material.
  108732. */
  108733. emissiveColor: Color3;
  108734. /**
  108735. * AKA Glossiness in other nomenclature.
  108736. */
  108737. microSurface: number;
  108738. /**
  108739. * source material index of refraction (IOR)' / 'destination material IOR.
  108740. */
  108741. indexOfRefraction: number;
  108742. /**
  108743. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108744. */
  108745. invertRefractionY: boolean;
  108746. /**
  108747. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108748. * Materials half opaque for instance using refraction could benefit from this control.
  108749. */
  108750. linkRefractionWithTransparency: boolean;
  108751. /**
  108752. * If true, the light map contains occlusion information instead of lighting info.
  108753. */
  108754. useLightmapAsShadowmap: boolean;
  108755. /**
  108756. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108757. */
  108758. useAlphaFromAlbedoTexture: boolean;
  108759. /**
  108760. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108761. */
  108762. forceAlphaTest: boolean;
  108763. /**
  108764. * Defines the alpha limits in alpha test mode.
  108765. */
  108766. alphaCutOff: number;
  108767. /**
  108768. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108769. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108770. */
  108771. useSpecularOverAlpha: boolean;
  108772. /**
  108773. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108774. */
  108775. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108776. /**
  108777. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108778. */
  108779. useRoughnessFromMetallicTextureAlpha: boolean;
  108780. /**
  108781. * Specifies if the metallic texture contains the roughness information in its green channel.
  108782. */
  108783. useRoughnessFromMetallicTextureGreen: boolean;
  108784. /**
  108785. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108786. */
  108787. useMetallnessFromMetallicTextureBlue: boolean;
  108788. /**
  108789. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108790. */
  108791. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108792. /**
  108793. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108794. */
  108795. useAmbientInGrayScale: boolean;
  108796. /**
  108797. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108798. * The material will try to infer what glossiness each pixel should be.
  108799. */
  108800. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108801. /**
  108802. * BJS is using an harcoded light falloff based on a manually sets up range.
  108803. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108804. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108805. */
  108806. /**
  108807. * BJS is using an harcoded light falloff based on a manually sets up range.
  108808. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108809. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108810. */
  108811. usePhysicalLightFalloff: boolean;
  108812. /**
  108813. * In order to support the falloff compatibility with gltf, a special mode has been added
  108814. * to reproduce the gltf light falloff.
  108815. */
  108816. /**
  108817. * In order to support the falloff compatibility with gltf, a special mode has been added
  108818. * to reproduce the gltf light falloff.
  108819. */
  108820. useGLTFLightFalloff: boolean;
  108821. /**
  108822. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108823. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108824. */
  108825. useRadianceOverAlpha: boolean;
  108826. /**
  108827. * Allows using an object space normal map (instead of tangent space).
  108828. */
  108829. useObjectSpaceNormalMap: boolean;
  108830. /**
  108831. * Allows using the bump map in parallax mode.
  108832. */
  108833. useParallax: boolean;
  108834. /**
  108835. * Allows using the bump map in parallax occlusion mode.
  108836. */
  108837. useParallaxOcclusion: boolean;
  108838. /**
  108839. * Controls the scale bias of the parallax mode.
  108840. */
  108841. parallaxScaleBias: number;
  108842. /**
  108843. * If sets to true, disables all the lights affecting the material.
  108844. */
  108845. disableLighting: boolean;
  108846. /**
  108847. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108848. */
  108849. forceIrradianceInFragment: boolean;
  108850. /**
  108851. * Number of Simultaneous lights allowed on the material.
  108852. */
  108853. maxSimultaneousLights: number;
  108854. /**
  108855. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108856. */
  108857. invertNormalMapX: boolean;
  108858. /**
  108859. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108860. */
  108861. invertNormalMapY: boolean;
  108862. /**
  108863. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108864. */
  108865. twoSidedLighting: boolean;
  108866. /**
  108867. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108868. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108869. */
  108870. useAlphaFresnel: boolean;
  108871. /**
  108872. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108873. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108874. */
  108875. useLinearAlphaFresnel: boolean;
  108876. /**
  108877. * Let user defines the brdf lookup texture used for IBL.
  108878. * A default 8bit version is embedded but you could point at :
  108879. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  108880. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108881. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108882. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108883. */
  108884. environmentBRDFTexture: Nullable<BaseTexture>;
  108885. /**
  108886. * Force normal to face away from face.
  108887. */
  108888. forceNormalForward: boolean;
  108889. /**
  108890. * Enables specular anti aliasing in the PBR shader.
  108891. * It will both interacts on the Geometry for analytical and IBL lighting.
  108892. * It also prefilter the roughness map based on the bump values.
  108893. */
  108894. enableSpecularAntiAliasing: boolean;
  108895. /**
  108896. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108897. * makes the reflect vector face the model (under horizon).
  108898. */
  108899. useHorizonOcclusion: boolean;
  108900. /**
  108901. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108902. * too much the area relying on ambient texture to define their ambient occlusion.
  108903. */
  108904. useRadianceOcclusion: boolean;
  108905. /**
  108906. * If set to true, no lighting calculations will be applied.
  108907. */
  108908. unlit: boolean;
  108909. /**
  108910. * Gets the image processing configuration used either in this material.
  108911. */
  108912. /**
  108913. * Sets the Default image processing configuration used either in the this material.
  108914. *
  108915. * If sets to null, the scene one is in use.
  108916. */
  108917. imageProcessingConfiguration: ImageProcessingConfiguration;
  108918. /**
  108919. * Gets wether the color curves effect is enabled.
  108920. */
  108921. /**
  108922. * Sets wether the color curves effect is enabled.
  108923. */
  108924. cameraColorCurvesEnabled: boolean;
  108925. /**
  108926. * Gets wether the color grading effect is enabled.
  108927. */
  108928. /**
  108929. * Gets wether the color grading effect is enabled.
  108930. */
  108931. cameraColorGradingEnabled: boolean;
  108932. /**
  108933. * Gets wether tonemapping is enabled or not.
  108934. */
  108935. /**
  108936. * Sets wether tonemapping is enabled or not
  108937. */
  108938. cameraToneMappingEnabled: boolean;
  108939. /**
  108940. * The camera exposure used on this material.
  108941. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108942. * This corresponds to a photographic exposure.
  108943. */
  108944. /**
  108945. * The camera exposure used on this material.
  108946. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108947. * This corresponds to a photographic exposure.
  108948. */
  108949. cameraExposure: number;
  108950. /**
  108951. * Gets The camera contrast used on this material.
  108952. */
  108953. /**
  108954. * Sets The camera contrast used on this material.
  108955. */
  108956. cameraContrast: number;
  108957. /**
  108958. * Gets the Color Grading 2D Lookup Texture.
  108959. */
  108960. /**
  108961. * Sets the Color Grading 2D Lookup Texture.
  108962. */
  108963. cameraColorGradingTexture: Nullable<BaseTexture>;
  108964. /**
  108965. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108966. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108967. * 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;
  108968. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108969. */
  108970. /**
  108971. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108972. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108973. * 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;
  108974. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108975. */
  108976. cameraColorCurves: Nullable<ColorCurves>;
  108977. /**
  108978. * Instantiates a new PBRMaterial instance.
  108979. *
  108980. * @param name The material name
  108981. * @param scene The scene the material will be use in.
  108982. */
  108983. constructor(name: string, scene: Scene);
  108984. /**
  108985. * Returns the name of this material class.
  108986. */
  108987. getClassName(): string;
  108988. /**
  108989. * Makes a duplicate of the current material.
  108990. * @param name - name to use for the new material.
  108991. */
  108992. clone(name: string): PBRMaterial;
  108993. /**
  108994. * Serializes this PBR Material.
  108995. * @returns - An object with the serialized material.
  108996. */
  108997. serialize(): any;
  108998. /**
  108999. * Parses a PBR Material from a serialized object.
  109000. * @param source - Serialized object.
  109001. * @param scene - BJS scene instance.
  109002. * @param rootUrl - url for the scene object
  109003. * @returns - PBRMaterial
  109004. */
  109005. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109006. }
  109007. }
  109008. declare module BABYLON {
  109009. /**
  109010. * Direct draw surface info
  109011. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109012. */
  109013. export interface DDSInfo {
  109014. /**
  109015. * Width of the texture
  109016. */
  109017. width: number;
  109018. /**
  109019. * Width of the texture
  109020. */
  109021. height: number;
  109022. /**
  109023. * Number of Mipmaps for the texture
  109024. * @see https://en.wikipedia.org/wiki/Mipmap
  109025. */
  109026. mipmapCount: number;
  109027. /**
  109028. * If the textures format is a known fourCC format
  109029. * @see https://www.fourcc.org/
  109030. */
  109031. isFourCC: boolean;
  109032. /**
  109033. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109034. */
  109035. isRGB: boolean;
  109036. /**
  109037. * If the texture is a lumincance format
  109038. */
  109039. isLuminance: boolean;
  109040. /**
  109041. * If this is a cube texture
  109042. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109043. */
  109044. isCube: boolean;
  109045. /**
  109046. * If the texture is a compressed format eg. FOURCC_DXT1
  109047. */
  109048. isCompressed: boolean;
  109049. /**
  109050. * The dxgiFormat of the texture
  109051. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109052. */
  109053. dxgiFormat: number;
  109054. /**
  109055. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109056. */
  109057. textureType: number;
  109058. /**
  109059. * Sphericle polynomial created for the dds texture
  109060. */
  109061. sphericalPolynomial?: SphericalPolynomial;
  109062. }
  109063. /**
  109064. * Class used to provide DDS decompression tools
  109065. */
  109066. export class DDSTools {
  109067. /**
  109068. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109069. */
  109070. static StoreLODInAlphaChannel: boolean;
  109071. /**
  109072. * Gets DDS information from an array buffer
  109073. * @param arrayBuffer defines the array buffer to read data from
  109074. * @returns the DDS information
  109075. */
  109076. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109077. private static _FloatView;
  109078. private static _Int32View;
  109079. private static _ToHalfFloat;
  109080. private static _FromHalfFloat;
  109081. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109082. private static _GetHalfFloatRGBAArrayBuffer;
  109083. private static _GetFloatRGBAArrayBuffer;
  109084. private static _GetFloatAsUIntRGBAArrayBuffer;
  109085. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109086. private static _GetRGBAArrayBuffer;
  109087. private static _ExtractLongWordOrder;
  109088. private static _GetRGBArrayBuffer;
  109089. private static _GetLuminanceArrayBuffer;
  109090. /**
  109091. * Uploads DDS Levels to a Babylon Texture
  109092. * @hidden
  109093. */
  109094. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109095. }
  109096. interface Engine {
  109097. /**
  109098. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109099. * @param rootUrl defines the url where the file to load is located
  109100. * @param scene defines the current scene
  109101. * @param lodScale defines scale to apply to the mip map selection
  109102. * @param lodOffset defines offset to apply to the mip map selection
  109103. * @param onLoad defines an optional callback raised when the texture is loaded
  109104. * @param onError defines an optional callback raised if there is an issue to load the texture
  109105. * @param format defines the format of the data
  109106. * @param forcedExtension defines the extension to use to pick the right loader
  109107. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109108. * @returns the cube texture as an InternalTexture
  109109. */
  109110. 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;
  109111. }
  109112. }
  109113. declare module BABYLON {
  109114. /**
  109115. * Implementation of the DDS Texture Loader.
  109116. * @hidden
  109117. */
  109118. export class _DDSTextureLoader implements IInternalTextureLoader {
  109119. /**
  109120. * Defines wether the loader supports cascade loading the different faces.
  109121. */
  109122. readonly supportCascades: boolean;
  109123. /**
  109124. * This returns if the loader support the current file information.
  109125. * @param extension defines the file extension of the file being loaded
  109126. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109127. * @param fallback defines the fallback internal texture if any
  109128. * @param isBase64 defines whether the texture is encoded as a base64
  109129. * @param isBuffer defines whether the texture data are stored as a buffer
  109130. * @returns true if the loader can load the specified file
  109131. */
  109132. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109133. /**
  109134. * Transform the url before loading if required.
  109135. * @param rootUrl the url of the texture
  109136. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109137. * @returns the transformed texture
  109138. */
  109139. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109140. /**
  109141. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109142. * @param rootUrl the url of the texture
  109143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109144. * @returns the fallback texture
  109145. */
  109146. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109147. /**
  109148. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109149. * @param data contains the texture data
  109150. * @param texture defines the BabylonJS internal texture
  109151. * @param createPolynomials will be true if polynomials have been requested
  109152. * @param onLoad defines the callback to trigger once the texture is ready
  109153. * @param onError defines the callback to trigger in case of error
  109154. */
  109155. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109156. /**
  109157. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109158. * @param data contains the texture data
  109159. * @param texture defines the BabylonJS internal texture
  109160. * @param callback defines the method to call once ready to upload
  109161. */
  109162. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109163. }
  109164. }
  109165. declare module BABYLON {
  109166. /** @hidden */
  109167. export var rgbdEncodePixelShader: {
  109168. name: string;
  109169. shader: string;
  109170. };
  109171. }
  109172. declare module BABYLON {
  109173. /**
  109174. * Raw texture data and descriptor sufficient for WebGL texture upload
  109175. */
  109176. export interface EnvironmentTextureInfo {
  109177. /**
  109178. * Version of the environment map
  109179. */
  109180. version: number;
  109181. /**
  109182. * Width of image
  109183. */
  109184. width: number;
  109185. /**
  109186. * Irradiance information stored in the file.
  109187. */
  109188. irradiance: any;
  109189. /**
  109190. * Specular information stored in the file.
  109191. */
  109192. specular: any;
  109193. }
  109194. /**
  109195. * Sets of helpers addressing the serialization and deserialization of environment texture
  109196. * stored in a BabylonJS env file.
  109197. * Those files are usually stored as .env files.
  109198. */
  109199. export class EnvironmentTextureTools {
  109200. /**
  109201. * Magic number identifying the env file.
  109202. */
  109203. private static _MagicBytes;
  109204. /**
  109205. * Gets the environment info from an env file.
  109206. * @param data The array buffer containing the .env bytes.
  109207. * @returns the environment file info (the json header) if successfully parsed.
  109208. */
  109209. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109210. /**
  109211. * Creates an environment texture from a loaded cube texture.
  109212. * @param texture defines the cube texture to convert in env file
  109213. * @return a promise containing the environment data if succesfull.
  109214. */
  109215. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109216. /**
  109217. * Creates a JSON representation of the spherical data.
  109218. * @param texture defines the texture containing the polynomials
  109219. * @return the JSON representation of the spherical info
  109220. */
  109221. private static _CreateEnvTextureIrradiance;
  109222. /**
  109223. * Uploads the texture info contained in the env file to the GPU.
  109224. * @param texture defines the internal texture to upload to
  109225. * @param arrayBuffer defines the buffer cotaining the data to load
  109226. * @param info defines the texture info retrieved through the GetEnvInfo method
  109227. * @returns a promise
  109228. */
  109229. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109230. /**
  109231. * Uploads the levels of image data to the GPU.
  109232. * @param texture defines the internal texture to upload to
  109233. * @param imageData defines the array buffer views of image data [mipmap][face]
  109234. * @returns a promise
  109235. */
  109236. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109237. /**
  109238. * Uploads spherical polynomials information to the texture.
  109239. * @param texture defines the texture we are trying to upload the information to
  109240. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109241. */
  109242. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109243. /** @hidden */
  109244. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109245. }
  109246. }
  109247. declare module BABYLON {
  109248. /**
  109249. * Implementation of the ENV Texture Loader.
  109250. * @hidden
  109251. */
  109252. export class _ENVTextureLoader implements IInternalTextureLoader {
  109253. /**
  109254. * Defines wether the loader supports cascade loading the different faces.
  109255. */
  109256. readonly supportCascades: boolean;
  109257. /**
  109258. * This returns if the loader support the current file information.
  109259. * @param extension defines the file extension of the file being loaded
  109260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109261. * @param fallback defines the fallback internal texture if any
  109262. * @param isBase64 defines whether the texture is encoded as a base64
  109263. * @param isBuffer defines whether the texture data are stored as a buffer
  109264. * @returns true if the loader can load the specified file
  109265. */
  109266. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109267. /**
  109268. * Transform the url before loading if required.
  109269. * @param rootUrl the url of the texture
  109270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109271. * @returns the transformed texture
  109272. */
  109273. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109274. /**
  109275. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109276. * @param rootUrl the url of the texture
  109277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109278. * @returns the fallback texture
  109279. */
  109280. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109281. /**
  109282. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109283. * @param data contains the texture data
  109284. * @param texture defines the BabylonJS internal texture
  109285. * @param createPolynomials will be true if polynomials have been requested
  109286. * @param onLoad defines the callback to trigger once the texture is ready
  109287. * @param onError defines the callback to trigger in case of error
  109288. */
  109289. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109290. /**
  109291. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109292. * @param data contains the texture data
  109293. * @param texture defines the BabylonJS internal texture
  109294. * @param callback defines the method to call once ready to upload
  109295. */
  109296. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109297. }
  109298. }
  109299. declare module BABYLON {
  109300. /**
  109301. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109302. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109303. */
  109304. export class KhronosTextureContainer {
  109305. /** contents of the KTX container file */
  109306. arrayBuffer: any;
  109307. private static HEADER_LEN;
  109308. private static COMPRESSED_2D;
  109309. private static COMPRESSED_3D;
  109310. private static TEX_2D;
  109311. private static TEX_3D;
  109312. /**
  109313. * Gets the openGL type
  109314. */
  109315. glType: number;
  109316. /**
  109317. * Gets the openGL type size
  109318. */
  109319. glTypeSize: number;
  109320. /**
  109321. * Gets the openGL format
  109322. */
  109323. glFormat: number;
  109324. /**
  109325. * Gets the openGL internal format
  109326. */
  109327. glInternalFormat: number;
  109328. /**
  109329. * Gets the base internal format
  109330. */
  109331. glBaseInternalFormat: number;
  109332. /**
  109333. * Gets image width in pixel
  109334. */
  109335. pixelWidth: number;
  109336. /**
  109337. * Gets image height in pixel
  109338. */
  109339. pixelHeight: number;
  109340. /**
  109341. * Gets image depth in pixels
  109342. */
  109343. pixelDepth: number;
  109344. /**
  109345. * Gets the number of array elements
  109346. */
  109347. numberOfArrayElements: number;
  109348. /**
  109349. * Gets the number of faces
  109350. */
  109351. numberOfFaces: number;
  109352. /**
  109353. * Gets the number of mipmap levels
  109354. */
  109355. numberOfMipmapLevels: number;
  109356. /**
  109357. * Gets the bytes of key value data
  109358. */
  109359. bytesOfKeyValueData: number;
  109360. /**
  109361. * Gets the load type
  109362. */
  109363. loadType: number;
  109364. /**
  109365. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109366. */
  109367. isInvalid: boolean;
  109368. /**
  109369. * Creates a new KhronosTextureContainer
  109370. * @param arrayBuffer contents of the KTX container file
  109371. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109372. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109373. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109374. */
  109375. constructor(
  109376. /** contents of the KTX container file */
  109377. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109378. /**
  109379. * Uploads KTX content to a Babylon Texture.
  109380. * It is assumed that the texture has already been created & is currently bound
  109381. * @hidden
  109382. */
  109383. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109384. private _upload2DCompressedLevels;
  109385. }
  109386. }
  109387. declare module BABYLON {
  109388. /**
  109389. * Implementation of the KTX Texture Loader.
  109390. * @hidden
  109391. */
  109392. export class _KTXTextureLoader implements IInternalTextureLoader {
  109393. /**
  109394. * Defines wether the loader supports cascade loading the different faces.
  109395. */
  109396. readonly supportCascades: boolean;
  109397. /**
  109398. * This returns if the loader support the current file information.
  109399. * @param extension defines the file extension of the file being loaded
  109400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109401. * @param fallback defines the fallback internal texture if any
  109402. * @param isBase64 defines whether the texture is encoded as a base64
  109403. * @param isBuffer defines whether the texture data are stored as a buffer
  109404. * @returns true if the loader can load the specified file
  109405. */
  109406. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109407. /**
  109408. * Transform the url before loading if required.
  109409. * @param rootUrl the url of the texture
  109410. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109411. * @returns the transformed texture
  109412. */
  109413. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109414. /**
  109415. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109416. * @param rootUrl the url of the texture
  109417. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109418. * @returns the fallback texture
  109419. */
  109420. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109421. /**
  109422. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109423. * @param data contains the texture data
  109424. * @param texture defines the BabylonJS internal texture
  109425. * @param createPolynomials will be true if polynomials have been requested
  109426. * @param onLoad defines the callback to trigger once the texture is ready
  109427. * @param onError defines the callback to trigger in case of error
  109428. */
  109429. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109430. /**
  109431. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109432. * @param data contains the texture data
  109433. * @param texture defines the BabylonJS internal texture
  109434. * @param callback defines the method to call once ready to upload
  109435. */
  109436. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109437. }
  109438. }
  109439. declare module BABYLON {
  109440. /** @hidden */
  109441. export var _forceSceneHelpersToBundle: boolean;
  109442. interface Scene {
  109443. /**
  109444. * Creates a default light for the scene.
  109445. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109446. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109447. */
  109448. createDefaultLight(replace?: boolean): void;
  109449. /**
  109450. * Creates a default camera for the scene.
  109451. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109452. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109453. * @param replace has default false, when true replaces the active camera in the scene
  109454. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109455. */
  109456. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109457. /**
  109458. * Creates a default camera and a default light.
  109459. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109460. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109461. * @param replace has the default false, when true replaces the active camera/light in the scene
  109462. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109463. */
  109464. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109465. /**
  109466. * Creates a new sky box
  109467. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109468. * @param environmentTexture defines the texture to use as environment texture
  109469. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109470. * @param scale defines the overall scale of the skybox
  109471. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109472. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109473. * @returns a new mesh holding the sky box
  109474. */
  109475. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109476. /**
  109477. * Creates a new environment
  109478. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109479. * @param options defines the options you can use to configure the environment
  109480. * @returns the new EnvironmentHelper
  109481. */
  109482. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109483. /**
  109484. * Creates a new VREXperienceHelper
  109485. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109486. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109487. * @returns a new VREXperienceHelper
  109488. */
  109489. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109490. /**
  109491. * Creates a new XREXperienceHelper
  109492. * @see http://doc.babylonjs.com/how_to/webxr
  109493. * @returns a promise for a new XREXperienceHelper
  109494. */
  109495. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109496. }
  109497. }
  109498. declare module BABYLON {
  109499. /**
  109500. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109501. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109502. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109503. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109504. */
  109505. export class VideoDome extends TransformNode {
  109506. /**
  109507. * Define the video source as a Monoscopic panoramic 360 video.
  109508. */
  109509. static readonly MODE_MONOSCOPIC: number;
  109510. /**
  109511. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109512. */
  109513. static readonly MODE_TOPBOTTOM: number;
  109514. /**
  109515. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109516. */
  109517. static readonly MODE_SIDEBYSIDE: number;
  109518. private _useDirectMapping;
  109519. /**
  109520. * The video texture being displayed on the sphere
  109521. */
  109522. protected _videoTexture: VideoTexture;
  109523. /**
  109524. * Gets the video texture being displayed on the sphere
  109525. */
  109526. readonly videoTexture: VideoTexture;
  109527. /**
  109528. * The skybox material
  109529. */
  109530. protected _material: BackgroundMaterial;
  109531. /**
  109532. * The surface used for the skybox
  109533. */
  109534. protected _mesh: Mesh;
  109535. /**
  109536. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109537. * Also see the options.resolution property.
  109538. */
  109539. fovMultiplier: number;
  109540. private _videoMode;
  109541. /**
  109542. * Gets or set the current video mode for the video. It can be:
  109543. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109544. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109545. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109546. */
  109547. videoMode: number;
  109548. /**
  109549. * Oberserver used in Stereoscopic VR Mode.
  109550. */
  109551. private _onBeforeCameraRenderObserver;
  109552. /**
  109553. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109554. * @param name Element's name, child elements will append suffixes for their own names.
  109555. * @param urlsOrVideo defines the url(s) or the video element to use
  109556. * @param options An object containing optional or exposed sub element properties
  109557. */
  109558. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109559. resolution?: number;
  109560. clickToPlay?: boolean;
  109561. autoPlay?: boolean;
  109562. loop?: boolean;
  109563. size?: number;
  109564. poster?: string;
  109565. faceForward?: boolean;
  109566. useDirectMapping?: boolean;
  109567. }, scene: Scene);
  109568. private _changeVideoMode;
  109569. /**
  109570. * Releases resources associated with this node.
  109571. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109572. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109573. */
  109574. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109575. }
  109576. }
  109577. declare module BABYLON {
  109578. /**
  109579. * This class can be used to get instrumentation data from a Babylon engine
  109580. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109581. */
  109582. export class EngineInstrumentation implements IDisposable {
  109583. /**
  109584. * Define the instrumented engine.
  109585. */
  109586. engine: Engine;
  109587. private _captureGPUFrameTime;
  109588. private _gpuFrameTimeToken;
  109589. private _gpuFrameTime;
  109590. private _captureShaderCompilationTime;
  109591. private _shaderCompilationTime;
  109592. private _onBeginFrameObserver;
  109593. private _onEndFrameObserver;
  109594. private _onBeforeShaderCompilationObserver;
  109595. private _onAfterShaderCompilationObserver;
  109596. /**
  109597. * Gets the perf counter used for GPU frame time
  109598. */
  109599. readonly gpuFrameTimeCounter: PerfCounter;
  109600. /**
  109601. * Gets the GPU frame time capture status
  109602. */
  109603. /**
  109604. * Enable or disable the GPU frame time capture
  109605. */
  109606. captureGPUFrameTime: boolean;
  109607. /**
  109608. * Gets the perf counter used for shader compilation time
  109609. */
  109610. readonly shaderCompilationTimeCounter: PerfCounter;
  109611. /**
  109612. * Gets the shader compilation time capture status
  109613. */
  109614. /**
  109615. * Enable or disable the shader compilation time capture
  109616. */
  109617. captureShaderCompilationTime: boolean;
  109618. /**
  109619. * Instantiates a new engine instrumentation.
  109620. * This class can be used to get instrumentation data from a Babylon engine
  109621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109622. * @param engine Defines the engine to instrument
  109623. */
  109624. constructor(
  109625. /**
  109626. * Define the instrumented engine.
  109627. */
  109628. engine: Engine);
  109629. /**
  109630. * Dispose and release associated resources.
  109631. */
  109632. dispose(): void;
  109633. }
  109634. }
  109635. declare module BABYLON {
  109636. /**
  109637. * This class can be used to get instrumentation data from a Babylon engine
  109638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109639. */
  109640. export class SceneInstrumentation implements IDisposable {
  109641. /**
  109642. * Defines the scene to instrument
  109643. */
  109644. scene: Scene;
  109645. private _captureActiveMeshesEvaluationTime;
  109646. private _activeMeshesEvaluationTime;
  109647. private _captureRenderTargetsRenderTime;
  109648. private _renderTargetsRenderTime;
  109649. private _captureFrameTime;
  109650. private _frameTime;
  109651. private _captureRenderTime;
  109652. private _renderTime;
  109653. private _captureInterFrameTime;
  109654. private _interFrameTime;
  109655. private _captureParticlesRenderTime;
  109656. private _particlesRenderTime;
  109657. private _captureSpritesRenderTime;
  109658. private _spritesRenderTime;
  109659. private _capturePhysicsTime;
  109660. private _physicsTime;
  109661. private _captureAnimationsTime;
  109662. private _animationsTime;
  109663. private _captureCameraRenderTime;
  109664. private _cameraRenderTime;
  109665. private _onBeforeActiveMeshesEvaluationObserver;
  109666. private _onAfterActiveMeshesEvaluationObserver;
  109667. private _onBeforeRenderTargetsRenderObserver;
  109668. private _onAfterRenderTargetsRenderObserver;
  109669. private _onAfterRenderObserver;
  109670. private _onBeforeDrawPhaseObserver;
  109671. private _onAfterDrawPhaseObserver;
  109672. private _onBeforeAnimationsObserver;
  109673. private _onBeforeParticlesRenderingObserver;
  109674. private _onAfterParticlesRenderingObserver;
  109675. private _onBeforeSpritesRenderingObserver;
  109676. private _onAfterSpritesRenderingObserver;
  109677. private _onBeforePhysicsObserver;
  109678. private _onAfterPhysicsObserver;
  109679. private _onAfterAnimationsObserver;
  109680. private _onBeforeCameraRenderObserver;
  109681. private _onAfterCameraRenderObserver;
  109682. /**
  109683. * Gets the perf counter used for active meshes evaluation time
  109684. */
  109685. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109686. /**
  109687. * Gets the active meshes evaluation time capture status
  109688. */
  109689. /**
  109690. * Enable or disable the active meshes evaluation time capture
  109691. */
  109692. captureActiveMeshesEvaluationTime: boolean;
  109693. /**
  109694. * Gets the perf counter used for render targets render time
  109695. */
  109696. readonly renderTargetsRenderTimeCounter: PerfCounter;
  109697. /**
  109698. * Gets the render targets render time capture status
  109699. */
  109700. /**
  109701. * Enable or disable the render targets render time capture
  109702. */
  109703. captureRenderTargetsRenderTime: boolean;
  109704. /**
  109705. * Gets the perf counter used for particles render time
  109706. */
  109707. readonly particlesRenderTimeCounter: PerfCounter;
  109708. /**
  109709. * Gets the particles render time capture status
  109710. */
  109711. /**
  109712. * Enable or disable the particles render time capture
  109713. */
  109714. captureParticlesRenderTime: boolean;
  109715. /**
  109716. * Gets the perf counter used for sprites render time
  109717. */
  109718. readonly spritesRenderTimeCounter: PerfCounter;
  109719. /**
  109720. * Gets the sprites render time capture status
  109721. */
  109722. /**
  109723. * Enable or disable the sprites render time capture
  109724. */
  109725. captureSpritesRenderTime: boolean;
  109726. /**
  109727. * Gets the perf counter used for physics time
  109728. */
  109729. readonly physicsTimeCounter: PerfCounter;
  109730. /**
  109731. * Gets the physics time capture status
  109732. */
  109733. /**
  109734. * Enable or disable the physics time capture
  109735. */
  109736. capturePhysicsTime: boolean;
  109737. /**
  109738. * Gets the perf counter used for animations time
  109739. */
  109740. readonly animationsTimeCounter: PerfCounter;
  109741. /**
  109742. * Gets the animations time capture status
  109743. */
  109744. /**
  109745. * Enable or disable the animations time capture
  109746. */
  109747. captureAnimationsTime: boolean;
  109748. /**
  109749. * Gets the perf counter used for frame time capture
  109750. */
  109751. readonly frameTimeCounter: PerfCounter;
  109752. /**
  109753. * Gets the frame time capture status
  109754. */
  109755. /**
  109756. * Enable or disable the frame time capture
  109757. */
  109758. captureFrameTime: boolean;
  109759. /**
  109760. * Gets the perf counter used for inter-frames time capture
  109761. */
  109762. readonly interFrameTimeCounter: PerfCounter;
  109763. /**
  109764. * Gets the inter-frames time capture status
  109765. */
  109766. /**
  109767. * Enable or disable the inter-frames time capture
  109768. */
  109769. captureInterFrameTime: boolean;
  109770. /**
  109771. * Gets the perf counter used for render time capture
  109772. */
  109773. readonly renderTimeCounter: PerfCounter;
  109774. /**
  109775. * Gets the render time capture status
  109776. */
  109777. /**
  109778. * Enable or disable the render time capture
  109779. */
  109780. captureRenderTime: boolean;
  109781. /**
  109782. * Gets the perf counter used for camera render time capture
  109783. */
  109784. readonly cameraRenderTimeCounter: PerfCounter;
  109785. /**
  109786. * Gets the camera render time capture status
  109787. */
  109788. /**
  109789. * Enable or disable the camera render time capture
  109790. */
  109791. captureCameraRenderTime: boolean;
  109792. /**
  109793. * Gets the perf counter used for draw calls
  109794. */
  109795. readonly drawCallsCounter: PerfCounter;
  109796. /**
  109797. * Instantiates a new scene instrumentation.
  109798. * This class can be used to get instrumentation data from a Babylon engine
  109799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109800. * @param scene Defines the scene to instrument
  109801. */
  109802. constructor(
  109803. /**
  109804. * Defines the scene to instrument
  109805. */
  109806. scene: Scene);
  109807. /**
  109808. * Dispose and release associated resources.
  109809. */
  109810. dispose(): void;
  109811. }
  109812. }
  109813. declare module BABYLON {
  109814. /** @hidden */
  109815. export var glowMapGenerationPixelShader: {
  109816. name: string;
  109817. shader: string;
  109818. };
  109819. }
  109820. declare module BABYLON {
  109821. /** @hidden */
  109822. export var glowMapGenerationVertexShader: {
  109823. name: string;
  109824. shader: string;
  109825. };
  109826. }
  109827. declare module BABYLON {
  109828. /**
  109829. * Effect layer options. This helps customizing the behaviour
  109830. * of the effect layer.
  109831. */
  109832. export interface IEffectLayerOptions {
  109833. /**
  109834. * Multiplication factor apply to the canvas size to compute the render target size
  109835. * used to generated the objects (the smaller the faster).
  109836. */
  109837. mainTextureRatio: number;
  109838. /**
  109839. * Enforces a fixed size texture to ensure effect stability across devices.
  109840. */
  109841. mainTextureFixedSize?: number;
  109842. /**
  109843. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  109844. */
  109845. alphaBlendingMode: number;
  109846. /**
  109847. * The camera attached to the layer.
  109848. */
  109849. camera: Nullable<Camera>;
  109850. /**
  109851. * The rendering group to draw the layer in.
  109852. */
  109853. renderingGroupId: number;
  109854. }
  109855. /**
  109856. * The effect layer Helps adding post process effect blended with the main pass.
  109857. *
  109858. * This can be for instance use to generate glow or higlight effects on the scene.
  109859. *
  109860. * The effect layer class can not be used directly and is intented to inherited from to be
  109861. * customized per effects.
  109862. */
  109863. export abstract class EffectLayer {
  109864. private _vertexBuffers;
  109865. private _indexBuffer;
  109866. private _cachedDefines;
  109867. private _effectLayerMapGenerationEffect;
  109868. private _effectLayerOptions;
  109869. private _mergeEffect;
  109870. protected _scene: Scene;
  109871. protected _engine: Engine;
  109872. protected _maxSize: number;
  109873. protected _mainTextureDesiredSize: ISize;
  109874. protected _mainTexture: RenderTargetTexture;
  109875. protected _shouldRender: boolean;
  109876. protected _postProcesses: PostProcess[];
  109877. protected _textures: BaseTexture[];
  109878. protected _emissiveTextureAndColor: {
  109879. texture: Nullable<BaseTexture>;
  109880. color: Color4;
  109881. };
  109882. /**
  109883. * The name of the layer
  109884. */
  109885. name: string;
  109886. /**
  109887. * The clear color of the texture used to generate the glow map.
  109888. */
  109889. neutralColor: Color4;
  109890. /**
  109891. * Specifies wether the highlight layer is enabled or not.
  109892. */
  109893. isEnabled: boolean;
  109894. /**
  109895. * Gets the camera attached to the layer.
  109896. */
  109897. readonly camera: Nullable<Camera>;
  109898. /**
  109899. * Gets the rendering group id the layer should render in.
  109900. */
  109901. readonly renderingGroupId: number;
  109902. /**
  109903. * An event triggered when the effect layer has been disposed.
  109904. */
  109905. onDisposeObservable: Observable<EffectLayer>;
  109906. /**
  109907. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  109908. */
  109909. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  109910. /**
  109911. * An event triggered when the generated texture is being merged in the scene.
  109912. */
  109913. onBeforeComposeObservable: Observable<EffectLayer>;
  109914. /**
  109915. * An event triggered when the generated texture has been merged in the scene.
  109916. */
  109917. onAfterComposeObservable: Observable<EffectLayer>;
  109918. /**
  109919. * An event triggered when the efffect layer changes its size.
  109920. */
  109921. onSizeChangedObservable: Observable<EffectLayer>;
  109922. /** @hidden */
  109923. static _SceneComponentInitialization: (scene: Scene) => void;
  109924. /**
  109925. * Instantiates a new effect Layer and references it in the scene.
  109926. * @param name The name of the layer
  109927. * @param scene The scene to use the layer in
  109928. */
  109929. constructor(
  109930. /** The Friendly of the effect in the scene */
  109931. name: string, scene: Scene);
  109932. /**
  109933. * Get the effect name of the layer.
  109934. * @return The effect name
  109935. */
  109936. abstract getEffectName(): string;
  109937. /**
  109938. * Checks for the readiness of the element composing the layer.
  109939. * @param subMesh the mesh to check for
  109940. * @param useInstances specify wether or not to use instances to render the mesh
  109941. * @return true if ready otherwise, false
  109942. */
  109943. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109944. /**
  109945. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109946. * @returns true if the effect requires stencil during the main canvas render pass.
  109947. */
  109948. abstract needStencil(): boolean;
  109949. /**
  109950. * Create the merge effect. This is the shader use to blit the information back
  109951. * to the main canvas at the end of the scene rendering.
  109952. * @returns The effect containing the shader used to merge the effect on the main canvas
  109953. */
  109954. protected abstract _createMergeEffect(): Effect;
  109955. /**
  109956. * Creates the render target textures and post processes used in the effect layer.
  109957. */
  109958. protected abstract _createTextureAndPostProcesses(): void;
  109959. /**
  109960. * Implementation specific of rendering the generating effect on the main canvas.
  109961. * @param effect The effect used to render through
  109962. */
  109963. protected abstract _internalRender(effect: Effect): void;
  109964. /**
  109965. * Sets the required values for both the emissive texture and and the main color.
  109966. */
  109967. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109968. /**
  109969. * Free any resources and references associated to a mesh.
  109970. * Internal use
  109971. * @param mesh The mesh to free.
  109972. */
  109973. abstract _disposeMesh(mesh: Mesh): void;
  109974. /**
  109975. * Serializes this layer (Glow or Highlight for example)
  109976. * @returns a serialized layer object
  109977. */
  109978. abstract serialize?(): any;
  109979. /**
  109980. * Initializes the effect layer with the required options.
  109981. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  109982. */
  109983. protected _init(options: Partial<IEffectLayerOptions>): void;
  109984. /**
  109985. * Generates the index buffer of the full screen quad blending to the main canvas.
  109986. */
  109987. private _generateIndexBuffer;
  109988. /**
  109989. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  109990. */
  109991. private _generateVertexBuffer;
  109992. /**
  109993. * Sets the main texture desired size which is the closest power of two
  109994. * of the engine canvas size.
  109995. */
  109996. private _setMainTextureSize;
  109997. /**
  109998. * Creates the main texture for the effect layer.
  109999. */
  110000. protected _createMainTexture(): void;
  110001. /**
  110002. * Adds specific effects defines.
  110003. * @param defines The defines to add specifics to.
  110004. */
  110005. protected _addCustomEffectDefines(defines: string[]): void;
  110006. /**
  110007. * Checks for the readiness of the element composing the layer.
  110008. * @param subMesh the mesh to check for
  110009. * @param useInstances specify wether or not to use instances to render the mesh
  110010. * @param emissiveTexture the associated emissive texture used to generate the glow
  110011. * @return true if ready otherwise, false
  110012. */
  110013. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110014. /**
  110015. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110016. */
  110017. render(): void;
  110018. /**
  110019. * Determine if a given mesh will be used in the current effect.
  110020. * @param mesh mesh to test
  110021. * @returns true if the mesh will be used
  110022. */
  110023. hasMesh(mesh: AbstractMesh): boolean;
  110024. /**
  110025. * Returns true if the layer contains information to display, otherwise false.
  110026. * @returns true if the glow layer should be rendered
  110027. */
  110028. shouldRender(): boolean;
  110029. /**
  110030. * Returns true if the mesh should render, otherwise false.
  110031. * @param mesh The mesh to render
  110032. * @returns true if it should render otherwise false
  110033. */
  110034. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110035. /**
  110036. * Returns true if the mesh can be rendered, otherwise false.
  110037. * @param mesh The mesh to render
  110038. * @param material The material used on the mesh
  110039. * @returns true if it can be rendered otherwise false
  110040. */
  110041. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110042. /**
  110043. * Returns true if the mesh should render, otherwise false.
  110044. * @param mesh The mesh to render
  110045. * @returns true if it should render otherwise false
  110046. */
  110047. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110048. /**
  110049. * Renders the submesh passed in parameter to the generation map.
  110050. */
  110051. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110052. /**
  110053. * Rebuild the required buffers.
  110054. * @hidden Internal use only.
  110055. */
  110056. _rebuild(): void;
  110057. /**
  110058. * Dispose only the render target textures and post process.
  110059. */
  110060. private _disposeTextureAndPostProcesses;
  110061. /**
  110062. * Dispose the highlight layer and free resources.
  110063. */
  110064. dispose(): void;
  110065. /**
  110066. * Gets the class name of the effect layer
  110067. * @returns the string with the class name of the effect layer
  110068. */
  110069. getClassName(): string;
  110070. /**
  110071. * Creates an effect layer from parsed effect layer data
  110072. * @param parsedEffectLayer defines effect layer data
  110073. * @param scene defines the current scene
  110074. * @param rootUrl defines the root URL containing the effect layer information
  110075. * @returns a parsed effect Layer
  110076. */
  110077. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110078. }
  110079. }
  110080. declare module BABYLON {
  110081. interface AbstractScene {
  110082. /**
  110083. * The list of effect layers (highlights/glow) added to the scene
  110084. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110085. * @see http://doc.babylonjs.com/how_to/glow_layer
  110086. */
  110087. effectLayers: Array<EffectLayer>;
  110088. /**
  110089. * Removes the given effect layer from this scene.
  110090. * @param toRemove defines the effect layer to remove
  110091. * @returns the index of the removed effect layer
  110092. */
  110093. removeEffectLayer(toRemove: EffectLayer): number;
  110094. /**
  110095. * Adds the given effect layer to this scene
  110096. * @param newEffectLayer defines the effect layer to add
  110097. */
  110098. addEffectLayer(newEffectLayer: EffectLayer): void;
  110099. }
  110100. /**
  110101. * Defines the layer scene component responsible to manage any effect layers
  110102. * in a given scene.
  110103. */
  110104. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110105. /**
  110106. * The component name helpfull to identify the component in the list of scene components.
  110107. */
  110108. readonly name: string;
  110109. /**
  110110. * The scene the component belongs to.
  110111. */
  110112. scene: Scene;
  110113. private _engine;
  110114. private _renderEffects;
  110115. private _needStencil;
  110116. private _previousStencilState;
  110117. /**
  110118. * Creates a new instance of the component for the given scene
  110119. * @param scene Defines the scene to register the component in
  110120. */
  110121. constructor(scene: Scene);
  110122. /**
  110123. * Registers the component in a given scene
  110124. */
  110125. register(): void;
  110126. /**
  110127. * Rebuilds the elements related to this component in case of
  110128. * context lost for instance.
  110129. */
  110130. rebuild(): void;
  110131. /**
  110132. * Serializes the component data to the specified json object
  110133. * @param serializationObject The object to serialize to
  110134. */
  110135. serialize(serializationObject: any): void;
  110136. /**
  110137. * Adds all the elements from the container to the scene
  110138. * @param container the container holding the elements
  110139. */
  110140. addFromContainer(container: AbstractScene): void;
  110141. /**
  110142. * Removes all the elements in the container from the scene
  110143. * @param container contains the elements to remove
  110144. * @param dispose if the removed element should be disposed (default: false)
  110145. */
  110146. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110147. /**
  110148. * Disposes the component and the associated ressources.
  110149. */
  110150. dispose(): void;
  110151. private _isReadyForMesh;
  110152. private _renderMainTexture;
  110153. private _setStencil;
  110154. private _setStencilBack;
  110155. private _draw;
  110156. private _drawCamera;
  110157. private _drawRenderingGroup;
  110158. }
  110159. }
  110160. declare module BABYLON {
  110161. /** @hidden */
  110162. export var glowMapMergePixelShader: {
  110163. name: string;
  110164. shader: string;
  110165. };
  110166. }
  110167. declare module BABYLON {
  110168. /** @hidden */
  110169. export var glowMapMergeVertexShader: {
  110170. name: string;
  110171. shader: string;
  110172. };
  110173. }
  110174. declare module BABYLON {
  110175. interface AbstractScene {
  110176. /**
  110177. * Return a the first highlight layer of the scene with a given name.
  110178. * @param name The name of the highlight layer to look for.
  110179. * @return The highlight layer if found otherwise null.
  110180. */
  110181. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110182. }
  110183. /**
  110184. * Glow layer options. This helps customizing the behaviour
  110185. * of the glow layer.
  110186. */
  110187. export interface IGlowLayerOptions {
  110188. /**
  110189. * Multiplication factor apply to the canvas size to compute the render target size
  110190. * used to generated the glowing objects (the smaller the faster).
  110191. */
  110192. mainTextureRatio: number;
  110193. /**
  110194. * Enforces a fixed size texture to ensure resize independant blur.
  110195. */
  110196. mainTextureFixedSize?: number;
  110197. /**
  110198. * How big is the kernel of the blur texture.
  110199. */
  110200. blurKernelSize: number;
  110201. /**
  110202. * The camera attached to the layer.
  110203. */
  110204. camera: Nullable<Camera>;
  110205. /**
  110206. * Enable MSAA by chosing the number of samples.
  110207. */
  110208. mainTextureSamples?: number;
  110209. /**
  110210. * The rendering group to draw the layer in.
  110211. */
  110212. renderingGroupId: number;
  110213. }
  110214. /**
  110215. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110216. *
  110217. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110218. * glowy meshes to your scene.
  110219. *
  110220. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110221. */
  110222. export class GlowLayer extends EffectLayer {
  110223. /**
  110224. * Effect Name of the layer.
  110225. */
  110226. static readonly EffectName: string;
  110227. /**
  110228. * The default blur kernel size used for the glow.
  110229. */
  110230. static DefaultBlurKernelSize: number;
  110231. /**
  110232. * The default texture size ratio used for the glow.
  110233. */
  110234. static DefaultTextureRatio: number;
  110235. /**
  110236. * Sets the kernel size of the blur.
  110237. */
  110238. /**
  110239. * Gets the kernel size of the blur.
  110240. */
  110241. blurKernelSize: number;
  110242. /**
  110243. * Sets the glow intensity.
  110244. */
  110245. /**
  110246. * Gets the glow intensity.
  110247. */
  110248. intensity: number;
  110249. private _options;
  110250. private _intensity;
  110251. private _horizontalBlurPostprocess1;
  110252. private _verticalBlurPostprocess1;
  110253. private _horizontalBlurPostprocess2;
  110254. private _verticalBlurPostprocess2;
  110255. private _blurTexture1;
  110256. private _blurTexture2;
  110257. private _postProcesses1;
  110258. private _postProcesses2;
  110259. private _includedOnlyMeshes;
  110260. private _excludedMeshes;
  110261. /**
  110262. * Callback used to let the user override the color selection on a per mesh basis
  110263. */
  110264. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110265. /**
  110266. * Callback used to let the user override the texture selection on a per mesh basis
  110267. */
  110268. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110269. /**
  110270. * Instantiates a new glow Layer and references it to the scene.
  110271. * @param name The name of the layer
  110272. * @param scene The scene to use the layer in
  110273. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110274. */
  110275. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110276. /**
  110277. * Get the effect name of the layer.
  110278. * @return The effect name
  110279. */
  110280. getEffectName(): string;
  110281. /**
  110282. * Create the merge effect. This is the shader use to blit the information back
  110283. * to the main canvas at the end of the scene rendering.
  110284. */
  110285. protected _createMergeEffect(): Effect;
  110286. /**
  110287. * Creates the render target textures and post processes used in the glow layer.
  110288. */
  110289. protected _createTextureAndPostProcesses(): void;
  110290. /**
  110291. * Checks for the readiness of the element composing the layer.
  110292. * @param subMesh the mesh to check for
  110293. * @param useInstances specify wether or not to use instances to render the mesh
  110294. * @param emissiveTexture the associated emissive texture used to generate the glow
  110295. * @return true if ready otherwise, false
  110296. */
  110297. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110298. /**
  110299. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110300. */
  110301. needStencil(): boolean;
  110302. /**
  110303. * Returns true if the mesh can be rendered, otherwise false.
  110304. * @param mesh The mesh to render
  110305. * @param material The material used on the mesh
  110306. * @returns true if it can be rendered otherwise false
  110307. */
  110308. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110309. /**
  110310. * Implementation specific of rendering the generating effect on the main canvas.
  110311. * @param effect The effect used to render through
  110312. */
  110313. protected _internalRender(effect: Effect): void;
  110314. /**
  110315. * Sets the required values for both the emissive texture and and the main color.
  110316. */
  110317. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110318. /**
  110319. * Returns true if the mesh should render, otherwise false.
  110320. * @param mesh The mesh to render
  110321. * @returns true if it should render otherwise false
  110322. */
  110323. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110324. /**
  110325. * Adds specific effects defines.
  110326. * @param defines The defines to add specifics to.
  110327. */
  110328. protected _addCustomEffectDefines(defines: string[]): void;
  110329. /**
  110330. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110331. * @param mesh The mesh to exclude from the glow layer
  110332. */
  110333. addExcludedMesh(mesh: Mesh): void;
  110334. /**
  110335. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110336. * @param mesh The mesh to remove
  110337. */
  110338. removeExcludedMesh(mesh: Mesh): void;
  110339. /**
  110340. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110341. * @param mesh The mesh to include in the glow layer
  110342. */
  110343. addIncludedOnlyMesh(mesh: Mesh): void;
  110344. /**
  110345. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110346. * @param mesh The mesh to remove
  110347. */
  110348. removeIncludedOnlyMesh(mesh: Mesh): void;
  110349. /**
  110350. * Determine if a given mesh will be used in the glow layer
  110351. * @param mesh The mesh to test
  110352. * @returns true if the mesh will be highlighted by the current glow layer
  110353. */
  110354. hasMesh(mesh: AbstractMesh): boolean;
  110355. /**
  110356. * Free any resources and references associated to a mesh.
  110357. * Internal use
  110358. * @param mesh The mesh to free.
  110359. * @hidden
  110360. */
  110361. _disposeMesh(mesh: Mesh): void;
  110362. /**
  110363. * Gets the class name of the effect layer
  110364. * @returns the string with the class name of the effect layer
  110365. */
  110366. getClassName(): string;
  110367. /**
  110368. * Serializes this glow layer
  110369. * @returns a serialized glow layer object
  110370. */
  110371. serialize(): any;
  110372. /**
  110373. * Creates a Glow Layer from parsed glow layer data
  110374. * @param parsedGlowLayer defines glow layer data
  110375. * @param scene defines the current scene
  110376. * @param rootUrl defines the root URL containing the glow layer information
  110377. * @returns a parsed Glow Layer
  110378. */
  110379. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110380. }
  110381. }
  110382. declare module BABYLON {
  110383. /** @hidden */
  110384. export var glowBlurPostProcessPixelShader: {
  110385. name: string;
  110386. shader: string;
  110387. };
  110388. }
  110389. declare module BABYLON {
  110390. interface AbstractScene {
  110391. /**
  110392. * Return a the first highlight layer of the scene with a given name.
  110393. * @param name The name of the highlight layer to look for.
  110394. * @return The highlight layer if found otherwise null.
  110395. */
  110396. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110397. }
  110398. /**
  110399. * Highlight layer options. This helps customizing the behaviour
  110400. * of the highlight layer.
  110401. */
  110402. export interface IHighlightLayerOptions {
  110403. /**
  110404. * Multiplication factor apply to the canvas size to compute the render target size
  110405. * used to generated the glowing objects (the smaller the faster).
  110406. */
  110407. mainTextureRatio: number;
  110408. /**
  110409. * Enforces a fixed size texture to ensure resize independant blur.
  110410. */
  110411. mainTextureFixedSize?: number;
  110412. /**
  110413. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110414. * of the picture to blur (the smaller the faster).
  110415. */
  110416. blurTextureSizeRatio: number;
  110417. /**
  110418. * How big in texel of the blur texture is the vertical blur.
  110419. */
  110420. blurVerticalSize: number;
  110421. /**
  110422. * How big in texel of the blur texture is the horizontal blur.
  110423. */
  110424. blurHorizontalSize: number;
  110425. /**
  110426. * Alpha blending mode used to apply the blur. Default is combine.
  110427. */
  110428. alphaBlendingMode: number;
  110429. /**
  110430. * The camera attached to the layer.
  110431. */
  110432. camera: Nullable<Camera>;
  110433. /**
  110434. * Should we display highlight as a solid stroke?
  110435. */
  110436. isStroke?: boolean;
  110437. /**
  110438. * The rendering group to draw the layer in.
  110439. */
  110440. renderingGroupId: number;
  110441. }
  110442. /**
  110443. * The highlight layer Helps adding a glow effect around a mesh.
  110444. *
  110445. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110446. * glowy meshes to your scene.
  110447. *
  110448. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110449. */
  110450. export class HighlightLayer extends EffectLayer {
  110451. name: string;
  110452. /**
  110453. * Effect Name of the highlight layer.
  110454. */
  110455. static readonly EffectName: string;
  110456. /**
  110457. * The neutral color used during the preparation of the glow effect.
  110458. * This is black by default as the blend operation is a blend operation.
  110459. */
  110460. static NeutralColor: Color4;
  110461. /**
  110462. * Stencil value used for glowing meshes.
  110463. */
  110464. static GlowingMeshStencilReference: number;
  110465. /**
  110466. * Stencil value used for the other meshes in the scene.
  110467. */
  110468. static NormalMeshStencilReference: number;
  110469. /**
  110470. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110471. */
  110472. innerGlow: boolean;
  110473. /**
  110474. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110475. */
  110476. outerGlow: boolean;
  110477. /**
  110478. * Specifies the horizontal size of the blur.
  110479. */
  110480. /**
  110481. * Gets the horizontal size of the blur.
  110482. */
  110483. blurHorizontalSize: number;
  110484. /**
  110485. * Specifies the vertical size of the blur.
  110486. */
  110487. /**
  110488. * Gets the vertical size of the blur.
  110489. */
  110490. blurVerticalSize: number;
  110491. /**
  110492. * An event triggered when the highlight layer is being blurred.
  110493. */
  110494. onBeforeBlurObservable: Observable<HighlightLayer>;
  110495. /**
  110496. * An event triggered when the highlight layer has been blurred.
  110497. */
  110498. onAfterBlurObservable: Observable<HighlightLayer>;
  110499. private _instanceGlowingMeshStencilReference;
  110500. private _options;
  110501. private _downSamplePostprocess;
  110502. private _horizontalBlurPostprocess;
  110503. private _verticalBlurPostprocess;
  110504. private _blurTexture;
  110505. private _meshes;
  110506. private _excludedMeshes;
  110507. /**
  110508. * Instantiates a new highlight Layer and references it to the scene..
  110509. * @param name The name of the layer
  110510. * @param scene The scene to use the layer in
  110511. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110512. */
  110513. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110514. /**
  110515. * Get the effect name of the layer.
  110516. * @return The effect name
  110517. */
  110518. getEffectName(): string;
  110519. /**
  110520. * Create the merge effect. This is the shader use to blit the information back
  110521. * to the main canvas at the end of the scene rendering.
  110522. */
  110523. protected _createMergeEffect(): Effect;
  110524. /**
  110525. * Creates the render target textures and post processes used in the highlight layer.
  110526. */
  110527. protected _createTextureAndPostProcesses(): void;
  110528. /**
  110529. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110530. */
  110531. needStencil(): boolean;
  110532. /**
  110533. * Checks for the readiness of the element composing the layer.
  110534. * @param subMesh the mesh to check for
  110535. * @param useInstances specify wether or not to use instances to render the mesh
  110536. * @param emissiveTexture the associated emissive texture used to generate the glow
  110537. * @return true if ready otherwise, false
  110538. */
  110539. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110540. /**
  110541. * Implementation specific of rendering the generating effect on the main canvas.
  110542. * @param effect The effect used to render through
  110543. */
  110544. protected _internalRender(effect: Effect): void;
  110545. /**
  110546. * Returns true if the layer contains information to display, otherwise false.
  110547. */
  110548. shouldRender(): boolean;
  110549. /**
  110550. * Returns true if the mesh should render, otherwise false.
  110551. * @param mesh The mesh to render
  110552. * @returns true if it should render otherwise false
  110553. */
  110554. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110555. /**
  110556. * Sets the required values for both the emissive texture and and the main color.
  110557. */
  110558. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110559. /**
  110560. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110561. * @param mesh The mesh to exclude from the highlight layer
  110562. */
  110563. addExcludedMesh(mesh: Mesh): void;
  110564. /**
  110565. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110566. * @param mesh The mesh to highlight
  110567. */
  110568. removeExcludedMesh(mesh: Mesh): void;
  110569. /**
  110570. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110571. * @param mesh mesh to test
  110572. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110573. */
  110574. hasMesh(mesh: AbstractMesh): boolean;
  110575. /**
  110576. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110577. * @param mesh The mesh to highlight
  110578. * @param color The color of the highlight
  110579. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110580. */
  110581. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110582. /**
  110583. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110584. * @param mesh The mesh to highlight
  110585. */
  110586. removeMesh(mesh: Mesh): void;
  110587. /**
  110588. * Force the stencil to the normal expected value for none glowing parts
  110589. */
  110590. private _defaultStencilReference;
  110591. /**
  110592. * Free any resources and references associated to a mesh.
  110593. * Internal use
  110594. * @param mesh The mesh to free.
  110595. * @hidden
  110596. */
  110597. _disposeMesh(mesh: Mesh): void;
  110598. /**
  110599. * Dispose the highlight layer and free resources.
  110600. */
  110601. dispose(): void;
  110602. /**
  110603. * Gets the class name of the effect layer
  110604. * @returns the string with the class name of the effect layer
  110605. */
  110606. getClassName(): string;
  110607. /**
  110608. * Serializes this Highlight layer
  110609. * @returns a serialized Highlight layer object
  110610. */
  110611. serialize(): any;
  110612. /**
  110613. * Creates a Highlight layer from parsed Highlight layer data
  110614. * @param parsedHightlightLayer defines the Highlight layer data
  110615. * @param scene defines the current scene
  110616. * @param rootUrl defines the root URL containing the Highlight layer information
  110617. * @returns a parsed Highlight layer
  110618. */
  110619. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110620. }
  110621. }
  110622. declare module BABYLON {
  110623. interface AbstractScene {
  110624. /**
  110625. * The list of layers (background and foreground) of the scene
  110626. */
  110627. layers: Array<Layer>;
  110628. }
  110629. /**
  110630. * Defines the layer scene component responsible to manage any layers
  110631. * in a given scene.
  110632. */
  110633. export class LayerSceneComponent implements ISceneComponent {
  110634. /**
  110635. * The component name helpfull to identify the component in the list of scene components.
  110636. */
  110637. readonly name: string;
  110638. /**
  110639. * The scene the component belongs to.
  110640. */
  110641. scene: Scene;
  110642. private _engine;
  110643. /**
  110644. * Creates a new instance of the component for the given scene
  110645. * @param scene Defines the scene to register the component in
  110646. */
  110647. constructor(scene: Scene);
  110648. /**
  110649. * Registers the component in a given scene
  110650. */
  110651. register(): void;
  110652. /**
  110653. * Rebuilds the elements related to this component in case of
  110654. * context lost for instance.
  110655. */
  110656. rebuild(): void;
  110657. /**
  110658. * Disposes the component and the associated ressources.
  110659. */
  110660. dispose(): void;
  110661. private _draw;
  110662. private _drawCameraPredicate;
  110663. private _drawCameraBackground;
  110664. private _drawCameraForeground;
  110665. private _drawRenderTargetPredicate;
  110666. private _drawRenderTargetBackground;
  110667. private _drawRenderTargetForeground;
  110668. /**
  110669. * Adds all the elements from the container to the scene
  110670. * @param container the container holding the elements
  110671. */
  110672. addFromContainer(container: AbstractScene): void;
  110673. /**
  110674. * Removes all the elements in the container from the scene
  110675. * @param container contains the elements to remove
  110676. * @param dispose if the removed element should be disposed (default: false)
  110677. */
  110678. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110679. }
  110680. }
  110681. declare module BABYLON {
  110682. /** @hidden */
  110683. export var layerPixelShader: {
  110684. name: string;
  110685. shader: string;
  110686. };
  110687. }
  110688. declare module BABYLON {
  110689. /** @hidden */
  110690. export var layerVertexShader: {
  110691. name: string;
  110692. shader: string;
  110693. };
  110694. }
  110695. declare module BABYLON {
  110696. /**
  110697. * This represents a full screen 2d layer.
  110698. * This can be useful to display a picture in the background of your scene for instance.
  110699. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110700. */
  110701. export class Layer {
  110702. /**
  110703. * Define the name of the layer.
  110704. */
  110705. name: string;
  110706. /**
  110707. * Define the texture the layer should display.
  110708. */
  110709. texture: Nullable<Texture>;
  110710. /**
  110711. * Is the layer in background or foreground.
  110712. */
  110713. isBackground: boolean;
  110714. /**
  110715. * Define the color of the layer (instead of texture).
  110716. */
  110717. color: Color4;
  110718. /**
  110719. * Define the scale of the layer in order to zoom in out of the texture.
  110720. */
  110721. scale: Vector2;
  110722. /**
  110723. * Define an offset for the layer in order to shift the texture.
  110724. */
  110725. offset: Vector2;
  110726. /**
  110727. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  110728. */
  110729. alphaBlendingMode: number;
  110730. /**
  110731. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  110732. * Alpha test will not mix with the background color in case of transparency.
  110733. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  110734. */
  110735. alphaTest: boolean;
  110736. /**
  110737. * Define a mask to restrict the layer to only some of the scene cameras.
  110738. */
  110739. layerMask: number;
  110740. /**
  110741. * Define the list of render target the layer is visible into.
  110742. */
  110743. renderTargetTextures: RenderTargetTexture[];
  110744. /**
  110745. * Define if the layer is only used in renderTarget or if it also
  110746. * renders in the main frame buffer of the canvas.
  110747. */
  110748. renderOnlyInRenderTargetTextures: boolean;
  110749. private _scene;
  110750. private _vertexBuffers;
  110751. private _indexBuffer;
  110752. private _effect;
  110753. private _alphaTestEffect;
  110754. /**
  110755. * An event triggered when the layer is disposed.
  110756. */
  110757. onDisposeObservable: Observable<Layer>;
  110758. private _onDisposeObserver;
  110759. /**
  110760. * Back compatibility with callback before the onDisposeObservable existed.
  110761. * The set callback will be triggered when the layer has been disposed.
  110762. */
  110763. onDispose: () => void;
  110764. /**
  110765. * An event triggered before rendering the scene
  110766. */
  110767. onBeforeRenderObservable: Observable<Layer>;
  110768. private _onBeforeRenderObserver;
  110769. /**
  110770. * Back compatibility with callback before the onBeforeRenderObservable existed.
  110771. * The set callback will be triggered just before rendering the layer.
  110772. */
  110773. onBeforeRender: () => void;
  110774. /**
  110775. * An event triggered after rendering the scene
  110776. */
  110777. onAfterRenderObservable: Observable<Layer>;
  110778. private _onAfterRenderObserver;
  110779. /**
  110780. * Back compatibility with callback before the onAfterRenderObservable existed.
  110781. * The set callback will be triggered just after rendering the layer.
  110782. */
  110783. onAfterRender: () => void;
  110784. /**
  110785. * Instantiates a new layer.
  110786. * This represents a full screen 2d layer.
  110787. * This can be useful to display a picture in the background of your scene for instance.
  110788. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110789. * @param name Define the name of the layer in the scene
  110790. * @param imgUrl Define the url of the texture to display in the layer
  110791. * @param scene Define the scene the layer belongs to
  110792. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  110793. * @param color Defines a color for the layer
  110794. */
  110795. constructor(
  110796. /**
  110797. * Define the name of the layer.
  110798. */
  110799. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  110800. private _createIndexBuffer;
  110801. /** @hidden */
  110802. _rebuild(): void;
  110803. /**
  110804. * Renders the layer in the scene.
  110805. */
  110806. render(): void;
  110807. /**
  110808. * Disposes and releases the associated ressources.
  110809. */
  110810. dispose(): void;
  110811. }
  110812. }
  110813. declare module BABYLON {
  110814. /** @hidden */
  110815. export var lensFlarePixelShader: {
  110816. name: string;
  110817. shader: string;
  110818. };
  110819. }
  110820. declare module BABYLON {
  110821. /** @hidden */
  110822. export var lensFlareVertexShader: {
  110823. name: string;
  110824. shader: string;
  110825. };
  110826. }
  110827. declare module BABYLON {
  110828. /**
  110829. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110830. * It is usually composed of several `lensFlare`.
  110831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110832. */
  110833. export class LensFlareSystem {
  110834. /**
  110835. * Define the name of the lens flare system
  110836. */
  110837. name: string;
  110838. /**
  110839. * List of lens flares used in this system.
  110840. */
  110841. lensFlares: LensFlare[];
  110842. /**
  110843. * Define a limit from the border the lens flare can be visible.
  110844. */
  110845. borderLimit: number;
  110846. /**
  110847. * Define a viewport border we do not want to see the lens flare in.
  110848. */
  110849. viewportBorder: number;
  110850. /**
  110851. * Define a predicate which could limit the list of meshes able to occlude the effect.
  110852. */
  110853. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110854. /**
  110855. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  110856. */
  110857. layerMask: number;
  110858. /**
  110859. * Define the id of the lens flare system in the scene.
  110860. * (equal to name by default)
  110861. */
  110862. id: string;
  110863. private _scene;
  110864. private _emitter;
  110865. private _vertexBuffers;
  110866. private _indexBuffer;
  110867. private _effect;
  110868. private _positionX;
  110869. private _positionY;
  110870. private _isEnabled;
  110871. /** @hidden */
  110872. static _SceneComponentInitialization: (scene: Scene) => void;
  110873. /**
  110874. * Instantiates a lens flare system.
  110875. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110876. * It is usually composed of several `lensFlare`.
  110877. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110878. * @param name Define the name of the lens flare system in the scene
  110879. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  110880. * @param scene Define the scene the lens flare system belongs to
  110881. */
  110882. constructor(
  110883. /**
  110884. * Define the name of the lens flare system
  110885. */
  110886. name: string, emitter: any, scene: Scene);
  110887. /**
  110888. * Define if the lens flare system is enabled.
  110889. */
  110890. isEnabled: boolean;
  110891. /**
  110892. * Get the scene the effects belongs to.
  110893. * @returns the scene holding the lens flare system
  110894. */
  110895. getScene(): Scene;
  110896. /**
  110897. * Get the emitter of the lens flare system.
  110898. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110899. * @returns the emitter of the lens flare system
  110900. */
  110901. getEmitter(): any;
  110902. /**
  110903. * Set the emitter of the lens flare system.
  110904. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110905. * @param newEmitter Define the new emitter of the system
  110906. */
  110907. setEmitter(newEmitter: any): void;
  110908. /**
  110909. * Get the lens flare system emitter position.
  110910. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  110911. * @returns the position
  110912. */
  110913. getEmitterPosition(): Vector3;
  110914. /**
  110915. * @hidden
  110916. */
  110917. computeEffectivePosition(globalViewport: Viewport): boolean;
  110918. /** @hidden */
  110919. _isVisible(): boolean;
  110920. /**
  110921. * @hidden
  110922. */
  110923. render(): boolean;
  110924. /**
  110925. * Dispose and release the lens flare with its associated resources.
  110926. */
  110927. dispose(): void;
  110928. /**
  110929. * Parse a lens flare system from a JSON repressentation
  110930. * @param parsedLensFlareSystem Define the JSON to parse
  110931. * @param scene Define the scene the parsed system should be instantiated in
  110932. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  110933. * @returns the parsed system
  110934. */
  110935. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  110936. /**
  110937. * Serialize the current Lens Flare System into a JSON representation.
  110938. * @returns the serialized JSON
  110939. */
  110940. serialize(): any;
  110941. }
  110942. }
  110943. declare module BABYLON {
  110944. /**
  110945. * This represents one of the lens effect in a `lensFlareSystem`.
  110946. * It controls one of the indiviual texture used in the effect.
  110947. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110948. */
  110949. export class LensFlare {
  110950. /**
  110951. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110952. */
  110953. size: number;
  110954. /**
  110955. * 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.
  110956. */
  110957. position: number;
  110958. /**
  110959. * Define the lens color.
  110960. */
  110961. color: Color3;
  110962. /**
  110963. * Define the lens texture.
  110964. */
  110965. texture: Nullable<Texture>;
  110966. /**
  110967. * Define the alpha mode to render this particular lens.
  110968. */
  110969. alphaMode: number;
  110970. private _system;
  110971. /**
  110972. * Creates a new Lens Flare.
  110973. * This represents one of the lens effect in a `lensFlareSystem`.
  110974. * It controls one of the indiviual texture used in the effect.
  110975. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110976. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  110977. * @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.
  110978. * @param color Define the lens color
  110979. * @param imgUrl Define the lens texture url
  110980. * @param system Define the `lensFlareSystem` this flare is part of
  110981. * @returns The newly created Lens Flare
  110982. */
  110983. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  110984. /**
  110985. * Instantiates a new Lens Flare.
  110986. * This represents one of the lens effect in a `lensFlareSystem`.
  110987. * It controls one of the indiviual texture used in the effect.
  110988. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110989. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  110990. * @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.
  110991. * @param color Define the lens color
  110992. * @param imgUrl Define the lens texture url
  110993. * @param system Define the `lensFlareSystem` this flare is part of
  110994. */
  110995. constructor(
  110996. /**
  110997. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110998. */
  110999. size: number,
  111000. /**
  111001. * 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.
  111002. */
  111003. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111004. /**
  111005. * Dispose and release the lens flare with its associated resources.
  111006. */
  111007. dispose(): void;
  111008. }
  111009. }
  111010. declare module BABYLON {
  111011. interface AbstractScene {
  111012. /**
  111013. * The list of lens flare system added to the scene
  111014. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111015. */
  111016. lensFlareSystems: Array<LensFlareSystem>;
  111017. /**
  111018. * Removes the given lens flare system from this scene.
  111019. * @param toRemove The lens flare system to remove
  111020. * @returns The index of the removed lens flare system
  111021. */
  111022. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111023. /**
  111024. * Adds the given lens flare system to this scene
  111025. * @param newLensFlareSystem The lens flare system to add
  111026. */
  111027. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111028. /**
  111029. * Gets a lens flare system using its name
  111030. * @param name defines the name to look for
  111031. * @returns the lens flare system or null if not found
  111032. */
  111033. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111034. /**
  111035. * Gets a lens flare system using its id
  111036. * @param id defines the id to look for
  111037. * @returns the lens flare system or null if not found
  111038. */
  111039. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111040. }
  111041. /**
  111042. * Defines the lens flare scene component responsible to manage any lens flares
  111043. * in a given scene.
  111044. */
  111045. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111046. /**
  111047. * The component name helpfull to identify the component in the list of scene components.
  111048. */
  111049. readonly name: string;
  111050. /**
  111051. * The scene the component belongs to.
  111052. */
  111053. scene: Scene;
  111054. /**
  111055. * Creates a new instance of the component for the given scene
  111056. * @param scene Defines the scene to register the component in
  111057. */
  111058. constructor(scene: Scene);
  111059. /**
  111060. * Registers the component in a given scene
  111061. */
  111062. register(): void;
  111063. /**
  111064. * Rebuilds the elements related to this component in case of
  111065. * context lost for instance.
  111066. */
  111067. rebuild(): void;
  111068. /**
  111069. * Adds all the elements from the container to the scene
  111070. * @param container the container holding the elements
  111071. */
  111072. addFromContainer(container: AbstractScene): void;
  111073. /**
  111074. * Removes all the elements in the container from the scene
  111075. * @param container contains the elements to remove
  111076. * @param dispose if the removed element should be disposed (default: false)
  111077. */
  111078. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111079. /**
  111080. * Serializes the component data to the specified json object
  111081. * @param serializationObject The object to serialize to
  111082. */
  111083. serialize(serializationObject: any): void;
  111084. /**
  111085. * Disposes the component and the associated ressources.
  111086. */
  111087. dispose(): void;
  111088. private _draw;
  111089. }
  111090. }
  111091. declare module BABYLON {
  111092. /**
  111093. * Defines the shadow generator component responsible to manage any shadow generators
  111094. * in a given scene.
  111095. */
  111096. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111097. /**
  111098. * The component name helpfull to identify the component in the list of scene components.
  111099. */
  111100. readonly name: string;
  111101. /**
  111102. * The scene the component belongs to.
  111103. */
  111104. scene: Scene;
  111105. /**
  111106. * Creates a new instance of the component for the given scene
  111107. * @param scene Defines the scene to register the component in
  111108. */
  111109. constructor(scene: Scene);
  111110. /**
  111111. * Registers the component in a given scene
  111112. */
  111113. register(): void;
  111114. /**
  111115. * Rebuilds the elements related to this component in case of
  111116. * context lost for instance.
  111117. */
  111118. rebuild(): void;
  111119. /**
  111120. * Serializes the component data to the specified json object
  111121. * @param serializationObject The object to serialize to
  111122. */
  111123. serialize(serializationObject: any): void;
  111124. /**
  111125. * Adds all the elements from the container to the scene
  111126. * @param container the container holding the elements
  111127. */
  111128. addFromContainer(container: AbstractScene): void;
  111129. /**
  111130. * Removes all the elements in the container from the scene
  111131. * @param container contains the elements to remove
  111132. * @param dispose if the removed element should be disposed (default: false)
  111133. */
  111134. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111135. /**
  111136. * Rebuilds the elements related to this component in case of
  111137. * context lost for instance.
  111138. */
  111139. dispose(): void;
  111140. private _gatherRenderTargets;
  111141. }
  111142. }
  111143. declare module BABYLON {
  111144. /**
  111145. * A point light is a light defined by an unique point in world space.
  111146. * The light is emitted in every direction from this point.
  111147. * A good example of a point light is a standard light bulb.
  111148. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111149. */
  111150. export class PointLight extends ShadowLight {
  111151. private _shadowAngle;
  111152. /**
  111153. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111154. * This specifies what angle the shadow will use to be created.
  111155. *
  111156. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111157. */
  111158. /**
  111159. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111160. * This specifies what angle the shadow will use to be created.
  111161. *
  111162. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111163. */
  111164. shadowAngle: number;
  111165. /**
  111166. * Gets the direction if it has been set.
  111167. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111168. */
  111169. /**
  111170. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111171. */
  111172. direction: Vector3;
  111173. /**
  111174. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111175. * A PointLight emits the light in every direction.
  111176. * It can cast shadows.
  111177. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111178. * ```javascript
  111179. * var pointLight = new PointLight("pl", camera.position, scene);
  111180. * ```
  111181. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111182. * @param name The light friendly name
  111183. * @param position The position of the point light in the scene
  111184. * @param scene The scene the lights belongs to
  111185. */
  111186. constructor(name: string, position: Vector3, scene: Scene);
  111187. /**
  111188. * Returns the string "PointLight"
  111189. * @returns the class name
  111190. */
  111191. getClassName(): string;
  111192. /**
  111193. * Returns the integer 0.
  111194. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111195. */
  111196. getTypeID(): number;
  111197. /**
  111198. * Specifies wether or not the shadowmap should be a cube texture.
  111199. * @returns true if the shadowmap needs to be a cube texture.
  111200. */
  111201. needCube(): boolean;
  111202. /**
  111203. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111204. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111205. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111206. */
  111207. getShadowDirection(faceIndex?: number): Vector3;
  111208. /**
  111209. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111210. * - fov = PI / 2
  111211. * - aspect ratio : 1.0
  111212. * - z-near and far equal to the active camera minZ and maxZ.
  111213. * Returns the PointLight.
  111214. */
  111215. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111216. protected _buildUniformLayout(): void;
  111217. /**
  111218. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111219. * @param effect The effect to update
  111220. * @param lightIndex The index of the light in the effect to update
  111221. * @returns The point light
  111222. */
  111223. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111224. /**
  111225. * Prepares the list of defines specific to the light type.
  111226. * @param defines the list of defines
  111227. * @param lightIndex defines the index of the light for the effect
  111228. */
  111229. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111230. }
  111231. }
  111232. declare module BABYLON {
  111233. /**
  111234. * Header information of HDR texture files.
  111235. */
  111236. export interface HDRInfo {
  111237. /**
  111238. * The height of the texture in pixels.
  111239. */
  111240. height: number;
  111241. /**
  111242. * The width of the texture in pixels.
  111243. */
  111244. width: number;
  111245. /**
  111246. * The index of the beginning of the data in the binary file.
  111247. */
  111248. dataPosition: number;
  111249. }
  111250. /**
  111251. * This groups tools to convert HDR texture to native colors array.
  111252. */
  111253. export class HDRTools {
  111254. private static Ldexp;
  111255. private static Rgbe2float;
  111256. private static readStringLine;
  111257. /**
  111258. * Reads header information from an RGBE texture stored in a native array.
  111259. * More information on this format are available here:
  111260. * https://en.wikipedia.org/wiki/RGBE_image_format
  111261. *
  111262. * @param uint8array The binary file stored in native array.
  111263. * @return The header information.
  111264. */
  111265. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111266. /**
  111267. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111268. * This RGBE texture needs to store the information as a panorama.
  111269. *
  111270. * More information on this format are available here:
  111271. * https://en.wikipedia.org/wiki/RGBE_image_format
  111272. *
  111273. * @param buffer The binary file stored in an array buffer.
  111274. * @param size The expected size of the extracted cubemap.
  111275. * @return The Cube Map information.
  111276. */
  111277. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111278. /**
  111279. * Returns the pixels data extracted from an RGBE texture.
  111280. * This pixels will be stored left to right up to down in the R G B order in one array.
  111281. *
  111282. * More information on this format are available here:
  111283. * https://en.wikipedia.org/wiki/RGBE_image_format
  111284. *
  111285. * @param uint8array The binary file stored in an array buffer.
  111286. * @param hdrInfo The header information of the file.
  111287. * @return The pixels data in RGB right to left up to down order.
  111288. */
  111289. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111290. private static RGBE_ReadPixels_RLE;
  111291. }
  111292. }
  111293. declare module BABYLON {
  111294. /**
  111295. * This represents a texture coming from an HDR input.
  111296. *
  111297. * The only supported format is currently panorama picture stored in RGBE format.
  111298. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111299. */
  111300. export class HDRCubeTexture extends BaseTexture {
  111301. private static _facesMapping;
  111302. private _generateHarmonics;
  111303. private _noMipmap;
  111304. private _textureMatrix;
  111305. private _size;
  111306. private _onLoad;
  111307. private _onError;
  111308. /**
  111309. * The texture URL.
  111310. */
  111311. url: string;
  111312. /**
  111313. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111314. */
  111315. coordinatesMode: number;
  111316. protected _isBlocking: boolean;
  111317. /**
  111318. * Sets wether or not the texture is blocking during loading.
  111319. */
  111320. /**
  111321. * Gets wether or not the texture is blocking during loading.
  111322. */
  111323. isBlocking: boolean;
  111324. protected _rotationY: number;
  111325. /**
  111326. * Sets texture matrix rotation angle around Y axis in radians.
  111327. */
  111328. /**
  111329. * Gets texture matrix rotation angle around Y axis radians.
  111330. */
  111331. rotationY: number;
  111332. /**
  111333. * Gets or sets the center of the bounding box associated with the cube texture
  111334. * It must define where the camera used to render the texture was set
  111335. */
  111336. boundingBoxPosition: Vector3;
  111337. private _boundingBoxSize;
  111338. /**
  111339. * Gets or sets the size of the bounding box associated with the cube texture
  111340. * When defined, the cubemap will switch to local mode
  111341. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111342. * @example https://www.babylonjs-playground.com/#RNASML
  111343. */
  111344. boundingBoxSize: Vector3;
  111345. /**
  111346. * Instantiates an HDRTexture from the following parameters.
  111347. *
  111348. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111349. * @param scene The scene the texture will be used in
  111350. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111351. * @param noMipmap Forces to not generate the mipmap if true
  111352. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111353. * @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)
  111354. * @param reserved Reserved flag for internal use.
  111355. */
  111356. 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>);
  111357. /**
  111358. * Get the current class name of the texture useful for serialization or dynamic coding.
  111359. * @returns "HDRCubeTexture"
  111360. */
  111361. getClassName(): string;
  111362. /**
  111363. * Occurs when the file is raw .hdr file.
  111364. */
  111365. private loadTexture;
  111366. clone(): HDRCubeTexture;
  111367. delayLoad(): void;
  111368. /**
  111369. * Get the texture reflection matrix used to rotate/transform the reflection.
  111370. * @returns the reflection matrix
  111371. */
  111372. getReflectionTextureMatrix(): Matrix;
  111373. /**
  111374. * Set the texture reflection matrix used to rotate/transform the reflection.
  111375. * @param value Define the reflection matrix to set
  111376. */
  111377. setReflectionTextureMatrix(value: Matrix): void;
  111378. /**
  111379. * Parses a JSON representation of an HDR Texture in order to create the texture
  111380. * @param parsedTexture Define the JSON representation
  111381. * @param scene Define the scene the texture should be created in
  111382. * @param rootUrl Define the root url in case we need to load relative dependencies
  111383. * @returns the newly created texture after parsing
  111384. */
  111385. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111386. serialize(): any;
  111387. }
  111388. }
  111389. declare module BABYLON {
  111390. /**
  111391. * Class used to control physics engine
  111392. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111393. */
  111394. export class PhysicsEngine implements IPhysicsEngine {
  111395. private _physicsPlugin;
  111396. /**
  111397. * Global value used to control the smallest number supported by the simulation
  111398. */
  111399. static Epsilon: number;
  111400. private _impostors;
  111401. private _joints;
  111402. /**
  111403. * Gets the gravity vector used by the simulation
  111404. */
  111405. gravity: Vector3;
  111406. /**
  111407. * Factory used to create the default physics plugin.
  111408. * @returns The default physics plugin
  111409. */
  111410. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111411. /**
  111412. * Creates a new Physics Engine
  111413. * @param gravity defines the gravity vector used by the simulation
  111414. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111415. */
  111416. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111417. /**
  111418. * Sets the gravity vector used by the simulation
  111419. * @param gravity defines the gravity vector to use
  111420. */
  111421. setGravity(gravity: Vector3): void;
  111422. /**
  111423. * Set the time step of the physics engine.
  111424. * Default is 1/60.
  111425. * To slow it down, enter 1/600 for example.
  111426. * To speed it up, 1/30
  111427. * @param newTimeStep defines the new timestep to apply to this world.
  111428. */
  111429. setTimeStep(newTimeStep?: number): void;
  111430. /**
  111431. * Get the time step of the physics engine.
  111432. * @returns the current time step
  111433. */
  111434. getTimeStep(): number;
  111435. /**
  111436. * Release all resources
  111437. */
  111438. dispose(): void;
  111439. /**
  111440. * Gets the name of the current physics plugin
  111441. * @returns the name of the plugin
  111442. */
  111443. getPhysicsPluginName(): string;
  111444. /**
  111445. * Adding a new impostor for the impostor tracking.
  111446. * This will be done by the impostor itself.
  111447. * @param impostor the impostor to add
  111448. */
  111449. addImpostor(impostor: PhysicsImpostor): void;
  111450. /**
  111451. * Remove an impostor from the engine.
  111452. * This impostor and its mesh will not longer be updated by the physics engine.
  111453. * @param impostor the impostor to remove
  111454. */
  111455. removeImpostor(impostor: PhysicsImpostor): void;
  111456. /**
  111457. * Add a joint to the physics engine
  111458. * @param mainImpostor defines the main impostor to which the joint is added.
  111459. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111460. * @param joint defines the joint that will connect both impostors.
  111461. */
  111462. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111463. /**
  111464. * Removes a joint from the simulation
  111465. * @param mainImpostor defines the impostor used with the joint
  111466. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111467. * @param joint defines the joint to remove
  111468. */
  111469. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111470. /**
  111471. * Called by the scene. No need to call it.
  111472. * @param delta defines the timespam between frames
  111473. */
  111474. _step(delta: number): void;
  111475. /**
  111476. * Gets the current plugin used to run the simulation
  111477. * @returns current plugin
  111478. */
  111479. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111480. /**
  111481. * Gets the list of physic impostors
  111482. * @returns an array of PhysicsImpostor
  111483. */
  111484. getImpostors(): Array<PhysicsImpostor>;
  111485. /**
  111486. * Gets the impostor for a physics enabled object
  111487. * @param object defines the object impersonated by the impostor
  111488. * @returns the PhysicsImpostor or null if not found
  111489. */
  111490. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111491. /**
  111492. * Gets the impostor for a physics body object
  111493. * @param body defines physics body used by the impostor
  111494. * @returns the PhysicsImpostor or null if not found
  111495. */
  111496. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111497. /**
  111498. * Does a raycast in the physics world
  111499. * @param from when should the ray start?
  111500. * @param to when should the ray end?
  111501. * @returns PhysicsRaycastResult
  111502. */
  111503. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111504. }
  111505. }
  111506. declare module BABYLON {
  111507. /** @hidden */
  111508. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111509. private _useDeltaForWorldStep;
  111510. world: any;
  111511. name: string;
  111512. private _physicsMaterials;
  111513. private _fixedTimeStep;
  111514. private _cannonRaycastResult;
  111515. private _raycastResult;
  111516. private _removeAfterStep;
  111517. BJSCANNON: any;
  111518. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111519. setGravity(gravity: Vector3): void;
  111520. setTimeStep(timeStep: number): void;
  111521. getTimeStep(): number;
  111522. executeStep(delta: number): void;
  111523. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111524. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111525. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111526. private _processChildMeshes;
  111527. removePhysicsBody(impostor: PhysicsImpostor): void;
  111528. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111529. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111530. private _addMaterial;
  111531. private _checkWithEpsilon;
  111532. private _createShape;
  111533. private _createHeightmap;
  111534. private _minus90X;
  111535. private _plus90X;
  111536. private _tmpPosition;
  111537. private _tmpDeltaPosition;
  111538. private _tmpUnityRotation;
  111539. private _updatePhysicsBodyTransformation;
  111540. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111541. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111542. isSupported(): boolean;
  111543. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111544. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111545. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111546. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111547. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111548. getBodyMass(impostor: PhysicsImpostor): number;
  111549. getBodyFriction(impostor: PhysicsImpostor): number;
  111550. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111551. getBodyRestitution(impostor: PhysicsImpostor): number;
  111552. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111553. sleepBody(impostor: PhysicsImpostor): void;
  111554. wakeUpBody(impostor: PhysicsImpostor): void;
  111555. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111556. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111557. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111558. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111559. getRadius(impostor: PhysicsImpostor): number;
  111560. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111561. dispose(): void;
  111562. private _extendNamespace;
  111563. /**
  111564. * Does a raycast in the physics world
  111565. * @param from when should the ray start?
  111566. * @param to when should the ray end?
  111567. * @returns PhysicsRaycastResult
  111568. */
  111569. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111570. }
  111571. }
  111572. declare module BABYLON {
  111573. /** @hidden */
  111574. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111575. world: any;
  111576. name: string;
  111577. BJSOIMO: any;
  111578. private _raycastResult;
  111579. constructor(iterations?: number, oimoInjection?: any);
  111580. setGravity(gravity: Vector3): void;
  111581. setTimeStep(timeStep: number): void;
  111582. getTimeStep(): number;
  111583. private _tmpImpostorsArray;
  111584. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111585. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111586. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111587. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111588. private _tmpPositionVector;
  111589. removePhysicsBody(impostor: PhysicsImpostor): void;
  111590. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111591. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111592. isSupported(): boolean;
  111593. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111594. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111595. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111596. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111597. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111598. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111599. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111600. getBodyMass(impostor: PhysicsImpostor): number;
  111601. getBodyFriction(impostor: PhysicsImpostor): number;
  111602. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111603. getBodyRestitution(impostor: PhysicsImpostor): number;
  111604. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111605. sleepBody(impostor: PhysicsImpostor): void;
  111606. wakeUpBody(impostor: PhysicsImpostor): void;
  111607. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111608. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111609. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111610. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111611. getRadius(impostor: PhysicsImpostor): number;
  111612. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111613. dispose(): void;
  111614. /**
  111615. * Does a raycast in the physics world
  111616. * @param from when should the ray start?
  111617. * @param to when should the ray end?
  111618. * @returns PhysicsRaycastResult
  111619. */
  111620. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111621. }
  111622. }
  111623. declare module BABYLON {
  111624. /**
  111625. * Class containing static functions to help procedurally build meshes
  111626. */
  111627. export class RibbonBuilder {
  111628. /**
  111629. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111630. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111631. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111632. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111633. * * 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
  111634. * * 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
  111635. * * 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
  111636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111639. * * 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
  111640. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111641. * * 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
  111642. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111644. * @param name defines the name of the mesh
  111645. * @param options defines the options used to create the mesh
  111646. * @param scene defines the hosting scene
  111647. * @returns the ribbon mesh
  111648. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111649. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111650. */
  111651. static CreateRibbon(name: string, options: {
  111652. pathArray: Vector3[][];
  111653. closeArray?: boolean;
  111654. closePath?: boolean;
  111655. offset?: number;
  111656. updatable?: boolean;
  111657. sideOrientation?: number;
  111658. frontUVs?: Vector4;
  111659. backUVs?: Vector4;
  111660. instance?: Mesh;
  111661. invertUV?: boolean;
  111662. uvs?: Vector2[];
  111663. colors?: Color4[];
  111664. }, scene?: Nullable<Scene>): Mesh;
  111665. }
  111666. }
  111667. declare module BABYLON {
  111668. /**
  111669. * Class containing static functions to help procedurally build meshes
  111670. */
  111671. export class ShapeBuilder {
  111672. /**
  111673. * 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.
  111674. * * 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.
  111675. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111676. * * 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.
  111677. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111678. * * 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
  111679. * * 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
  111680. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111683. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111685. * @param name defines the name of the mesh
  111686. * @param options defines the options used to create the mesh
  111687. * @param scene defines the hosting scene
  111688. * @returns the extruded shape mesh
  111689. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111691. */
  111692. static ExtrudeShape(name: string, options: {
  111693. shape: Vector3[];
  111694. path: Vector3[];
  111695. scale?: number;
  111696. rotation?: number;
  111697. cap?: number;
  111698. updatable?: boolean;
  111699. sideOrientation?: number;
  111700. frontUVs?: Vector4;
  111701. backUVs?: Vector4;
  111702. instance?: Mesh;
  111703. invertUV?: boolean;
  111704. }, scene?: Nullable<Scene>): Mesh;
  111705. /**
  111706. * Creates an custom extruded shape mesh.
  111707. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  111708. * * 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.
  111709. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111710. * * 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
  111711. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  111712. * * 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
  111713. * * It must returns a float value that will be the scale value applied to the shape on each path point
  111714. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  111715. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  111716. * * 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
  111717. * * 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
  111718. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  111719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111721. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111723. * @param name defines the name of the mesh
  111724. * @param options defines the options used to create the mesh
  111725. * @param scene defines the hosting scene
  111726. * @returns the custom extruded shape mesh
  111727. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  111728. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111730. */
  111731. static ExtrudeShapeCustom(name: string, options: {
  111732. shape: Vector3[];
  111733. path: Vector3[];
  111734. scaleFunction?: any;
  111735. rotationFunction?: any;
  111736. ribbonCloseArray?: boolean;
  111737. ribbonClosePath?: boolean;
  111738. cap?: number;
  111739. updatable?: boolean;
  111740. sideOrientation?: number;
  111741. frontUVs?: Vector4;
  111742. backUVs?: Vector4;
  111743. instance?: Mesh;
  111744. invertUV?: boolean;
  111745. }, scene?: Nullable<Scene>): Mesh;
  111746. private static _ExtrudeShapeGeneric;
  111747. }
  111748. }
  111749. declare module BABYLON {
  111750. /**
  111751. * AmmoJS Physics plugin
  111752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111753. * @see https://github.com/kripken/ammo.js/
  111754. */
  111755. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  111756. private _useDeltaForWorldStep;
  111757. /**
  111758. * Reference to the Ammo library
  111759. */
  111760. bjsAMMO: any;
  111761. /**
  111762. * Created ammoJS world which physics bodies are added to
  111763. */
  111764. world: any;
  111765. /**
  111766. * Name of the plugin
  111767. */
  111768. name: string;
  111769. private _timeStep;
  111770. private _fixedTimeStep;
  111771. private _maxSteps;
  111772. private _tmpQuaternion;
  111773. private _tmpAmmoTransform;
  111774. private _tmpAmmoQuaternion;
  111775. private _tmpAmmoConcreteContactResultCallback;
  111776. private _collisionConfiguration;
  111777. private _dispatcher;
  111778. private _overlappingPairCache;
  111779. private _solver;
  111780. private _softBodySolver;
  111781. private _tmpAmmoVectorA;
  111782. private _tmpAmmoVectorB;
  111783. private _tmpAmmoVectorC;
  111784. private _tmpAmmoVectorD;
  111785. private _tmpContactCallbackResult;
  111786. private _tmpAmmoVectorRCA;
  111787. private _tmpAmmoVectorRCB;
  111788. private _raycastResult;
  111789. private static readonly DISABLE_COLLISION_FLAG;
  111790. private static readonly KINEMATIC_FLAG;
  111791. private static readonly DISABLE_DEACTIVATION_FLAG;
  111792. /**
  111793. * Initializes the ammoJS plugin
  111794. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111795. * @param ammoInjection can be used to inject your own ammo reference
  111796. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  111797. */
  111798. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  111799. /**
  111800. * Sets the gravity of the physics world (m/(s^2))
  111801. * @param gravity Gravity to set
  111802. */
  111803. setGravity(gravity: Vector3): void;
  111804. /**
  111805. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111806. * @param timeStep timestep to use in seconds
  111807. */
  111808. setTimeStep(timeStep: number): void;
  111809. /**
  111810. * 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)
  111811. * @param fixedTimeStep fixedTimeStep to use in seconds
  111812. */
  111813. setFixedTimeStep(fixedTimeStep: number): void;
  111814. /**
  111815. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111816. * @param maxSteps the maximum number of steps by the physics engine per frame
  111817. */
  111818. setMaxSteps(maxSteps: number): void;
  111819. /**
  111820. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111821. * @returns the current timestep in seconds
  111822. */
  111823. getTimeStep(): number;
  111824. private _isImpostorInContact;
  111825. private _isImpostorPairInContact;
  111826. private _stepSimulation;
  111827. /**
  111828. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  111829. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  111830. * After the step the babylon meshes are set to the position of the physics imposters
  111831. * @param delta amount of time to step forward
  111832. * @param impostors array of imposters to update before/after the step
  111833. */
  111834. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111835. /**
  111836. * Update babylon mesh to match physics world object
  111837. * @param impostor imposter to match
  111838. */
  111839. private _afterSoftStep;
  111840. /**
  111841. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111842. * @param impostor imposter to match
  111843. */
  111844. private _ropeStep;
  111845. /**
  111846. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111847. * @param impostor imposter to match
  111848. */
  111849. private _softbodyOrClothStep;
  111850. private _tmpVector;
  111851. private _tmpMatrix;
  111852. /**
  111853. * Applies an impulse on the imposter
  111854. * @param impostor imposter to apply impulse to
  111855. * @param force amount of force to be applied to the imposter
  111856. * @param contactPoint the location to apply the impulse on the imposter
  111857. */
  111858. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111859. /**
  111860. * Applies a force on the imposter
  111861. * @param impostor imposter to apply force
  111862. * @param force amount of force to be applied to the imposter
  111863. * @param contactPoint the location to apply the force on the imposter
  111864. */
  111865. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111866. /**
  111867. * Creates a physics body using the plugin
  111868. * @param impostor the imposter to create the physics body on
  111869. */
  111870. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111871. /**
  111872. * Removes the physics body from the imposter and disposes of the body's memory
  111873. * @param impostor imposter to remove the physics body from
  111874. */
  111875. removePhysicsBody(impostor: PhysicsImpostor): void;
  111876. /**
  111877. * Generates a joint
  111878. * @param impostorJoint the imposter joint to create the joint with
  111879. */
  111880. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111881. /**
  111882. * Removes a joint
  111883. * @param impostorJoint the imposter joint to remove the joint from
  111884. */
  111885. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111886. private _addMeshVerts;
  111887. /**
  111888. * Initialise the soft body vertices to match its object's (mesh) vertices
  111889. * Softbody vertices (nodes) are in world space and to match this
  111890. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  111891. * @param impostor to create the softbody for
  111892. */
  111893. private _softVertexData;
  111894. /**
  111895. * Create an impostor's soft body
  111896. * @param impostor to create the softbody for
  111897. */
  111898. private _createSoftbody;
  111899. /**
  111900. * Create cloth for an impostor
  111901. * @param impostor to create the softbody for
  111902. */
  111903. private _createCloth;
  111904. /**
  111905. * Create rope for an impostor
  111906. * @param impostor to create the softbody for
  111907. */
  111908. private _createRope;
  111909. private _addHullVerts;
  111910. private _createShape;
  111911. /**
  111912. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111913. * @param impostor imposter containing the physics body and babylon object
  111914. */
  111915. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111916. /**
  111917. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111918. * @param impostor imposter containing the physics body and babylon object
  111919. * @param newPosition new position
  111920. * @param newRotation new rotation
  111921. */
  111922. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111923. /**
  111924. * If this plugin is supported
  111925. * @returns true if its supported
  111926. */
  111927. isSupported(): boolean;
  111928. /**
  111929. * Sets the linear velocity of the physics body
  111930. * @param impostor imposter to set the velocity on
  111931. * @param velocity velocity to set
  111932. */
  111933. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111934. /**
  111935. * Sets the angular velocity of the physics body
  111936. * @param impostor imposter to set the velocity on
  111937. * @param velocity velocity to set
  111938. */
  111939. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111940. /**
  111941. * gets the linear velocity
  111942. * @param impostor imposter to get linear velocity from
  111943. * @returns linear velocity
  111944. */
  111945. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111946. /**
  111947. * gets the angular velocity
  111948. * @param impostor imposter to get angular velocity from
  111949. * @returns angular velocity
  111950. */
  111951. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111952. /**
  111953. * Sets the mass of physics body
  111954. * @param impostor imposter to set the mass on
  111955. * @param mass mass to set
  111956. */
  111957. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111958. /**
  111959. * Gets the mass of the physics body
  111960. * @param impostor imposter to get the mass from
  111961. * @returns mass
  111962. */
  111963. getBodyMass(impostor: PhysicsImpostor): number;
  111964. /**
  111965. * Gets friction of the impostor
  111966. * @param impostor impostor to get friction from
  111967. * @returns friction value
  111968. */
  111969. getBodyFriction(impostor: PhysicsImpostor): number;
  111970. /**
  111971. * Sets friction of the impostor
  111972. * @param impostor impostor to set friction on
  111973. * @param friction friction value
  111974. */
  111975. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111976. /**
  111977. * Gets restitution of the impostor
  111978. * @param impostor impostor to get restitution from
  111979. * @returns restitution value
  111980. */
  111981. getBodyRestitution(impostor: PhysicsImpostor): number;
  111982. /**
  111983. * Sets resitution of the impostor
  111984. * @param impostor impostor to set resitution on
  111985. * @param restitution resitution value
  111986. */
  111987. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111988. /**
  111989. * Gets pressure inside the impostor
  111990. * @param impostor impostor to get pressure from
  111991. * @returns pressure value
  111992. */
  111993. getBodyPressure(impostor: PhysicsImpostor): number;
  111994. /**
  111995. * Sets pressure inside a soft body impostor
  111996. * Cloth and rope must remain 0 pressure
  111997. * @param impostor impostor to set pressure on
  111998. * @param pressure pressure value
  111999. */
  112000. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112001. /**
  112002. * Gets stiffness of the impostor
  112003. * @param impostor impostor to get stiffness from
  112004. * @returns pressure value
  112005. */
  112006. getBodyStiffness(impostor: PhysicsImpostor): number;
  112007. /**
  112008. * Sets stiffness of the impostor
  112009. * @param impostor impostor to set stiffness on
  112010. * @param stiffness stiffness value from 0 to 1
  112011. */
  112012. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112013. /**
  112014. * Gets velocityIterations of the impostor
  112015. * @param impostor impostor to get velocity iterations from
  112016. * @returns velocityIterations value
  112017. */
  112018. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112019. /**
  112020. * Sets velocityIterations of the impostor
  112021. * @param impostor impostor to set velocity iterations on
  112022. * @param velocityIterations velocityIterations value
  112023. */
  112024. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112025. /**
  112026. * Gets positionIterations of the impostor
  112027. * @param impostor impostor to get position iterations from
  112028. * @returns positionIterations value
  112029. */
  112030. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112031. /**
  112032. * Sets positionIterations of the impostor
  112033. * @param impostor impostor to set position on
  112034. * @param positionIterations positionIterations value
  112035. */
  112036. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112037. /**
  112038. * Append an anchor to a cloth object
  112039. * @param impostor is the cloth impostor to add anchor to
  112040. * @param otherImpostor is the rigid impostor to anchor to
  112041. * @param width ratio across width from 0 to 1
  112042. * @param height ratio up height from 0 to 1
  112043. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112044. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112045. */
  112046. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112047. /**
  112048. * Append an hook to a rope object
  112049. * @param impostor is the rope impostor to add hook to
  112050. * @param otherImpostor is the rigid impostor to hook to
  112051. * @param length ratio along the rope from 0 to 1
  112052. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112053. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112054. */
  112055. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112056. /**
  112057. * Sleeps the physics body and stops it from being active
  112058. * @param impostor impostor to sleep
  112059. */
  112060. sleepBody(impostor: PhysicsImpostor): void;
  112061. /**
  112062. * Activates the physics body
  112063. * @param impostor impostor to activate
  112064. */
  112065. wakeUpBody(impostor: PhysicsImpostor): void;
  112066. /**
  112067. * Updates the distance parameters of the joint
  112068. * @param joint joint to update
  112069. * @param maxDistance maximum distance of the joint
  112070. * @param minDistance minimum distance of the joint
  112071. */
  112072. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112073. /**
  112074. * Sets a motor on the joint
  112075. * @param joint joint to set motor on
  112076. * @param speed speed of the motor
  112077. * @param maxForce maximum force of the motor
  112078. * @param motorIndex index of the motor
  112079. */
  112080. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112081. /**
  112082. * Sets the motors limit
  112083. * @param joint joint to set limit on
  112084. * @param upperLimit upper limit
  112085. * @param lowerLimit lower limit
  112086. */
  112087. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112088. /**
  112089. * Syncs the position and rotation of a mesh with the impostor
  112090. * @param mesh mesh to sync
  112091. * @param impostor impostor to update the mesh with
  112092. */
  112093. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112094. /**
  112095. * Gets the radius of the impostor
  112096. * @param impostor impostor to get radius from
  112097. * @returns the radius
  112098. */
  112099. getRadius(impostor: PhysicsImpostor): number;
  112100. /**
  112101. * Gets the box size of the impostor
  112102. * @param impostor impostor to get box size from
  112103. * @param result the resulting box size
  112104. */
  112105. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112106. /**
  112107. * Disposes of the impostor
  112108. */
  112109. dispose(): void;
  112110. /**
  112111. * Does a raycast in the physics world
  112112. * @param from when should the ray start?
  112113. * @param to when should the ray end?
  112114. * @returns PhysicsRaycastResult
  112115. */
  112116. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112117. }
  112118. }
  112119. declare module BABYLON {
  112120. interface AbstractScene {
  112121. /**
  112122. * The list of reflection probes added to the scene
  112123. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112124. */
  112125. reflectionProbes: Array<ReflectionProbe>;
  112126. /**
  112127. * Removes the given reflection probe from this scene.
  112128. * @param toRemove The reflection probe to remove
  112129. * @returns The index of the removed reflection probe
  112130. */
  112131. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112132. /**
  112133. * Adds the given reflection probe to this scene.
  112134. * @param newReflectionProbe The reflection probe to add
  112135. */
  112136. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112137. }
  112138. /**
  112139. * Class used to generate realtime reflection / refraction cube textures
  112140. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112141. */
  112142. export class ReflectionProbe {
  112143. /** defines the name of the probe */
  112144. name: string;
  112145. private _scene;
  112146. private _renderTargetTexture;
  112147. private _projectionMatrix;
  112148. private _viewMatrix;
  112149. private _target;
  112150. private _add;
  112151. private _attachedMesh;
  112152. private _invertYAxis;
  112153. /** Gets or sets probe position (center of the cube map) */
  112154. position: Vector3;
  112155. /**
  112156. * Creates a new reflection probe
  112157. * @param name defines the name of the probe
  112158. * @param size defines the texture resolution (for each face)
  112159. * @param scene defines the hosting scene
  112160. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112161. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112162. */
  112163. constructor(
  112164. /** defines the name of the probe */
  112165. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112166. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112167. samples: number;
  112168. /** Gets or sets the refresh rate to use (on every frame by default) */
  112169. refreshRate: number;
  112170. /**
  112171. * Gets the hosting scene
  112172. * @returns a Scene
  112173. */
  112174. getScene(): Scene;
  112175. /** Gets the internal CubeTexture used to render to */
  112176. readonly cubeTexture: RenderTargetTexture;
  112177. /** Gets the list of meshes to render */
  112178. readonly renderList: Nullable<AbstractMesh[]>;
  112179. /**
  112180. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112181. * @param mesh defines the mesh to attach to
  112182. */
  112183. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112184. /**
  112185. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112186. * @param renderingGroupId The rendering group id corresponding to its index
  112187. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112188. */
  112189. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112190. /**
  112191. * Clean all associated resources
  112192. */
  112193. dispose(): void;
  112194. /**
  112195. * Converts the reflection probe information to a readable string for debug purpose.
  112196. * @param fullDetails Supports for multiple levels of logging within scene loading
  112197. * @returns the human readable reflection probe info
  112198. */
  112199. toString(fullDetails?: boolean): string;
  112200. /**
  112201. * Get the class name of the relfection probe.
  112202. * @returns "ReflectionProbe"
  112203. */
  112204. getClassName(): string;
  112205. /**
  112206. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112207. * @returns The JSON representation of the texture
  112208. */
  112209. serialize(): any;
  112210. /**
  112211. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112212. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112213. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112214. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112215. * @returns The parsed reflection probe if successful
  112216. */
  112217. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112218. }
  112219. }
  112220. declare module BABYLON {
  112221. /** @hidden */
  112222. export var _BabylonLoaderRegistered: boolean;
  112223. }
  112224. declare module BABYLON {
  112225. /**
  112226. * The Physically based simple base material of BJS.
  112227. *
  112228. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112229. * It is used as the base class for both the specGloss and metalRough conventions.
  112230. */
  112231. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112232. /**
  112233. * Number of Simultaneous lights allowed on the material.
  112234. */
  112235. maxSimultaneousLights: number;
  112236. /**
  112237. * If sets to true, disables all the lights affecting the material.
  112238. */
  112239. disableLighting: boolean;
  112240. /**
  112241. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112242. */
  112243. environmentTexture: BaseTexture;
  112244. /**
  112245. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112246. */
  112247. invertNormalMapX: boolean;
  112248. /**
  112249. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112250. */
  112251. invertNormalMapY: boolean;
  112252. /**
  112253. * Normal map used in the model.
  112254. */
  112255. normalTexture: BaseTexture;
  112256. /**
  112257. * Emissivie color used to self-illuminate the model.
  112258. */
  112259. emissiveColor: Color3;
  112260. /**
  112261. * Emissivie texture used to self-illuminate the model.
  112262. */
  112263. emissiveTexture: BaseTexture;
  112264. /**
  112265. * Occlusion Channel Strenght.
  112266. */
  112267. occlusionStrength: number;
  112268. /**
  112269. * Occlusion Texture of the material (adding extra occlusion effects).
  112270. */
  112271. occlusionTexture: BaseTexture;
  112272. /**
  112273. * Defines the alpha limits in alpha test mode.
  112274. */
  112275. alphaCutOff: number;
  112276. /**
  112277. * Gets the current double sided mode.
  112278. */
  112279. /**
  112280. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112281. */
  112282. doubleSided: boolean;
  112283. /**
  112284. * Stores the pre-calculated light information of a mesh in a texture.
  112285. */
  112286. lightmapTexture: BaseTexture;
  112287. /**
  112288. * If true, the light map contains occlusion information instead of lighting info.
  112289. */
  112290. useLightmapAsShadowmap: boolean;
  112291. /**
  112292. * Instantiates a new PBRMaterial instance.
  112293. *
  112294. * @param name The material name
  112295. * @param scene The scene the material will be use in.
  112296. */
  112297. constructor(name: string, scene: Scene);
  112298. getClassName(): string;
  112299. }
  112300. }
  112301. declare module BABYLON {
  112302. /**
  112303. * The PBR material of BJS following the metal roughness convention.
  112304. *
  112305. * This fits to the PBR convention in the GLTF definition:
  112306. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112307. */
  112308. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112309. /**
  112310. * The base color has two different interpretations depending on the value of metalness.
  112311. * When the material is a metal, the base color is the specific measured reflectance value
  112312. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112313. * of the material.
  112314. */
  112315. baseColor: Color3;
  112316. /**
  112317. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112318. * well as opacity information in the alpha channel.
  112319. */
  112320. baseTexture: BaseTexture;
  112321. /**
  112322. * Specifies the metallic scalar value of the material.
  112323. * Can also be used to scale the metalness values of the metallic texture.
  112324. */
  112325. metallic: number;
  112326. /**
  112327. * Specifies the roughness scalar value of the material.
  112328. * Can also be used to scale the roughness values of the metallic texture.
  112329. */
  112330. roughness: number;
  112331. /**
  112332. * Texture containing both the metallic value in the B channel and the
  112333. * roughness value in the G channel to keep better precision.
  112334. */
  112335. metallicRoughnessTexture: BaseTexture;
  112336. /**
  112337. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112338. *
  112339. * @param name The material name
  112340. * @param scene The scene the material will be use in.
  112341. */
  112342. constructor(name: string, scene: Scene);
  112343. /**
  112344. * Return the currrent class name of the material.
  112345. */
  112346. getClassName(): string;
  112347. /**
  112348. * Makes a duplicate of the current material.
  112349. * @param name - name to use for the new material.
  112350. */
  112351. clone(name: string): PBRMetallicRoughnessMaterial;
  112352. /**
  112353. * Serialize the material to a parsable JSON object.
  112354. */
  112355. serialize(): any;
  112356. /**
  112357. * Parses a JSON object correponding to the serialize function.
  112358. */
  112359. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112360. }
  112361. }
  112362. declare module BABYLON {
  112363. /**
  112364. * The PBR material of BJS following the specular glossiness convention.
  112365. *
  112366. * This fits to the PBR convention in the GLTF definition:
  112367. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112368. */
  112369. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112370. /**
  112371. * Specifies the diffuse color of the material.
  112372. */
  112373. diffuseColor: Color3;
  112374. /**
  112375. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112376. * channel.
  112377. */
  112378. diffuseTexture: BaseTexture;
  112379. /**
  112380. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112381. */
  112382. specularColor: Color3;
  112383. /**
  112384. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112385. */
  112386. glossiness: number;
  112387. /**
  112388. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112389. */
  112390. specularGlossinessTexture: BaseTexture;
  112391. /**
  112392. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112393. *
  112394. * @param name The material name
  112395. * @param scene The scene the material will be use in.
  112396. */
  112397. constructor(name: string, scene: Scene);
  112398. /**
  112399. * Return the currrent class name of the material.
  112400. */
  112401. getClassName(): string;
  112402. /**
  112403. * Makes a duplicate of the current material.
  112404. * @param name - name to use for the new material.
  112405. */
  112406. clone(name: string): PBRSpecularGlossinessMaterial;
  112407. /**
  112408. * Serialize the material to a parsable JSON object.
  112409. */
  112410. serialize(): any;
  112411. /**
  112412. * Parses a JSON object correponding to the serialize function.
  112413. */
  112414. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112415. }
  112416. }
  112417. declare module BABYLON {
  112418. /**
  112419. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112420. * It can help converting any input color in a desired output one. This can then be used to create effects
  112421. * from sepia, black and white to sixties or futuristic rendering...
  112422. *
  112423. * The only supported format is currently 3dl.
  112424. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112425. */
  112426. export class ColorGradingTexture extends BaseTexture {
  112427. /**
  112428. * The current texture matrix. (will always be identity in color grading texture)
  112429. */
  112430. private _textureMatrix;
  112431. /**
  112432. * The texture URL.
  112433. */
  112434. url: string;
  112435. /**
  112436. * Empty line regex stored for GC.
  112437. */
  112438. private static _noneEmptyLineRegex;
  112439. private _engine;
  112440. /**
  112441. * Instantiates a ColorGradingTexture from the following parameters.
  112442. *
  112443. * @param url The location of the color gradind data (currently only supporting 3dl)
  112444. * @param scene The scene the texture will be used in
  112445. */
  112446. constructor(url: string, scene: Scene);
  112447. /**
  112448. * Returns the texture matrix used in most of the material.
  112449. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112450. */
  112451. getTextureMatrix(): Matrix;
  112452. /**
  112453. * Occurs when the file being loaded is a .3dl LUT file.
  112454. */
  112455. private load3dlTexture;
  112456. /**
  112457. * Starts the loading process of the texture.
  112458. */
  112459. private loadTexture;
  112460. /**
  112461. * Clones the color gradind texture.
  112462. */
  112463. clone(): ColorGradingTexture;
  112464. /**
  112465. * Called during delayed load for textures.
  112466. */
  112467. delayLoad(): void;
  112468. /**
  112469. * Parses a color grading texture serialized by Babylon.
  112470. * @param parsedTexture The texture information being parsedTexture
  112471. * @param scene The scene to load the texture in
  112472. * @param rootUrl The root url of the data assets to load
  112473. * @return A color gradind texture
  112474. */
  112475. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112476. /**
  112477. * Serializes the LUT texture to json format.
  112478. */
  112479. serialize(): any;
  112480. }
  112481. }
  112482. declare module BABYLON {
  112483. /**
  112484. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112485. */
  112486. export class EquiRectangularCubeTexture extends BaseTexture {
  112487. /** The six faces of the cube. */
  112488. private static _FacesMapping;
  112489. private _noMipmap;
  112490. private _onLoad;
  112491. private _onError;
  112492. /** The size of the cubemap. */
  112493. private _size;
  112494. /** The buffer of the image. */
  112495. private _buffer;
  112496. /** The width of the input image. */
  112497. private _width;
  112498. /** The height of the input image. */
  112499. private _height;
  112500. /** The URL to the image. */
  112501. url: string;
  112502. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112503. coordinatesMode: number;
  112504. /**
  112505. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112506. * @param url The location of the image
  112507. * @param scene The scene the texture will be used in
  112508. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112509. * @param noMipmap Forces to not generate the mipmap if true
  112510. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112511. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112512. * @param onLoad — defines a callback called when texture is loaded
  112513. * @param onError — defines a callback called if there is an error
  112514. */
  112515. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112516. /**
  112517. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112518. */
  112519. private loadImage;
  112520. /**
  112521. * Convert the image buffer into a cubemap and create a CubeTexture.
  112522. */
  112523. private loadTexture;
  112524. /**
  112525. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112526. * @param buffer The ArrayBuffer that should be converted.
  112527. * @returns The buffer as Float32Array.
  112528. */
  112529. private getFloat32ArrayFromArrayBuffer;
  112530. /**
  112531. * Get the current class name of the texture useful for serialization or dynamic coding.
  112532. * @returns "EquiRectangularCubeTexture"
  112533. */
  112534. getClassName(): string;
  112535. /**
  112536. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112537. * @returns A clone of the current EquiRectangularCubeTexture.
  112538. */
  112539. clone(): EquiRectangularCubeTexture;
  112540. }
  112541. }
  112542. declare module BABYLON {
  112543. /**
  112544. * Based on jsTGALoader - Javascript loader for TGA file
  112545. * By Vincent Thibault
  112546. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112547. */
  112548. export class TGATools {
  112549. private static _TYPE_INDEXED;
  112550. private static _TYPE_RGB;
  112551. private static _TYPE_GREY;
  112552. private static _TYPE_RLE_INDEXED;
  112553. private static _TYPE_RLE_RGB;
  112554. private static _TYPE_RLE_GREY;
  112555. private static _ORIGIN_MASK;
  112556. private static _ORIGIN_SHIFT;
  112557. private static _ORIGIN_BL;
  112558. private static _ORIGIN_BR;
  112559. private static _ORIGIN_UL;
  112560. private static _ORIGIN_UR;
  112561. /**
  112562. * Gets the header of a TGA file
  112563. * @param data defines the TGA data
  112564. * @returns the header
  112565. */
  112566. static GetTGAHeader(data: Uint8Array): any;
  112567. /**
  112568. * Uploads TGA content to a Babylon Texture
  112569. * @hidden
  112570. */
  112571. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112572. /** @hidden */
  112573. 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;
  112574. /** @hidden */
  112575. 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;
  112576. /** @hidden */
  112577. 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;
  112578. /** @hidden */
  112579. 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;
  112580. /** @hidden */
  112581. 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;
  112582. /** @hidden */
  112583. 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;
  112584. }
  112585. }
  112586. declare module BABYLON {
  112587. /**
  112588. * Implementation of the TGA Texture Loader.
  112589. * @hidden
  112590. */
  112591. export class _TGATextureLoader implements IInternalTextureLoader {
  112592. /**
  112593. * Defines wether the loader supports cascade loading the different faces.
  112594. */
  112595. readonly supportCascades: boolean;
  112596. /**
  112597. * This returns if the loader support the current file information.
  112598. * @param extension defines the file extension of the file being loaded
  112599. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112600. * @param fallback defines the fallback internal texture if any
  112601. * @param isBase64 defines whether the texture is encoded as a base64
  112602. * @param isBuffer defines whether the texture data are stored as a buffer
  112603. * @returns true if the loader can load the specified file
  112604. */
  112605. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112606. /**
  112607. * Transform the url before loading if required.
  112608. * @param rootUrl the url of the texture
  112609. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112610. * @returns the transformed texture
  112611. */
  112612. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112613. /**
  112614. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112615. * @param rootUrl the url of the texture
  112616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112617. * @returns the fallback texture
  112618. */
  112619. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112620. /**
  112621. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112622. * @param data contains the texture data
  112623. * @param texture defines the BabylonJS internal texture
  112624. * @param createPolynomials will be true if polynomials have been requested
  112625. * @param onLoad defines the callback to trigger once the texture is ready
  112626. * @param onError defines the callback to trigger in case of error
  112627. */
  112628. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112629. /**
  112630. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112631. * @param data contains the texture data
  112632. * @param texture defines the BabylonJS internal texture
  112633. * @param callback defines the method to call once ready to upload
  112634. */
  112635. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112636. }
  112637. }
  112638. declare module BABYLON {
  112639. /**
  112640. * Info about the .basis files
  112641. */
  112642. class BasisFileInfo {
  112643. /**
  112644. * If the file has alpha
  112645. */
  112646. hasAlpha: boolean;
  112647. /**
  112648. * Width of the image
  112649. */
  112650. width: number;
  112651. /**
  112652. * Height of the image
  112653. */
  112654. height: number;
  112655. /**
  112656. * Aligned width used when falling back to Rgb565 ((width + 3) & ~3)
  112657. */
  112658. alignedWidth: number;
  112659. /**
  112660. * Aligned height used when falling back to Rgb565 ((height + 3) & ~3)
  112661. */
  112662. alignedHeight: number;
  112663. }
  112664. /**
  112665. * Used to load .Basis files
  112666. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  112667. */
  112668. export class BasisTools {
  112669. private static _IgnoreSupportedFormats;
  112670. private static _LoadScriptPromise;
  112671. private static _FallbackURL;
  112672. private static _BASIS_FORMAT;
  112673. /**
  112674. * Basis module can be aquired from https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  112675. * This should be set prior to loading a .basis texture
  112676. */
  112677. static BasisModule: Nullable<any>;
  112678. /**
  112679. * Verifies that the BasisModule has been populated and falls back to loading from the web if not availible
  112680. * @returns promise which will resolve if the basis module was loaded
  112681. */
  112682. static VerifyBasisModuleAsync(): any;
  112683. /**
  112684. * Verifies that the basis module has been populated and creates a bsis file from the image data
  112685. * @param data array buffer of the .basis file
  112686. * @returns the Basis file
  112687. */
  112688. static LoadBasisFile(data: ArrayBuffer): any;
  112689. /**
  112690. * Detects the supported transcode format for the file
  112691. * @param engine Babylon engine
  112692. * @param fileInfo info about the file
  112693. * @returns the chosed format or null if none are supported
  112694. */
  112695. static GetSupportedTranscodeFormat(engine: Engine, fileInfo: BasisFileInfo): Nullable<number>;
  112696. /**
  112697. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  112698. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  112699. * @returns internal format corresponding to the Basis format
  112700. */
  112701. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  112702. /**
  112703. * Retreives information about the basis file eg. dimensions
  112704. * @param basisFile the basis file to get the info from
  112705. * @returns information about the basis file
  112706. */
  112707. static GetFileInfo(basisFile: any): BasisFileInfo;
  112708. /**
  112709. * Transcodes the basis file to the requested format to be transferred to the gpu
  112710. * @param format fromat to be transferred to
  112711. * @param fileInfo information about the loaded file
  112712. * @param loadedFile the loaded basis file
  112713. * @returns the resulting pixels and if the transcode fell back to using Rgb565
  112714. */
  112715. static TranscodeFile(format: Nullable<number>, fileInfo: BasisFileInfo, loadedFile: any): {
  112716. fallbackToRgb565: boolean;
  112717. pixels: Uint8Array;
  112718. };
  112719. /**
  112720. * From https://github.com/BinomialLLC/basis_universal/blob/master/webgl/texture/dxt-to-rgb565.js
  112721. * An unoptimized version of dxtToRgb565. Also, the floating
  112722. * point math used to compute the colors actually results in
  112723. * slightly different colors compared to hardware DXT decoders.
  112724. * @param src dxt src pixels
  112725. * @param srcByteOffset offset for the start of src
  112726. * @param width aligned width of the image
  112727. * @param height aligned height of the image
  112728. * @return the converted pixels
  112729. */
  112730. static ConvertDxtToRgb565(src: Uint16Array, srcByteOffset: number, width: number, height: number): Uint16Array;
  112731. }
  112732. }
  112733. declare module BABYLON {
  112734. /**
  112735. * Loader for .basis file format
  112736. */
  112737. export class _BasisTextureLoader implements IInternalTextureLoader {
  112738. /**
  112739. * Defines whether the loader supports cascade loading the different faces.
  112740. */
  112741. readonly supportCascades: boolean;
  112742. /**
  112743. * This returns if the loader support the current file information.
  112744. * @param extension defines the file extension of the file being loaded
  112745. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112746. * @param fallback defines the fallback internal texture if any
  112747. * @param isBase64 defines whether the texture is encoded as a base64
  112748. * @param isBuffer defines whether the texture data are stored as a buffer
  112749. * @returns true if the loader can load the specified file
  112750. */
  112751. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112752. /**
  112753. * Transform the url before loading if required.
  112754. * @param rootUrl the url of the texture
  112755. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112756. * @returns the transformed texture
  112757. */
  112758. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112759. /**
  112760. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112761. * @param rootUrl the url of the texture
  112762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112763. * @returns the fallback texture
  112764. */
  112765. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112766. /**
  112767. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  112768. * @param data contains the texture data
  112769. * @param texture defines the BabylonJS internal texture
  112770. * @param createPolynomials will be true if polynomials have been requested
  112771. * @param onLoad defines the callback to trigger once the texture is ready
  112772. * @param onError defines the callback to trigger in case of error
  112773. */
  112774. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112775. /**
  112776. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112777. * @param data contains the texture data
  112778. * @param texture defines the BabylonJS internal texture
  112779. * @param callback defines the method to call once ready to upload
  112780. */
  112781. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112782. }
  112783. }
  112784. declare module BABYLON {
  112785. /**
  112786. * 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.
  112787. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112788. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112789. */
  112790. export class CustomProceduralTexture extends ProceduralTexture {
  112791. private _animate;
  112792. private _time;
  112793. private _config;
  112794. private _texturePath;
  112795. /**
  112796. * Instantiates a new Custom Procedural Texture.
  112797. * 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.
  112798. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112799. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112800. * @param name Define the name of the texture
  112801. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  112802. * @param size Define the size of the texture to create
  112803. * @param scene Define the scene the texture belongs to
  112804. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  112805. * @param generateMipMaps Define if the texture should creates mip maps or not
  112806. */
  112807. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112808. private _loadJson;
  112809. /**
  112810. * Is the texture ready to be used ? (rendered at least once)
  112811. * @returns true if ready, otherwise, false.
  112812. */
  112813. isReady(): boolean;
  112814. /**
  112815. * Render the texture to its associated render target.
  112816. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  112817. */
  112818. render(useCameraPostProcess?: boolean): void;
  112819. /**
  112820. * Update the list of dependant textures samplers in the shader.
  112821. */
  112822. updateTextures(): void;
  112823. /**
  112824. * Update the uniform values of the procedural texture in the shader.
  112825. */
  112826. updateShaderUniforms(): void;
  112827. /**
  112828. * Define if the texture animates or not.
  112829. */
  112830. animate: boolean;
  112831. }
  112832. }
  112833. declare module BABYLON {
  112834. /** @hidden */
  112835. export var noisePixelShader: {
  112836. name: string;
  112837. shader: string;
  112838. };
  112839. }
  112840. declare module BABYLON {
  112841. /**
  112842. * Class used to generate noise procedural textures
  112843. */
  112844. export class NoiseProceduralTexture extends ProceduralTexture {
  112845. private _time;
  112846. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  112847. brightness: number;
  112848. /** Defines the number of octaves to process */
  112849. octaves: number;
  112850. /** Defines the level of persistence (0.8 by default) */
  112851. persistence: number;
  112852. /** Gets or sets animation speed factor (default is 1) */
  112853. animationSpeedFactor: number;
  112854. /**
  112855. * Creates a new NoiseProceduralTexture
  112856. * @param name defines the name fo the texture
  112857. * @param size defines the size of the texture (default is 256)
  112858. * @param scene defines the hosting scene
  112859. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  112860. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  112861. */
  112862. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112863. private _updateShaderUniforms;
  112864. protected _getDefines(): string;
  112865. /** Generate the current state of the procedural texture */
  112866. render(useCameraPostProcess?: boolean): void;
  112867. /**
  112868. * Serializes this noise procedural texture
  112869. * @returns a serialized noise procedural texture object
  112870. */
  112871. serialize(): any;
  112872. /**
  112873. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  112874. * @param parsedTexture defines parsed texture data
  112875. * @param scene defines the current scene
  112876. * @param rootUrl defines the root URL containing noise procedural texture information
  112877. * @returns a parsed NoiseProceduralTexture
  112878. */
  112879. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  112880. }
  112881. }
  112882. declare module BABYLON {
  112883. /**
  112884. * Raw cube texture where the raw buffers are passed in
  112885. */
  112886. export class RawCubeTexture extends CubeTexture {
  112887. /**
  112888. * Creates a cube texture where the raw buffers are passed in.
  112889. * @param scene defines the scene the texture is attached to
  112890. * @param data defines the array of data to use to create each face
  112891. * @param size defines the size of the textures
  112892. * @param format defines the format of the data
  112893. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  112894. * @param generateMipMaps defines if the engine should generate the mip levels
  112895. * @param invertY defines if data must be stored with Y axis inverted
  112896. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  112897. * @param compression defines the compression used (null by default)
  112898. */
  112899. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  112900. /**
  112901. * Updates the raw cube texture.
  112902. * @param data defines the data to store
  112903. * @param format defines the data format
  112904. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112905. * @param invertY defines if data must be stored with Y axis inverted
  112906. * @param compression defines the compression used (null by default)
  112907. * @param level defines which level of the texture to update
  112908. */
  112909. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  112910. /**
  112911. * Updates a raw cube texture with RGBD encoded data.
  112912. * @param data defines the array of data [mipmap][face] to use to create each face
  112913. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  112914. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112915. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112916. * @returns a promsie that resolves when the operation is complete
  112917. */
  112918. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  112919. /**
  112920. * Clones the raw cube texture.
  112921. * @return a new cube texture
  112922. */
  112923. clone(): CubeTexture;
  112924. /** @hidden */
  112925. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112926. }
  112927. }
  112928. declare module BABYLON {
  112929. /**
  112930. * Class used to store 3D textures containing user data
  112931. */
  112932. export class RawTexture3D extends Texture {
  112933. /** Gets or sets the texture format to use */
  112934. format: number;
  112935. private _engine;
  112936. /**
  112937. * Create a new RawTexture3D
  112938. * @param data defines the data of the texture
  112939. * @param width defines the width of the texture
  112940. * @param height defines the height of the texture
  112941. * @param depth defines the depth of the texture
  112942. * @param format defines the texture format to use
  112943. * @param scene defines the hosting scene
  112944. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  112945. * @param invertY defines if texture must be stored with Y axis inverted
  112946. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112947. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  112948. */
  112949. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  112950. /** Gets or sets the texture format to use */
  112951. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  112952. /**
  112953. * Update the texture with new data
  112954. * @param data defines the data to store in the texture
  112955. */
  112956. update(data: ArrayBufferView): void;
  112957. }
  112958. }
  112959. declare module BABYLON {
  112960. /**
  112961. * Creates a refraction texture used by refraction channel of the standard material.
  112962. * It is like a mirror but to see through a material.
  112963. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112964. */
  112965. export class RefractionTexture extends RenderTargetTexture {
  112966. /**
  112967. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  112968. * 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.
  112969. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112970. */
  112971. refractionPlane: Plane;
  112972. /**
  112973. * Define how deep under the surface we should see.
  112974. */
  112975. depth: number;
  112976. /**
  112977. * Creates a refraction texture used by refraction channel of the standard material.
  112978. * It is like a mirror but to see through a material.
  112979. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112980. * @param name Define the texture name
  112981. * @param size Define the size of the underlying texture
  112982. * @param scene Define the scene the refraction belongs to
  112983. * @param generateMipMaps Define if we need to generate mips level for the refraction
  112984. */
  112985. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  112986. /**
  112987. * Clone the refraction texture.
  112988. * @returns the cloned texture
  112989. */
  112990. clone(): RefractionTexture;
  112991. /**
  112992. * Serialize the texture to a JSON representation you could use in Parse later on
  112993. * @returns the serialized JSON representation
  112994. */
  112995. serialize(): any;
  112996. }
  112997. }
  112998. declare module BABYLON {
  112999. /**
  113000. * Defines the options related to the creation of an HtmlElementTexture
  113001. */
  113002. export interface IHtmlElementTextureOptions {
  113003. /**
  113004. * Defines wether mip maps should be created or not.
  113005. */
  113006. generateMipMaps?: boolean;
  113007. /**
  113008. * Defines the sampling mode of the texture.
  113009. */
  113010. samplingMode?: number;
  113011. /**
  113012. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113013. */
  113014. engine: Nullable<Engine>;
  113015. /**
  113016. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113017. */
  113018. scene: Nullable<Scene>;
  113019. }
  113020. /**
  113021. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113022. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113023. * is automatically managed.
  113024. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113025. * in your application.
  113026. *
  113027. * As the update is not automatic, you need to call them manually.
  113028. */
  113029. export class HtmlElementTexture extends BaseTexture {
  113030. /**
  113031. * The texture URL.
  113032. */
  113033. element: HTMLVideoElement | HTMLCanvasElement;
  113034. private static readonly DefaultOptions;
  113035. private _textureMatrix;
  113036. private _engine;
  113037. private _isVideo;
  113038. private _generateMipMaps;
  113039. private _samplingMode;
  113040. /**
  113041. * Instantiates a HtmlElementTexture from the following parameters.
  113042. *
  113043. * @param name Defines the name of the texture
  113044. * @param element Defines the video or canvas the texture is filled with
  113045. * @param options Defines the other none mandatory texture creation options
  113046. */
  113047. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113048. private _createInternalTexture;
  113049. /**
  113050. * Returns the texture matrix used in most of the material.
  113051. */
  113052. getTextureMatrix(): Matrix;
  113053. /**
  113054. * Updates the content of the texture.
  113055. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113056. */
  113057. update(invertY?: Nullable<boolean>): void;
  113058. }
  113059. }
  113060. declare module BABYLON {
  113061. /**
  113062. * Enum used to define the target of a block
  113063. */
  113064. export enum NodeMaterialBlockTargets {
  113065. /** Vertex shader */
  113066. Vertex = 1,
  113067. /** Fragment shader */
  113068. Fragment = 2,
  113069. /** Vertex and Fragment */
  113070. VertexAndFragment = 3
  113071. }
  113072. }
  113073. declare module BABYLON {
  113074. /**
  113075. * Defines the kind of connection point for node based material
  113076. */
  113077. export enum NodeMaterialBlockConnectionPointTypes {
  113078. /** Float */
  113079. Float = 1,
  113080. /** Int */
  113081. Int = 2,
  113082. /** Vector2 */
  113083. Vector2 = 4,
  113084. /** Vector3 */
  113085. Vector3 = 8,
  113086. /** Vector4 */
  113087. Vector4 = 16,
  113088. /** Color3 */
  113089. Color3 = 32,
  113090. /** Color4 */
  113091. Color4 = 64,
  113092. /** Matrix */
  113093. Matrix = 128,
  113094. /** Texture */
  113095. Texture = 256,
  113096. /** Texture3D */
  113097. Texture3D = 512,
  113098. /** Vector3 or Color3 */
  113099. Vector3OrColor3 = 40,
  113100. /** Vector3 or Vector4 */
  113101. Vector3OrVector4 = 24,
  113102. /** Vector4 or Color4 */
  113103. Vector4OrColor4 = 80,
  113104. /** Color3 or Color4 */
  113105. Color3OrColor4 = 96,
  113106. /** Vector3 or Color3 */
  113107. Vector3OrColor3OrVector4OrColor4 = 120
  113108. }
  113109. }
  113110. declare module BABYLON {
  113111. /**
  113112. * Enum used to define well known values e.g. values automatically provided by the system
  113113. */
  113114. export enum NodeMaterialWellKnownValues {
  113115. /** World */
  113116. World = 1,
  113117. /** View */
  113118. View = 2,
  113119. /** Projection */
  113120. Projection = 3,
  113121. /** ViewProjection */
  113122. ViewProjection = 4,
  113123. /** WorldView */
  113124. WorldView = 5,
  113125. /** WorldViewProjection */
  113126. WorldViewProjection = 6,
  113127. /** Will be filled by the block itself */
  113128. Automatic = 7
  113129. }
  113130. }
  113131. declare module BABYLON {
  113132. /**
  113133. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113134. */
  113135. export enum NodeMaterialBlockConnectionPointMode {
  113136. /** Value is an uniform */
  113137. Uniform = 0,
  113138. /** Value is a mesh attribute */
  113139. Attribute = 1,
  113140. /** Value is a varying between vertex and fragment shaders */
  113141. Varying = 2,
  113142. /** Mode is undefined */
  113143. Undefined = 3
  113144. }
  113145. }
  113146. declare module BABYLON {
  113147. /**
  113148. * Class used to store shared data between 2 NodeMaterialBuildState
  113149. */
  113150. export class NodeMaterialBuildStateSharedData {
  113151. /**
  113152. * Gets the list of emitted varyings
  113153. */
  113154. varyings: string[];
  113155. /**
  113156. * Gets the varying declaration string
  113157. */
  113158. varyingDeclaration: string;
  113159. /**
  113160. * Uniform connection points
  113161. */
  113162. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113163. /**
  113164. * Bindable blocks (Blocks that need to set data to the effect)
  113165. */
  113166. bindableBlocks: NodeMaterialBlock[];
  113167. /**
  113168. * List of blocks that can provide a compilation fallback
  113169. */
  113170. blocksWithFallbacks: NodeMaterialBlock[];
  113171. /**
  113172. * List of blocks that can provide a define update
  113173. */
  113174. blocksWithDefines: NodeMaterialBlock[];
  113175. /**
  113176. * List of blocks that can provide a repeatable content
  113177. */
  113178. repeatableContentBlocks: NodeMaterialBlock[];
  113179. /**
  113180. * List of blocks that can block the isReady function for the material
  113181. */
  113182. blockingBlocks: NodeMaterialBlock[];
  113183. /**
  113184. * Build Id used to avoid multiple recompilations
  113185. */
  113186. buildId: number;
  113187. /** List of emitted variables */
  113188. variableNames: {
  113189. [key: string]: number;
  113190. };
  113191. /** List of emitted defines */
  113192. defineNames: {
  113193. [key: string]: number;
  113194. };
  113195. /** Should emit comments? */
  113196. emitComments: boolean;
  113197. /** Emit build activity */
  113198. verbose: boolean;
  113199. /**
  113200. * Gets the compilation hints emitted at compilation time
  113201. */
  113202. hints: {
  113203. needWorldViewMatrix: boolean;
  113204. needWorldViewProjectionMatrix: boolean;
  113205. needAlphaBlending: boolean;
  113206. needAlphaTesting: boolean;
  113207. };
  113208. /**
  113209. * List of compilation checks
  113210. */
  113211. checks: {
  113212. emitVertex: boolean;
  113213. emitFragment: boolean;
  113214. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113215. };
  113216. /** Creates a new shared data */
  113217. constructor();
  113218. /**
  113219. * Emits console errors and exceptions if there is a failing check
  113220. */
  113221. emitErrors(): void;
  113222. }
  113223. }
  113224. declare module BABYLON {
  113225. /**
  113226. * Class used to store node based material build state
  113227. */
  113228. export class NodeMaterialBuildState {
  113229. /**
  113230. * Gets the list of emitted attributes
  113231. */
  113232. attributes: string[];
  113233. /**
  113234. * Gets the list of emitted uniforms
  113235. */
  113236. uniforms: string[];
  113237. /**
  113238. * Gets the list of emitted samplers
  113239. */
  113240. samplers: string[];
  113241. /**
  113242. * Gets the list of emitted functions
  113243. */
  113244. functions: {
  113245. [key: string]: string;
  113246. };
  113247. /**
  113248. * Gets the target of the compilation state
  113249. */
  113250. target: NodeMaterialBlockTargets;
  113251. /**
  113252. * Shared data between multiple NodeMaterialBuildState instances
  113253. */
  113254. sharedData: NodeMaterialBuildStateSharedData;
  113255. /** @hidden */
  113256. _vertexState: NodeMaterialBuildState;
  113257. private _attributeDeclaration;
  113258. private _uniformDeclaration;
  113259. private _samplerDeclaration;
  113260. private _varyingTransfer;
  113261. private _repeatableContentAnchorIndex;
  113262. /** @hidden */
  113263. _builtCompilationString: string;
  113264. /**
  113265. * Gets the emitted compilation strings
  113266. */
  113267. compilationString: string;
  113268. /**
  113269. * Finalize the compilation strings
  113270. * @param state defines the current compilation state
  113271. */
  113272. finalize(state: NodeMaterialBuildState): void;
  113273. /** @hidden */
  113274. readonly _repeatableContentAnchor: string;
  113275. /** @hidden */
  113276. _getFreeVariableName(prefix: string): string;
  113277. /** @hidden */
  113278. _getFreeDefineName(prefix: string): string;
  113279. /** @hidden */
  113280. _excludeVariableName(name: string): void;
  113281. /** @hidden */
  113282. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113283. /** @hidden */
  113284. _emitFunction(name: string, code: string, comments: string): void;
  113285. /** @hidden */
  113286. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113287. replaceStrings?: {
  113288. search: RegExp;
  113289. replace: string;
  113290. }[];
  113291. }): string;
  113292. /** @hidden */
  113293. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113294. repeatKey?: string;
  113295. removeAttributes?: boolean;
  113296. removeUniforms?: boolean;
  113297. removeVaryings?: boolean;
  113298. removeIfDef?: boolean;
  113299. replaceStrings?: {
  113300. search: RegExp;
  113301. replace: string;
  113302. }[];
  113303. }): void;
  113304. /** @hidden */
  113305. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  113306. private _emitDefine;
  113307. /** @hidden */
  113308. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113309. }
  113310. }
  113311. declare module BABYLON {
  113312. /**
  113313. * Root class for all node material optimizers
  113314. */
  113315. export class NodeMaterialOptimizer {
  113316. /**
  113317. * Function used to optimize a NodeMaterial graph
  113318. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113319. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113320. */
  113321. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113322. }
  113323. }
  113324. declare module BABYLON {
  113325. /**
  113326. * Block used to transform a vector4 with a matrix
  113327. */
  113328. export class Vector4TransformBlock extends NodeMaterialBlock {
  113329. /**
  113330. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113331. */
  113332. complementW: number;
  113333. /**
  113334. * Creates a new Vector4TransformBlock
  113335. * @param name defines the block name
  113336. */
  113337. constructor(name: string);
  113338. /**
  113339. * Gets the current class name
  113340. * @returns the class name
  113341. */
  113342. getClassName(): string;
  113343. /**
  113344. * Gets the vector input
  113345. */
  113346. readonly vector: NodeMaterialConnectionPoint;
  113347. /**
  113348. * Gets the matrix transform input
  113349. */
  113350. readonly transform: NodeMaterialConnectionPoint;
  113351. protected _buildBlock(state: NodeMaterialBuildState): this;
  113352. }
  113353. }
  113354. declare module BABYLON {
  113355. /**
  113356. * Block used to output the vertex position
  113357. */
  113358. export class VertexOutputBlock extends NodeMaterialBlock {
  113359. /**
  113360. * Creates a new VertexOutputBlock
  113361. * @param name defines the block name
  113362. */
  113363. constructor(name: string);
  113364. /**
  113365. * Gets the current class name
  113366. * @returns the class name
  113367. */
  113368. getClassName(): string;
  113369. /**
  113370. * Gets the vector input component
  113371. */
  113372. readonly vector: NodeMaterialConnectionPoint;
  113373. protected _buildBlock(state: NodeMaterialBuildState): this;
  113374. }
  113375. }
  113376. declare module BABYLON {
  113377. /**
  113378. * Block used to output the final color
  113379. */
  113380. export class FragmentOutputBlock extends NodeMaterialBlock {
  113381. /**
  113382. * Gets or sets a boolean indicating if this block will output an alpha value
  113383. */
  113384. alphaBlendingEnabled: boolean;
  113385. /**
  113386. * Create a new FragmentOutputBlock
  113387. * @param name defines the block name
  113388. */
  113389. constructor(name: string);
  113390. /**
  113391. * Gets the current class name
  113392. * @returns the class name
  113393. */
  113394. getClassName(): string;
  113395. /**
  113396. * Gets the color input component
  113397. */
  113398. readonly color: NodeMaterialConnectionPoint;
  113399. protected _buildBlock(state: NodeMaterialBuildState): this;
  113400. }
  113401. }
  113402. declare module BABYLON {
  113403. /**
  113404. * Interface used to configure the node material editor
  113405. */
  113406. export interface INodeMaterialEditorOptions {
  113407. /** Define the URl to load node editor script */
  113408. editorURL?: string;
  113409. }
  113410. /** @hidden */
  113411. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113412. /** BONES */
  113413. NUM_BONE_INFLUENCERS: number;
  113414. BonesPerMesh: number;
  113415. BONETEXTURE: boolean;
  113416. /** MORPH TARGETS */
  113417. MORPHTARGETS: boolean;
  113418. MORPHTARGETS_NORMAL: boolean;
  113419. MORPHTARGETS_TANGENT: boolean;
  113420. NUM_MORPH_INFLUENCERS: number;
  113421. /** IMAGE PROCESSING */
  113422. IMAGEPROCESSING: boolean;
  113423. VIGNETTE: boolean;
  113424. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113425. VIGNETTEBLENDMODEOPAQUE: boolean;
  113426. TONEMAPPING: boolean;
  113427. TONEMAPPING_ACES: boolean;
  113428. CONTRAST: boolean;
  113429. EXPOSURE: boolean;
  113430. COLORCURVES: boolean;
  113431. COLORGRADING: boolean;
  113432. COLORGRADING3D: boolean;
  113433. SAMPLER3DGREENDEPTH: boolean;
  113434. SAMPLER3DBGRMAP: boolean;
  113435. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113436. constructor();
  113437. setValue(name: string, value: boolean): void;
  113438. }
  113439. /**
  113440. * Class used to configure NodeMaterial
  113441. */
  113442. export interface INodeMaterialOptions {
  113443. /**
  113444. * Defines if blocks should emit comments
  113445. */
  113446. emitComments: boolean;
  113447. }
  113448. /**
  113449. * Class used to create a node based material built by assembling shader blocks
  113450. */
  113451. export class NodeMaterial extends PushMaterial {
  113452. private _options;
  113453. private _vertexCompilationState;
  113454. private _fragmentCompilationState;
  113455. private _sharedData;
  113456. private _buildId;
  113457. private _buildWasSuccessful;
  113458. private _cachedWorldViewMatrix;
  113459. private _cachedWorldViewProjectionMatrix;
  113460. private _textureConnectionPoints;
  113461. private _optimizers;
  113462. /** Define the URl to load node editor script */
  113463. static EditorURL: string;
  113464. private BJSNODEMATERIALEDITOR;
  113465. /** Get the inspector from bundle or global */
  113466. private _getGlobalNodeMaterialEditor;
  113467. /**
  113468. * Defines the maximum number of lights that can be used in the material
  113469. */
  113470. maxSimultaneousLights: number;
  113471. /**
  113472. * Observable raised when the material is built
  113473. */
  113474. onBuildObservable: Observable<NodeMaterial>;
  113475. /**
  113476. * Gets or sets the root nodes of the material vertex shader
  113477. */
  113478. _vertexOutputNodes: NodeMaterialBlock[];
  113479. /**
  113480. * Gets or sets the root nodes of the material fragment (pixel) shader
  113481. */
  113482. _fragmentOutputNodes: NodeMaterialBlock[];
  113483. /** Gets or sets options to control the node material overall behavior */
  113484. options: INodeMaterialOptions;
  113485. /**
  113486. * Default configuration related to image processing available in the standard Material.
  113487. */
  113488. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113489. /**
  113490. * Gets the image processing configuration used either in this material.
  113491. */
  113492. /**
  113493. * Sets the Default image processing configuration used either in the this material.
  113494. *
  113495. * If sets to null, the scene one is in use.
  113496. */
  113497. imageProcessingConfiguration: ImageProcessingConfiguration;
  113498. /**
  113499. * Create a new node based material
  113500. * @param name defines the material name
  113501. * @param scene defines the hosting scene
  113502. * @param options defines creation option
  113503. */
  113504. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113505. /**
  113506. * Gets the current class name of the material e.g. "NodeMaterial"
  113507. * @returns the class name
  113508. */
  113509. getClassName(): string;
  113510. /**
  113511. * Keep track of the image processing observer to allow dispose and replace.
  113512. */
  113513. private _imageProcessingObserver;
  113514. /**
  113515. * Attaches a new image processing configuration to the Standard Material.
  113516. * @param configuration
  113517. */
  113518. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113519. /**
  113520. * Adds a new optimizer to the list of optimizers
  113521. * @param optimizer defines the optimizers to add
  113522. * @returns the current material
  113523. */
  113524. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113525. /**
  113526. * Remove an optimizer from the list of optimizers
  113527. * @param optimizer defines the optimizers to remove
  113528. * @returns the current material
  113529. */
  113530. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113531. /**
  113532. * Add a new block to the list of output nodes
  113533. * @param node defines the node to add
  113534. * @returns the current material
  113535. */
  113536. addOutputNode(node: NodeMaterialBlock): this;
  113537. /**
  113538. * Remove a block from the list of root nodes
  113539. * @param node defines the node to remove
  113540. * @returns the current material
  113541. */
  113542. removeOutputNode(node: NodeMaterialBlock): this;
  113543. private _addVertexOutputNode;
  113544. private _removeVertexOutputNode;
  113545. private _addFragmentOutputNode;
  113546. private _removeFragmentOutputNode;
  113547. /**
  113548. * Specifies if the material will require alpha blending
  113549. * @returns a boolean specifying if alpha blending is needed
  113550. */
  113551. needAlphaBlending(): boolean;
  113552. /**
  113553. * Specifies if this material should be rendered in alpha test mode
  113554. * @returns a boolean specifying if an alpha test is needed.
  113555. */
  113556. needAlphaTesting(): boolean;
  113557. private _initializeBlock;
  113558. private _resetDualBlocks;
  113559. /**
  113560. * Build the material and generates the inner effect
  113561. * @param verbose defines if the build should log activity
  113562. */
  113563. build(verbose?: boolean): void;
  113564. /**
  113565. * Runs an otpimization phase to try to improve the shader code
  113566. */
  113567. optimize(): void;
  113568. private _prepareDefinesForAttributes;
  113569. /**
  113570. * Get if the submesh is ready to be used and all its information available.
  113571. * Child classes can use it to update shaders
  113572. * @param mesh defines the mesh to check
  113573. * @param subMesh defines which submesh to check
  113574. * @param useInstances specifies that instances should be used
  113575. * @returns a boolean indicating that the submesh is ready or not
  113576. */
  113577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113578. /**
  113579. * Binds the world matrix to the material
  113580. * @param world defines the world transformation matrix
  113581. */
  113582. bindOnlyWorldMatrix(world: Matrix): void;
  113583. /**
  113584. * Binds the submesh to this material by preparing the effect and shader to draw
  113585. * @param world defines the world transformation matrix
  113586. * @param mesh defines the mesh containing the submesh
  113587. * @param subMesh defines the submesh to bind the material to
  113588. */
  113589. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113590. /**
  113591. * Gets the active textures from the material
  113592. * @returns an array of textures
  113593. */
  113594. getActiveTextures(): BaseTexture[];
  113595. /**
  113596. * Specifies if the material uses a texture
  113597. * @param texture defines the texture to check against the material
  113598. * @returns a boolean specifying if the material uses the texture
  113599. */
  113600. hasTexture(texture: BaseTexture): boolean;
  113601. /**
  113602. * Disposes the material
  113603. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113604. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113605. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113606. */
  113607. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113608. /** Creates the node editor window. */
  113609. private _createNodeEditor;
  113610. /**
  113611. * Launch the node material editor
  113612. * @param config Define the configuration of the editor
  113613. * @return a promise fulfilled when the node editor is visible
  113614. */
  113615. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113616. /**
  113617. * Clear the current material
  113618. */
  113619. clear(): void;
  113620. /**
  113621. * Clear the current material and set it to a default state
  113622. */
  113623. setToDefault(): void;
  113624. }
  113625. }
  113626. declare module BABYLON {
  113627. /**
  113628. * Defines a block that can be used inside a node based material
  113629. */
  113630. export class NodeMaterialBlock {
  113631. private _buildId;
  113632. private _target;
  113633. private _isFinalMerger;
  113634. /** @hidden */
  113635. _inputs: NodeMaterialConnectionPoint[];
  113636. /** @hidden */
  113637. _outputs: NodeMaterialConnectionPoint[];
  113638. /**
  113639. * Gets or sets the name of the block
  113640. */
  113641. name: string;
  113642. /**
  113643. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113644. */
  113645. readonly isFinalMerger: boolean;
  113646. /**
  113647. * Gets or sets the build Id
  113648. */
  113649. buildId: number;
  113650. /**
  113651. * Gets or sets the target of the block
  113652. */
  113653. target: NodeMaterialBlockTargets;
  113654. /**
  113655. * Gets the list of input points
  113656. */
  113657. readonly inputs: NodeMaterialConnectionPoint[];
  113658. /** Gets the list of output points */
  113659. readonly outputs: NodeMaterialConnectionPoint[];
  113660. /**
  113661. * Find an input by its name
  113662. * @param name defines the name of the input to look for
  113663. * @returns the input or null if not found
  113664. */
  113665. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113666. /**
  113667. * Find an output by its name
  113668. * @param name defines the name of the outputto look for
  113669. * @returns the output or null if not found
  113670. */
  113671. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113672. /**
  113673. * Creates a new NodeMaterialBlock
  113674. * @param name defines the block name
  113675. * @param target defines the target of that block (Vertex by default)
  113676. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  113677. */
  113678. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  113679. /**
  113680. * Initialize the block and prepare the context for build
  113681. * @param state defines the state that will be used for the build
  113682. */
  113683. initialize(state: NodeMaterialBuildState): void;
  113684. /**
  113685. * Bind data to effect. Will only be called for blocks with isBindable === true
  113686. * @param effect defines the effect to bind data to
  113687. * @param nodeMaterial defines the hosting NodeMaterial
  113688. * @param mesh defines the mesh that will be rendered
  113689. */
  113690. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113691. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  113692. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  113693. protected _writeFloat(value: number): string;
  113694. /**
  113695. * Gets the current class name e.g. "NodeMaterialBlock"
  113696. * @returns the class name
  113697. */
  113698. getClassName(): string;
  113699. /**
  113700. * Register a new input. Must be called inside a block constructor
  113701. * @param name defines the connection point name
  113702. * @param type defines the connection point type
  113703. * @param isOptional defines a boolean indicating that this input can be omitted
  113704. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113705. * @returns the current block
  113706. */
  113707. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  113708. /**
  113709. * Register a new output. Must be called inside a block constructor
  113710. * @param name defines the connection point name
  113711. * @param type defines the connection point type
  113712. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113713. * @returns the current block
  113714. */
  113715. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  113716. /**
  113717. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  113718. * @param forOutput defines an optional connection point to check compatibility with
  113719. * @returns the first available input or null
  113720. */
  113721. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  113722. /**
  113723. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  113724. * @param forBlock defines an optional block to check compatibility with
  113725. * @returns the first available input or null
  113726. */
  113727. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  113728. /**
  113729. * Connect current block with another block
  113730. * @param other defines the block to connect with
  113731. * @param options define the various options to help pick the right connections
  113732. * @returns the current block
  113733. */
  113734. connectTo(other: NodeMaterialBlock, options?: {
  113735. input?: string;
  113736. output?: string;
  113737. outputSwizzle?: string;
  113738. }): this | undefined;
  113739. protected _buildBlock(state: NodeMaterialBuildState): void;
  113740. /**
  113741. * Add potential fallbacks if shader compilation fails
  113742. * @param mesh defines the mesh to be rendered
  113743. * @param fallbacks defines the current prioritized list of fallbacks
  113744. */
  113745. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113746. /**
  113747. * Update defines for shader compilation
  113748. * @param mesh defines the mesh to be rendered
  113749. * @param nodeMaterial defines the node material requesting the update
  113750. * @param defines defines the material defines to update
  113751. * @param useInstances specifies that instances should be used
  113752. */
  113753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113754. /**
  113755. * Lets the block try to connect some inputs automatically
  113756. */
  113757. autoConfigure(): void;
  113758. /**
  113759. * Function called when a block is declared as repeatable content generator
  113760. * @param vertexShaderState defines the current compilation state for the vertex shader
  113761. * @param fragmentShaderState defines the current compilation state for the fragment shader
  113762. * @param mesh defines the mesh to be rendered
  113763. * @param defines defines the material defines to update
  113764. */
  113765. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113766. /**
  113767. * Checks if the block is ready
  113768. * @param mesh defines the mesh to be rendered
  113769. * @param nodeMaterial defines the node material requesting the update
  113770. * @param defines defines the material defines to update
  113771. * @param useInstances specifies that instances should be used
  113772. * @returns true if the block is ready
  113773. */
  113774. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  113775. /**
  113776. * Compile the current node and generate the shader code
  113777. * @param state defines the current compilation state (uniforms, samplers, current string)
  113778. * @returns the current block
  113779. */
  113780. build(state: NodeMaterialBuildState): this | undefined;
  113781. }
  113782. }
  113783. declare module BABYLON {
  113784. /**
  113785. * Defines a connection point for a block
  113786. */
  113787. export class NodeMaterialConnectionPoint {
  113788. /** @hidden */
  113789. _ownerBlock: NodeMaterialBlock;
  113790. /** @hidden */
  113791. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113792. private _associatedVariableName;
  113793. private _endpoints;
  113794. private _storedValue;
  113795. private _valueCallback;
  113796. private _mode;
  113797. /** @hidden */
  113798. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113799. /** @hidden */
  113800. _needToEmitVarying: boolean;
  113801. /**
  113802. * Gets or sets the connection point type (default is float)
  113803. */
  113804. type: NodeMaterialBlockConnectionPointTypes;
  113805. /**
  113806. * Gets or sets the connection point name
  113807. */
  113808. name: string;
  113809. /**
  113810. * Gets or sets the swizzle to apply to this connection point when reading or writing
  113811. */
  113812. swizzle: string;
  113813. /**
  113814. * Gets or sets a boolean indicating that this connection point can be omitted
  113815. */
  113816. isOptional: boolean;
  113817. /**
  113818. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  113819. */
  113820. define: string;
  113821. /** Gets or sets the target of that connection point */
  113822. target: NodeMaterialBlockTargets;
  113823. /**
  113824. * Gets or sets the value of that point.
  113825. * Please note that this value will be ignored if valueCallback is defined
  113826. */
  113827. value: any;
  113828. /**
  113829. * Gets or sets a callback used to get the value of that point.
  113830. * Please note that setting this value will force the connection point to ignore the value property
  113831. */
  113832. valueCallback: () => any;
  113833. /**
  113834. * Gets or sets the associated variable name in the shader
  113835. */
  113836. associatedVariableName: string;
  113837. /**
  113838. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  113839. * In this case the connection point name must be the name of the uniform to use.
  113840. * Can only be set on inputs
  113841. */
  113842. isUniform: boolean;
  113843. /**
  113844. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  113845. * In this case the connection point name must be the name of the attribute to use
  113846. * Can only be set on inputs
  113847. */
  113848. isAttribute: boolean;
  113849. /**
  113850. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  113851. * Can only be set on exit points
  113852. */
  113853. isVarying: boolean;
  113854. /** Get the other side of the connection (if any) */
  113855. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113856. /** Get the block that owns this connection point */
  113857. readonly ownerBlock: NodeMaterialBlock;
  113858. /** Get the block connected on the other side of this connection (if any) */
  113859. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  113860. /** Get the block connected on the endpoints of this connection (if any) */
  113861. readonly connectedBlocks: Array<NodeMaterialBlock>;
  113862. /**
  113863. * Creates a new connection point
  113864. * @param name defines the connection point name
  113865. * @param ownerBlock defines the block hosting this connection point
  113866. */
  113867. constructor(name: string, ownerBlock: NodeMaterialBlock);
  113868. /**
  113869. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  113870. * @returns the class name
  113871. */
  113872. getClassName(): string;
  113873. /**
  113874. * Set the source of this connection point to a vertex attribute
  113875. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  113876. * @returns the current connection point
  113877. */
  113878. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  113879. /**
  113880. * Set the source of this connection point to a well known value
  113881. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  113882. * @returns the current connection point
  113883. */
  113884. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  113885. /**
  113886. * Gets a boolean indicating that the current connection point is a well known value
  113887. */
  113888. readonly isWellKnownValue: boolean;
  113889. /**
  113890. * Gets or sets the current well known value or null if not defined as well know value
  113891. */
  113892. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113893. private _getTypeLength;
  113894. /**
  113895. * Connect this point to another connection point
  113896. * @param connectionPoint defines the other connection point
  113897. * @returns the current connection point
  113898. */
  113899. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113900. /**
  113901. * Disconnect this point from one of his endpoint
  113902. * @param endpoint defines the other connection point
  113903. * @returns the current connection point
  113904. */
  113905. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113906. /**
  113907. * When connection point is an uniform, this function will send its value to the effect
  113908. * @param effect defines the effect to transmit value to
  113909. * @param world defines the world matrix
  113910. * @param worldView defines the worldxview matrix
  113911. * @param worldViewProjection defines the worldxviewxprojection matrix
  113912. */
  113913. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  113914. /**
  113915. * When connection point is an uniform, this function will send its value to the effect
  113916. * @param effect defines the effect to transmit value to
  113917. * @param scene defines the hosting scene
  113918. */
  113919. transmit(effect: Effect, scene: Scene): void;
  113920. }
  113921. }
  113922. declare module BABYLON {
  113923. /**
  113924. * Block used to add support for vertex skinning (bones)
  113925. */
  113926. export class BonesBlock extends NodeMaterialBlock {
  113927. /**
  113928. * Creates a new BonesBlock
  113929. * @param name defines the block name
  113930. */
  113931. constructor(name: string);
  113932. /**
  113933. * Initialize the block and prepare the context for build
  113934. * @param state defines the state that will be used for the build
  113935. */
  113936. initialize(state: NodeMaterialBuildState): void;
  113937. /**
  113938. * Gets the current class name
  113939. * @returns the class name
  113940. */
  113941. getClassName(): string;
  113942. /**
  113943. * Gets the matrix indices input component
  113944. */
  113945. readonly matricesIndices: NodeMaterialConnectionPoint;
  113946. /**
  113947. * Gets the matrix weights input component
  113948. */
  113949. readonly matricesWeights: NodeMaterialConnectionPoint;
  113950. /**
  113951. * Gets the extra matrix indices input component
  113952. */
  113953. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  113954. /**
  113955. * Gets the extra matrix weights input component
  113956. */
  113957. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  113958. /**
  113959. * Gets the world input component
  113960. */
  113961. readonly world: NodeMaterialConnectionPoint;
  113962. autoConfigure(): void;
  113963. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113964. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113966. protected _buildBlock(state: NodeMaterialBuildState): this;
  113967. }
  113968. }
  113969. declare module BABYLON {
  113970. /**
  113971. * Block used to add support for instances
  113972. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113973. */
  113974. export class InstancesBlock extends NodeMaterialBlock {
  113975. /**
  113976. * Creates a new InstancesBlock
  113977. * @param name defines the block name
  113978. */
  113979. constructor(name: string);
  113980. /**
  113981. * Gets the current class name
  113982. * @returns the class name
  113983. */
  113984. getClassName(): string;
  113985. /**
  113986. * Gets the first world row input component
  113987. */
  113988. readonly world0: NodeMaterialConnectionPoint;
  113989. /**
  113990. * Gets the second world row input component
  113991. */
  113992. readonly world1: NodeMaterialConnectionPoint;
  113993. /**
  113994. * Gets the third world row input component
  113995. */
  113996. readonly world2: NodeMaterialConnectionPoint;
  113997. /**
  113998. * Gets the forth world row input component
  113999. */
  114000. readonly world3: NodeMaterialConnectionPoint;
  114001. /**
  114002. * Gets the world input component
  114003. */
  114004. readonly world: NodeMaterialConnectionPoint;
  114005. /**
  114006. * Gets the output component
  114007. */
  114008. readonly output: NodeMaterialConnectionPoint;
  114009. autoConfigure(): void;
  114010. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114011. protected _buildBlock(state: NodeMaterialBuildState): this;
  114012. }
  114013. }
  114014. declare module BABYLON {
  114015. /**
  114016. * Block used to add morph targets support to vertex shader
  114017. */
  114018. export class MorphTargetsBlock extends NodeMaterialBlock {
  114019. private _repeatableContentAnchor;
  114020. private _repeatebleContentGenerated;
  114021. /**
  114022. * Create a new MorphTargetsBlock
  114023. * @param name defines the block name
  114024. */
  114025. constructor(name: string);
  114026. /**
  114027. * Gets the current class name
  114028. * @returns the class name
  114029. */
  114030. getClassName(): string;
  114031. /**
  114032. * Gets the position input component
  114033. */
  114034. readonly position: NodeMaterialConnectionPoint;
  114035. /**
  114036. * Gets the normal input component
  114037. */
  114038. readonly normal: NodeMaterialConnectionPoint;
  114039. /**
  114040. * Gets the tangent input component
  114041. */
  114042. readonly tangent: NodeMaterialConnectionPoint;
  114043. /**
  114044. * Gets the position output component
  114045. */
  114046. readonly positionOutput: NodeMaterialConnectionPoint;
  114047. /**
  114048. * Gets the normal output component
  114049. */
  114050. readonly normalOutput: NodeMaterialConnectionPoint;
  114051. /**
  114052. * Gets the tangent output component
  114053. */
  114054. readonly tangentOutput: NodeMaterialConnectionPoint;
  114055. initialize(state: NodeMaterialBuildState): void;
  114056. autoConfigure(): void;
  114057. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114059. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114060. protected _buildBlock(state: NodeMaterialBuildState): this;
  114061. }
  114062. }
  114063. declare module BABYLON {
  114064. /**
  114065. * Block used to add an alpha test in the fragment shader
  114066. */
  114067. export class AlphaTestBlock extends NodeMaterialBlock {
  114068. /**
  114069. * Gets or sets the alpha value where alpha testing happens
  114070. */
  114071. alphaCutOff: number;
  114072. /**
  114073. * Create a new AlphaTestBlock
  114074. * @param name defines the block name
  114075. */
  114076. constructor(name: string);
  114077. /**
  114078. * Gets the current class name
  114079. * @returns the class name
  114080. */
  114081. getClassName(): string;
  114082. /**
  114083. * Gets the color input component
  114084. */
  114085. readonly color: NodeMaterialConnectionPoint;
  114086. protected _buildBlock(state: NodeMaterialBuildState): this;
  114087. }
  114088. }
  114089. declare module BABYLON {
  114090. /**
  114091. * Block used to create a Color4 out of 4 inputs (one for each component)
  114092. */
  114093. export class RGBAMergerBlock extends NodeMaterialBlock {
  114094. /**
  114095. * Create a new RGBAMergerBlock
  114096. * @param name defines the block name
  114097. */
  114098. constructor(name: string);
  114099. /**
  114100. * Gets the current class name
  114101. * @returns the class name
  114102. */
  114103. getClassName(): string;
  114104. /**
  114105. * Gets the R input component
  114106. */
  114107. readonly r: NodeMaterialConnectionPoint;
  114108. /**
  114109. * Gets the G input component
  114110. */
  114111. readonly g: NodeMaterialConnectionPoint;
  114112. /**
  114113. * Gets the B input component
  114114. */
  114115. readonly b: NodeMaterialConnectionPoint;
  114116. /**
  114117. * Gets the RGB input component
  114118. */
  114119. readonly rgb: NodeMaterialConnectionPoint;
  114120. /**
  114121. * Gets the R input component
  114122. */
  114123. readonly a: NodeMaterialConnectionPoint;
  114124. protected _buildBlock(state: NodeMaterialBuildState): this;
  114125. }
  114126. }
  114127. declare module BABYLON {
  114128. /**
  114129. * Block used to create a Color3 out of 3 inputs (one for each component)
  114130. */
  114131. export class RGBMergerBlock extends NodeMaterialBlock {
  114132. /**
  114133. * Create a new RGBMergerBlock
  114134. * @param name defines the block name
  114135. */
  114136. constructor(name: string);
  114137. /**
  114138. * Gets the current class name
  114139. * @returns the class name
  114140. */
  114141. getClassName(): string;
  114142. /**
  114143. * Gets the R component input
  114144. */
  114145. readonly r: NodeMaterialConnectionPoint;
  114146. /**
  114147. * Gets the G component input
  114148. */
  114149. readonly g: NodeMaterialConnectionPoint;
  114150. /**
  114151. * Gets the B component input
  114152. */
  114153. readonly b: NodeMaterialConnectionPoint;
  114154. protected _buildBlock(state: NodeMaterialBuildState): this;
  114155. }
  114156. }
  114157. declare module BABYLON {
  114158. /**
  114159. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114160. */
  114161. export class RGBASplitterBlock extends NodeMaterialBlock {
  114162. /**
  114163. * Create a new RGBASplitterBlock
  114164. * @param name defines the block name
  114165. */
  114166. constructor(name: string);
  114167. /**
  114168. * Gets the current class name
  114169. * @returns the class name
  114170. */
  114171. getClassName(): string;
  114172. /**
  114173. * Gets the input component
  114174. */
  114175. readonly input: NodeMaterialConnectionPoint;
  114176. protected _buildBlock(state: NodeMaterialBuildState): this;
  114177. }
  114178. }
  114179. declare module BABYLON {
  114180. /**
  114181. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114182. */
  114183. export class RGBSplitterBlock extends NodeMaterialBlock {
  114184. /**
  114185. * Create a new RGBSplitterBlock
  114186. * @param name defines the block name
  114187. */
  114188. constructor(name: string);
  114189. /**
  114190. * Gets the current class name
  114191. * @returns the class name
  114192. */
  114193. getClassName(): string;
  114194. /**
  114195. * Gets the input component
  114196. */
  114197. readonly input: NodeMaterialConnectionPoint;
  114198. protected _buildBlock(state: NodeMaterialBuildState): this;
  114199. }
  114200. }
  114201. declare module BABYLON {
  114202. /**
  114203. * Block used to read a texture from a sampler
  114204. */
  114205. export class TextureBlock extends NodeMaterialBlock {
  114206. private _defineName;
  114207. /**
  114208. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114209. */
  114210. autoConnectTextureMatrix: boolean;
  114211. /**
  114212. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114213. */
  114214. autoSelectUV: boolean;
  114215. /**
  114216. * Create a new TextureBlock
  114217. * @param name defines the block name
  114218. */
  114219. constructor(name: string);
  114220. /**
  114221. * Gets the current class name
  114222. * @returns the class name
  114223. */
  114224. getClassName(): string;
  114225. /**
  114226. * Gets the uv input component
  114227. */
  114228. readonly uv: NodeMaterialConnectionPoint;
  114229. /**
  114230. * Gets the texture information input component
  114231. */
  114232. readonly textureInfo: NodeMaterialConnectionPoint;
  114233. /**
  114234. * Gets the transformed uv input component
  114235. */
  114236. readonly transformedUV: NodeMaterialConnectionPoint;
  114237. /**
  114238. * Gets the texture input component
  114239. */
  114240. readonly texture: NodeMaterialConnectionPoint;
  114241. /**
  114242. * Gets the texture transform input component
  114243. */
  114244. readonly textureTransform: NodeMaterialConnectionPoint;
  114245. autoConfigure(): void;
  114246. initialize(state: NodeMaterialBuildState): void;
  114247. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114248. isReady(): boolean;
  114249. private _injectVertexCode;
  114250. protected _buildBlock(state: NodeMaterialBuildState): this;
  114251. }
  114252. }
  114253. declare module BABYLON {
  114254. /**
  114255. * Block used to add image processing support to fragment shader
  114256. */
  114257. export class ImageProcessingBlock extends NodeMaterialBlock {
  114258. /**
  114259. * Create a new ImageProcessingBlock
  114260. * @param name defines the block name
  114261. */
  114262. constructor(name: string);
  114263. /**
  114264. * Gets the current class name
  114265. * @returns the class name
  114266. */
  114267. getClassName(): string;
  114268. /**
  114269. * Gets the color input component
  114270. */
  114271. readonly color: NodeMaterialConnectionPoint;
  114272. /**
  114273. * Initialize the block and prepare the context for build
  114274. * @param state defines the state that will be used for the build
  114275. */
  114276. initialize(state: NodeMaterialBuildState): void;
  114277. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114279. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114280. protected _buildBlock(state: NodeMaterialBuildState): this;
  114281. }
  114282. }
  114283. declare module BABYLON {
  114284. /**
  114285. * Block used to add support for scene fog
  114286. */
  114287. export class FogBlock extends NodeMaterialBlock {
  114288. /**
  114289. * Create a new FogBlock
  114290. * @param name defines the block name
  114291. */
  114292. constructor(name: string);
  114293. /**
  114294. * Gets the current class name
  114295. * @returns the class name
  114296. */
  114297. getClassName(): string;
  114298. /**
  114299. * Gets the world position input component
  114300. */
  114301. readonly worldPosition: NodeMaterialConnectionPoint;
  114302. /**
  114303. * Gets the view input component
  114304. */
  114305. readonly view: NodeMaterialConnectionPoint;
  114306. /**
  114307. * Gets the color input component
  114308. */
  114309. readonly color: NodeMaterialConnectionPoint;
  114310. /**
  114311. * Gets the fog color input component
  114312. */
  114313. readonly fogColor: NodeMaterialConnectionPoint;
  114314. /**
  114315. * Gets the for parameter input component
  114316. */
  114317. readonly fogParameters: NodeMaterialConnectionPoint;
  114318. autoConfigure(): void;
  114319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114320. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114321. protected _buildBlock(state: NodeMaterialBuildState): this;
  114322. }
  114323. }
  114324. declare module BABYLON {
  114325. /**
  114326. * Block used to multiply 2 vector4
  114327. */
  114328. export class MultiplyBlock extends NodeMaterialBlock {
  114329. /**
  114330. * Creates a new MultiplyBlock
  114331. * @param name defines the block name
  114332. */
  114333. constructor(name: string);
  114334. /**
  114335. * Gets the current class name
  114336. * @returns the class name
  114337. */
  114338. getClassName(): string;
  114339. /**
  114340. * Gets the left operand input component
  114341. */
  114342. readonly left: NodeMaterialConnectionPoint;
  114343. /**
  114344. * Gets the right operand input component
  114345. */
  114346. readonly right: NodeMaterialConnectionPoint;
  114347. protected _buildBlock(state: NodeMaterialBuildState): this;
  114348. }
  114349. }
  114350. declare module BABYLON {
  114351. /**
  114352. * Block used to add 2 vector4
  114353. */
  114354. export class AddBlock extends NodeMaterialBlock {
  114355. /**
  114356. * Creates a new AddBlock
  114357. * @param name defines the block name
  114358. */
  114359. constructor(name: string);
  114360. /**
  114361. * Gets the current class name
  114362. * @returns the class name
  114363. */
  114364. getClassName(): string;
  114365. /**
  114366. * Gets the left operand input component
  114367. */
  114368. readonly left: NodeMaterialConnectionPoint;
  114369. /**
  114370. * Gets the right operand input component
  114371. */
  114372. readonly right: NodeMaterialConnectionPoint;
  114373. protected _buildBlock(state: NodeMaterialBuildState): this;
  114374. }
  114375. }
  114376. declare module BABYLON {
  114377. /**
  114378. * Block used to clamp a float
  114379. */
  114380. export class ClampBlock extends NodeMaterialBlock {
  114381. /** Gets or sets the minimum range */
  114382. minimum: number;
  114383. /** Gets or sets the maximum range */
  114384. maximum: number;
  114385. /**
  114386. * Creates a new ClampBlock
  114387. * @param name defines the block name
  114388. */
  114389. constructor(name: string);
  114390. /**
  114391. * Gets the current class name
  114392. * @returns the class name
  114393. */
  114394. getClassName(): string;
  114395. /**
  114396. * Gets the value input component
  114397. */
  114398. readonly value: NodeMaterialConnectionPoint;
  114399. protected _buildBlock(state: NodeMaterialBuildState): this;
  114400. }
  114401. }
  114402. declare module BABYLON {
  114403. /**
  114404. * Block used to transform a vector2 with a matrix
  114405. */
  114406. export class Vector2TransformBlock extends NodeMaterialBlock {
  114407. /**
  114408. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114409. */
  114410. complementZ: number;
  114411. /**
  114412. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114413. */
  114414. complementW: number;
  114415. /**
  114416. * Creates a new Vector2TransformBlock
  114417. * @param name defines the block name
  114418. */
  114419. constructor(name: string);
  114420. /**
  114421. * Gets the vector input
  114422. */
  114423. readonly vector: NodeMaterialConnectionPoint;
  114424. /**
  114425. * Gets the matrix transform input
  114426. */
  114427. readonly transform: NodeMaterialConnectionPoint;
  114428. /**
  114429. * Gets the current class name
  114430. * @returns the class name
  114431. */
  114432. getClassName(): string;
  114433. protected _buildBlock(state: NodeMaterialBuildState): this;
  114434. }
  114435. }
  114436. declare module BABYLON {
  114437. /**
  114438. * Block used to transform a vector3 with a matrix
  114439. */
  114440. export class Vector3TransformBlock extends NodeMaterialBlock {
  114441. /**
  114442. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114443. */
  114444. complement: number;
  114445. /**
  114446. * Creates a new Vector3TransformBlock
  114447. * @param name defines the block name
  114448. */
  114449. constructor(name: string);
  114450. /**
  114451. * Gets the vector input
  114452. */
  114453. readonly vector: NodeMaterialConnectionPoint;
  114454. /**
  114455. * Gets the matrix transform input
  114456. */
  114457. readonly transform: NodeMaterialConnectionPoint;
  114458. /**
  114459. * Gets the current class name
  114460. * @returns the class name
  114461. */
  114462. getClassName(): string;
  114463. protected _buildBlock(state: NodeMaterialBuildState): this;
  114464. }
  114465. }
  114466. declare module BABYLON {
  114467. /**
  114468. * Block used to multiply two matrices
  114469. */
  114470. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  114471. /**
  114472. * Creates a new MatrixMultiplicationBlock
  114473. * @param name defines the block name
  114474. */
  114475. constructor(name: string);
  114476. /**
  114477. * Gets the left operand
  114478. */
  114479. readonly left: NodeMaterialConnectionPoint;
  114480. /**
  114481. * Gets the right operand
  114482. */
  114483. readonly right: NodeMaterialConnectionPoint;
  114484. /**
  114485. * Gets the current class name
  114486. * @returns the class name
  114487. */
  114488. getClassName(): string;
  114489. protected _buildBlock(state: NodeMaterialBuildState): this;
  114490. }
  114491. }
  114492. declare module BABYLON {
  114493. /**
  114494. * Helper class to push actions to a pool of workers.
  114495. */
  114496. export class WorkerPool implements IDisposable {
  114497. private _workerInfos;
  114498. private _pendingActions;
  114499. /**
  114500. * Constructor
  114501. * @param workers Array of workers to use for actions
  114502. */
  114503. constructor(workers: Array<Worker>);
  114504. /**
  114505. * Terminates all workers and clears any pending actions.
  114506. */
  114507. dispose(): void;
  114508. /**
  114509. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114510. * pended until a worker has completed its action.
  114511. * @param action The action to perform. Call onComplete when the action is complete.
  114512. */
  114513. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114514. private _execute;
  114515. }
  114516. }
  114517. declare module BABYLON {
  114518. /**
  114519. * Configuration for Draco compression
  114520. */
  114521. export interface IDracoCompressionConfiguration {
  114522. /**
  114523. * Configuration for the decoder.
  114524. */
  114525. decoder: {
  114526. /**
  114527. * The url to the WebAssembly module.
  114528. */
  114529. wasmUrl?: string;
  114530. /**
  114531. * The url to the WebAssembly binary.
  114532. */
  114533. wasmBinaryUrl?: string;
  114534. /**
  114535. * The url to the fallback JavaScript module.
  114536. */
  114537. fallbackUrl?: string;
  114538. };
  114539. }
  114540. /**
  114541. * Draco compression (https://google.github.io/draco/)
  114542. *
  114543. * This class wraps the Draco module.
  114544. *
  114545. * **Encoder**
  114546. *
  114547. * The encoder is not currently implemented.
  114548. *
  114549. * **Decoder**
  114550. *
  114551. * 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.
  114552. *
  114553. * To update the configuration, use the following code:
  114554. * ```javascript
  114555. * DracoCompression.Configuration = {
  114556. * decoder: {
  114557. * wasmUrl: "<url to the WebAssembly library>",
  114558. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  114559. * fallbackUrl: "<url to the fallback JavaScript library>",
  114560. * }
  114561. * };
  114562. * ```
  114563. *
  114564. * 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.
  114565. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  114566. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  114567. *
  114568. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  114569. * ```javascript
  114570. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  114571. * ```
  114572. *
  114573. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  114574. */
  114575. export class DracoCompression implements IDisposable {
  114576. private _workerPoolPromise?;
  114577. private _decoderModulePromise?;
  114578. /**
  114579. * The configuration. Defaults to the following urls:
  114580. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  114581. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  114582. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  114583. */
  114584. static Configuration: IDracoCompressionConfiguration;
  114585. /**
  114586. * Returns true if the decoder configuration is available.
  114587. */
  114588. static readonly DecoderAvailable: boolean;
  114589. /**
  114590. * Default number of workers to create when creating the draco compression object.
  114591. */
  114592. static DefaultNumWorkers: number;
  114593. private static GetDefaultNumWorkers;
  114594. private static _Default;
  114595. /**
  114596. * Default instance for the draco compression object.
  114597. */
  114598. static readonly Default: DracoCompression;
  114599. /**
  114600. * Constructor
  114601. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  114602. */
  114603. constructor(numWorkers?: number);
  114604. /**
  114605. * Stop all async operations and release resources.
  114606. */
  114607. dispose(): void;
  114608. /**
  114609. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  114610. * @returns a promise that resolves when ready
  114611. */
  114612. whenReadyAsync(): Promise<void>;
  114613. /**
  114614. * Decode Draco compressed mesh data to vertex data.
  114615. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  114616. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  114617. * @returns A promise that resolves with the decoded vertex data
  114618. */
  114619. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  114620. [kind: string]: number;
  114621. }): Promise<VertexData>;
  114622. }
  114623. }
  114624. declare module BABYLON {
  114625. /**
  114626. * Class for building Constructive Solid Geometry
  114627. */
  114628. export class CSG {
  114629. private polygons;
  114630. /**
  114631. * The world matrix
  114632. */
  114633. matrix: Matrix;
  114634. /**
  114635. * Stores the position
  114636. */
  114637. position: Vector3;
  114638. /**
  114639. * Stores the rotation
  114640. */
  114641. rotation: Vector3;
  114642. /**
  114643. * Stores the rotation quaternion
  114644. */
  114645. rotationQuaternion: Nullable<Quaternion>;
  114646. /**
  114647. * Stores the scaling vector
  114648. */
  114649. scaling: Vector3;
  114650. /**
  114651. * Convert the Mesh to CSG
  114652. * @param mesh The Mesh to convert to CSG
  114653. * @returns A new CSG from the Mesh
  114654. */
  114655. static FromMesh(mesh: Mesh): CSG;
  114656. /**
  114657. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  114658. * @param polygons Polygons used to construct a CSG solid
  114659. */
  114660. private static FromPolygons;
  114661. /**
  114662. * Clones, or makes a deep copy, of the CSG
  114663. * @returns A new CSG
  114664. */
  114665. clone(): CSG;
  114666. /**
  114667. * Unions this CSG with another CSG
  114668. * @param csg The CSG to union against this CSG
  114669. * @returns The unioned CSG
  114670. */
  114671. union(csg: CSG): CSG;
  114672. /**
  114673. * Unions this CSG with another CSG in place
  114674. * @param csg The CSG to union against this CSG
  114675. */
  114676. unionInPlace(csg: CSG): void;
  114677. /**
  114678. * Subtracts this CSG with another CSG
  114679. * @param csg The CSG to subtract against this CSG
  114680. * @returns A new CSG
  114681. */
  114682. subtract(csg: CSG): CSG;
  114683. /**
  114684. * Subtracts this CSG with another CSG in place
  114685. * @param csg The CSG to subtact against this CSG
  114686. */
  114687. subtractInPlace(csg: CSG): void;
  114688. /**
  114689. * Intersect this CSG with another CSG
  114690. * @param csg The CSG to intersect against this CSG
  114691. * @returns A new CSG
  114692. */
  114693. intersect(csg: CSG): CSG;
  114694. /**
  114695. * Intersects this CSG with another CSG in place
  114696. * @param csg The CSG to intersect against this CSG
  114697. */
  114698. intersectInPlace(csg: CSG): void;
  114699. /**
  114700. * Return a new CSG solid with solid and empty space switched. This solid is
  114701. * not modified.
  114702. * @returns A new CSG solid with solid and empty space switched
  114703. */
  114704. inverse(): CSG;
  114705. /**
  114706. * Inverses the CSG in place
  114707. */
  114708. inverseInPlace(): void;
  114709. /**
  114710. * This is used to keep meshes transformations so they can be restored
  114711. * when we build back a Babylon Mesh
  114712. * NB : All CSG operations are performed in world coordinates
  114713. * @param csg The CSG to copy the transform attributes from
  114714. * @returns This CSG
  114715. */
  114716. copyTransformAttributes(csg: CSG): CSG;
  114717. /**
  114718. * Build Raw mesh from CSG
  114719. * Coordinates here are in world space
  114720. * @param name The name of the mesh geometry
  114721. * @param scene The Scene
  114722. * @param keepSubMeshes Specifies if the submeshes should be kept
  114723. * @returns A new Mesh
  114724. */
  114725. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  114726. /**
  114727. * Build Mesh from CSG taking material and transforms into account
  114728. * @param name The name of the Mesh
  114729. * @param material The material of the Mesh
  114730. * @param scene The Scene
  114731. * @param keepSubMeshes Specifies if submeshes should be kept
  114732. * @returns The new Mesh
  114733. */
  114734. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  114735. }
  114736. }
  114737. declare module BABYLON {
  114738. /**
  114739. * Class used to create a trail following a mesh
  114740. */
  114741. export class TrailMesh extends Mesh {
  114742. private _generator;
  114743. private _autoStart;
  114744. private _running;
  114745. private _diameter;
  114746. private _length;
  114747. private _sectionPolygonPointsCount;
  114748. private _sectionVectors;
  114749. private _sectionNormalVectors;
  114750. private _beforeRenderObserver;
  114751. /**
  114752. * @constructor
  114753. * @param name The value used by scene.getMeshByName() to do a lookup.
  114754. * @param generator The mesh to generate a trail.
  114755. * @param scene The scene to add this mesh to.
  114756. * @param diameter Diameter of trailing mesh. Default is 1.
  114757. * @param length Length of trailing mesh. Default is 60.
  114758. * @param autoStart Automatically start trailing mesh. Default true.
  114759. */
  114760. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  114761. /**
  114762. * "TrailMesh"
  114763. * @returns "TrailMesh"
  114764. */
  114765. getClassName(): string;
  114766. private _createMesh;
  114767. /**
  114768. * Start trailing mesh.
  114769. */
  114770. start(): void;
  114771. /**
  114772. * Stop trailing mesh.
  114773. */
  114774. stop(): void;
  114775. /**
  114776. * Update trailing mesh geometry.
  114777. */
  114778. update(): void;
  114779. /**
  114780. * Returns a new TrailMesh object.
  114781. * @param name is a string, the name given to the new mesh
  114782. * @param newGenerator use new generator object for cloned trail mesh
  114783. * @returns a new mesh
  114784. */
  114785. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  114786. /**
  114787. * Serializes this trail mesh
  114788. * @param serializationObject object to write serialization to
  114789. */
  114790. serialize(serializationObject: any): void;
  114791. /**
  114792. * Parses a serialized trail mesh
  114793. * @param parsedMesh the serialized mesh
  114794. * @param scene the scene to create the trail mesh in
  114795. * @returns the created trail mesh
  114796. */
  114797. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  114798. }
  114799. }
  114800. declare module BABYLON {
  114801. /**
  114802. * Class containing static functions to help procedurally build meshes
  114803. */
  114804. export class TiledBoxBuilder {
  114805. /**
  114806. * Creates a box mesh
  114807. * 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)
  114808. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114812. * @param name defines the name of the mesh
  114813. * @param options defines the options used to create the mesh
  114814. * @param scene defines the hosting scene
  114815. * @returns the box mesh
  114816. */
  114817. static CreateTiledBox(name: string, options: {
  114818. pattern?: number;
  114819. width?: number;
  114820. height?: number;
  114821. depth?: number;
  114822. tileSize?: number;
  114823. tileWidth?: number;
  114824. tileHeight?: number;
  114825. alignHorizontal?: number;
  114826. alignVertical?: number;
  114827. faceUV?: Vector4[];
  114828. faceColors?: Color4[];
  114829. sideOrientation?: number;
  114830. updatable?: boolean;
  114831. }, scene?: Nullable<Scene>): Mesh;
  114832. }
  114833. }
  114834. declare module BABYLON {
  114835. /**
  114836. * Class containing static functions to help procedurally build meshes
  114837. */
  114838. export class TorusKnotBuilder {
  114839. /**
  114840. * Creates a torus knot mesh
  114841. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114842. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114843. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114844. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114848. * @param name defines the name of the mesh
  114849. * @param options defines the options used to create the mesh
  114850. * @param scene defines the hosting scene
  114851. * @returns the torus knot mesh
  114852. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114853. */
  114854. static CreateTorusKnot(name: string, options: {
  114855. radius?: number;
  114856. tube?: number;
  114857. radialSegments?: number;
  114858. tubularSegments?: number;
  114859. p?: number;
  114860. q?: number;
  114861. updatable?: boolean;
  114862. sideOrientation?: number;
  114863. frontUVs?: Vector4;
  114864. backUVs?: Vector4;
  114865. }, scene: any): Mesh;
  114866. }
  114867. }
  114868. declare module BABYLON {
  114869. /**
  114870. * Polygon
  114871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114872. */
  114873. export class Polygon {
  114874. /**
  114875. * Creates a rectangle
  114876. * @param xmin bottom X coord
  114877. * @param ymin bottom Y coord
  114878. * @param xmax top X coord
  114879. * @param ymax top Y coord
  114880. * @returns points that make the resulting rectation
  114881. */
  114882. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  114883. /**
  114884. * Creates a circle
  114885. * @param radius radius of circle
  114886. * @param cx scale in x
  114887. * @param cy scale in y
  114888. * @param numberOfSides number of sides that make up the circle
  114889. * @returns points that make the resulting circle
  114890. */
  114891. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  114892. /**
  114893. * Creates a polygon from input string
  114894. * @param input Input polygon data
  114895. * @returns the parsed points
  114896. */
  114897. static Parse(input: string): Vector2[];
  114898. /**
  114899. * Starts building a polygon from x and y coordinates
  114900. * @param x x coordinate
  114901. * @param y y coordinate
  114902. * @returns the started path2
  114903. */
  114904. static StartingAt(x: number, y: number): Path2;
  114905. }
  114906. /**
  114907. * Builds a polygon
  114908. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  114909. */
  114910. export class PolygonMeshBuilder {
  114911. private _points;
  114912. private _outlinepoints;
  114913. private _holes;
  114914. private _name;
  114915. private _scene;
  114916. private _epoints;
  114917. private _eholes;
  114918. private _addToepoint;
  114919. /**
  114920. * Babylon reference to the earcut plugin.
  114921. */
  114922. bjsEarcut: any;
  114923. /**
  114924. * Creates a PolygonMeshBuilder
  114925. * @param name name of the builder
  114926. * @param contours Path of the polygon
  114927. * @param scene scene to add to when creating the mesh
  114928. * @param earcutInjection can be used to inject your own earcut reference
  114929. */
  114930. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  114931. /**
  114932. * Adds a whole within the polygon
  114933. * @param hole Array of points defining the hole
  114934. * @returns this
  114935. */
  114936. addHole(hole: Vector2[]): PolygonMeshBuilder;
  114937. /**
  114938. * Creates the polygon
  114939. * @param updatable If the mesh should be updatable
  114940. * @param depth The depth of the mesh created
  114941. * @returns the created mesh
  114942. */
  114943. build(updatable?: boolean, depth?: number): Mesh;
  114944. /**
  114945. * Creates the polygon
  114946. * @param depth The depth of the mesh created
  114947. * @returns the created VertexData
  114948. */
  114949. buildVertexData(depth?: number): VertexData;
  114950. /**
  114951. * Adds a side to the polygon
  114952. * @param positions points that make the polygon
  114953. * @param normals normals of the polygon
  114954. * @param uvs uvs of the polygon
  114955. * @param indices indices of the polygon
  114956. * @param bounds bounds of the polygon
  114957. * @param points points of the polygon
  114958. * @param depth depth of the polygon
  114959. * @param flip flip of the polygon
  114960. */
  114961. private addSide;
  114962. }
  114963. }
  114964. declare module BABYLON {
  114965. /**
  114966. * Class containing static functions to help procedurally build meshes
  114967. */
  114968. export class PolygonBuilder {
  114969. /**
  114970. * Creates a polygon mesh
  114971. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  114972. * * 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
  114973. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  114976. * * Remember you can only change the shape positions, not their number when updating a polygon
  114977. * @param name defines the name of the mesh
  114978. * @param options defines the options used to create the mesh
  114979. * @param scene defines the hosting scene
  114980. * @param earcutInjection can be used to inject your own earcut reference
  114981. * @returns the polygon mesh
  114982. */
  114983. static CreatePolygon(name: string, options: {
  114984. shape: Vector3[];
  114985. holes?: Vector3[][];
  114986. depth?: number;
  114987. faceUV?: Vector4[];
  114988. faceColors?: Color4[];
  114989. updatable?: boolean;
  114990. sideOrientation?: number;
  114991. frontUVs?: Vector4;
  114992. backUVs?: Vector4;
  114993. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114994. /**
  114995. * Creates an extruded polygon mesh, with depth in the Y direction.
  114996. * * 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)
  114997. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114998. * @param name defines the name of the mesh
  114999. * @param options defines the options used to create the mesh
  115000. * @param scene defines the hosting scene
  115001. * @param earcutInjection can be used to inject your own earcut reference
  115002. * @returns the polygon mesh
  115003. */
  115004. static ExtrudePolygon(name: string, options: {
  115005. shape: Vector3[];
  115006. holes?: Vector3[][];
  115007. depth?: number;
  115008. faceUV?: Vector4[];
  115009. faceColors?: Color4[];
  115010. updatable?: boolean;
  115011. sideOrientation?: number;
  115012. frontUVs?: Vector4;
  115013. backUVs?: Vector4;
  115014. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115015. }
  115016. }
  115017. declare module BABYLON {
  115018. /**
  115019. * Class containing static functions to help procedurally build meshes
  115020. */
  115021. export class LatheBuilder {
  115022. /**
  115023. * Creates lathe mesh.
  115024. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115025. * * 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
  115026. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115027. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115028. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115029. * * 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
  115030. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115031. * * 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
  115032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115036. * @param name defines the name of the mesh
  115037. * @param options defines the options used to create the mesh
  115038. * @param scene defines the hosting scene
  115039. * @returns the lathe mesh
  115040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115041. */
  115042. static CreateLathe(name: string, options: {
  115043. shape: Vector3[];
  115044. radius?: number;
  115045. tessellation?: number;
  115046. clip?: number;
  115047. arc?: number;
  115048. closed?: boolean;
  115049. updatable?: boolean;
  115050. sideOrientation?: number;
  115051. frontUVs?: Vector4;
  115052. backUVs?: Vector4;
  115053. cap?: number;
  115054. invertUV?: boolean;
  115055. }, scene?: Nullable<Scene>): Mesh;
  115056. }
  115057. }
  115058. declare module BABYLON {
  115059. /**
  115060. * Class containing static functions to help procedurally build meshes
  115061. */
  115062. export class TiledPlaneBuilder {
  115063. /**
  115064. * Creates a tiled plane mesh
  115065. * * The parameter `pattern` will, depending on value, do nothing or
  115066. * * * flip (reflect about central vertical) alternate tiles across and up
  115067. * * * flip every tile on alternate rows
  115068. * * * rotate (180 degs) alternate tiles across and up
  115069. * * * rotate every tile on alternate rows
  115070. * * * flip and rotate alternate tiles across and up
  115071. * * * flip and rotate every tile on alternate rows
  115072. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115073. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115076. * * 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)
  115077. * * 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)
  115078. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115079. * @param name defines the name of the mesh
  115080. * @param options defines the options used to create the mesh
  115081. * @param scene defines the hosting scene
  115082. * @returns the box mesh
  115083. */
  115084. static CreateTiledPlane(name: string, options: {
  115085. pattern?: number;
  115086. tileSize?: number;
  115087. tileWidth?: number;
  115088. tileHeight?: number;
  115089. size?: number;
  115090. width?: number;
  115091. height?: number;
  115092. alignHorizontal?: number;
  115093. alignVertical?: number;
  115094. sideOrientation?: number;
  115095. frontUVs?: Vector4;
  115096. backUVs?: Vector4;
  115097. updatable?: boolean;
  115098. }, scene?: Nullable<Scene>): Mesh;
  115099. }
  115100. }
  115101. declare module BABYLON {
  115102. /**
  115103. * Class containing static functions to help procedurally build meshes
  115104. */
  115105. export class TubeBuilder {
  115106. /**
  115107. * Creates a tube mesh.
  115108. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115109. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115110. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115111. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115112. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115113. * * 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)
  115114. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115115. * * 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
  115116. * * 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
  115117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115119. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115121. * @param name defines the name of the mesh
  115122. * @param options defines the options used to create the mesh
  115123. * @param scene defines the hosting scene
  115124. * @returns the tube mesh
  115125. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115126. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115127. */
  115128. static CreateTube(name: string, options: {
  115129. path: Vector3[];
  115130. radius?: number;
  115131. tessellation?: number;
  115132. radiusFunction?: {
  115133. (i: number, distance: number): number;
  115134. };
  115135. cap?: number;
  115136. arc?: number;
  115137. updatable?: boolean;
  115138. sideOrientation?: number;
  115139. frontUVs?: Vector4;
  115140. backUVs?: Vector4;
  115141. instance?: Mesh;
  115142. invertUV?: boolean;
  115143. }, scene?: Nullable<Scene>): Mesh;
  115144. }
  115145. }
  115146. declare module BABYLON {
  115147. /**
  115148. * Class containing static functions to help procedurally build meshes
  115149. */
  115150. export class IcoSphereBuilder {
  115151. /**
  115152. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115153. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115154. * * 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`)
  115155. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115156. * * 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
  115157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115160. * @param name defines the name of the mesh
  115161. * @param options defines the options used to create the mesh
  115162. * @param scene defines the hosting scene
  115163. * @returns the icosahedron mesh
  115164. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115165. */
  115166. static CreateIcoSphere(name: string, options: {
  115167. radius?: number;
  115168. radiusX?: number;
  115169. radiusY?: number;
  115170. radiusZ?: number;
  115171. flat?: boolean;
  115172. subdivisions?: number;
  115173. sideOrientation?: number;
  115174. frontUVs?: Vector4;
  115175. backUVs?: Vector4;
  115176. updatable?: boolean;
  115177. }, scene?: Nullable<Scene>): Mesh;
  115178. }
  115179. }
  115180. declare module BABYLON {
  115181. /**
  115182. * Class containing static functions to help procedurally build meshes
  115183. */
  115184. export class DecalBuilder {
  115185. /**
  115186. * Creates a decal mesh.
  115187. * 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
  115188. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115189. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115190. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115191. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115192. * @param name defines the name of the mesh
  115193. * @param sourceMesh defines the mesh where the decal must be applied
  115194. * @param options defines the options used to create the mesh
  115195. * @param scene defines the hosting scene
  115196. * @returns the decal mesh
  115197. * @see https://doc.babylonjs.com/how_to/decals
  115198. */
  115199. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115200. position?: Vector3;
  115201. normal?: Vector3;
  115202. size?: Vector3;
  115203. angle?: number;
  115204. }): Mesh;
  115205. }
  115206. }
  115207. declare module BABYLON {
  115208. /**
  115209. * Class containing static functions to help procedurally build meshes
  115210. */
  115211. export class MeshBuilder {
  115212. /**
  115213. * Creates a box mesh
  115214. * * The parameter `size` sets the size (float) of each box side (default 1)
  115215. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115216. * * 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)
  115217. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115221. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115222. * @param name defines the name of the mesh
  115223. * @param options defines the options used to create the mesh
  115224. * @param scene defines the hosting scene
  115225. * @returns the box mesh
  115226. */
  115227. static CreateBox(name: string, options: {
  115228. size?: number;
  115229. width?: number;
  115230. height?: number;
  115231. depth?: number;
  115232. faceUV?: Vector4[];
  115233. faceColors?: Color4[];
  115234. sideOrientation?: number;
  115235. frontUVs?: Vector4;
  115236. backUVs?: Vector4;
  115237. updatable?: boolean;
  115238. }, scene?: Nullable<Scene>): Mesh;
  115239. /**
  115240. * Creates a tiled box mesh
  115241. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115243. * @param name defines the name of the mesh
  115244. * @param options defines the options used to create the mesh
  115245. * @param scene defines the hosting scene
  115246. * @returns the tiled box mesh
  115247. */
  115248. static CreateTiledBox(name: string, options: {
  115249. pattern?: number;
  115250. size?: number;
  115251. width?: number;
  115252. height?: number;
  115253. depth: number;
  115254. tileSize?: number;
  115255. tileWidth?: number;
  115256. tileHeight?: number;
  115257. faceUV?: Vector4[];
  115258. faceColors?: Color4[];
  115259. alignHorizontal?: number;
  115260. alignVertical?: number;
  115261. sideOrientation?: number;
  115262. updatable?: boolean;
  115263. }, scene?: Nullable<Scene>): Mesh;
  115264. /**
  115265. * Creates a sphere mesh
  115266. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115267. * * 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`)
  115268. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115269. * * 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
  115270. * * 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)
  115271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115274. * @param name defines the name of the mesh
  115275. * @param options defines the options used to create the mesh
  115276. * @param scene defines the hosting scene
  115277. * @returns the sphere mesh
  115278. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115279. */
  115280. static CreateSphere(name: string, options: {
  115281. segments?: number;
  115282. diameter?: number;
  115283. diameterX?: number;
  115284. diameterY?: number;
  115285. diameterZ?: number;
  115286. arc?: number;
  115287. slice?: number;
  115288. sideOrientation?: number;
  115289. frontUVs?: Vector4;
  115290. backUVs?: Vector4;
  115291. updatable?: boolean;
  115292. }, scene?: Nullable<Scene>): Mesh;
  115293. /**
  115294. * Creates a plane polygonal mesh. By default, this is a disc
  115295. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115296. * * 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
  115297. * * 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
  115298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115301. * @param name defines the name of the mesh
  115302. * @param options defines the options used to create the mesh
  115303. * @param scene defines the hosting scene
  115304. * @returns the plane polygonal mesh
  115305. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115306. */
  115307. static CreateDisc(name: string, options: {
  115308. radius?: number;
  115309. tessellation?: number;
  115310. arc?: number;
  115311. updatable?: boolean;
  115312. sideOrientation?: number;
  115313. frontUVs?: Vector4;
  115314. backUVs?: Vector4;
  115315. }, scene?: Nullable<Scene>): Mesh;
  115316. /**
  115317. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115318. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115319. * * 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`)
  115320. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115321. * * 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
  115322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115325. * @param name defines the name of the mesh
  115326. * @param options defines the options used to create the mesh
  115327. * @param scene defines the hosting scene
  115328. * @returns the icosahedron mesh
  115329. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115330. */
  115331. static CreateIcoSphere(name: string, options: {
  115332. radius?: number;
  115333. radiusX?: number;
  115334. radiusY?: number;
  115335. radiusZ?: number;
  115336. flat?: boolean;
  115337. subdivisions?: number;
  115338. sideOrientation?: number;
  115339. frontUVs?: Vector4;
  115340. backUVs?: Vector4;
  115341. updatable?: boolean;
  115342. }, scene?: Nullable<Scene>): Mesh;
  115343. /**
  115344. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115345. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115346. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115347. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115348. * * 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
  115349. * * 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
  115350. * * 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
  115351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115354. * * 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
  115355. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115356. * * 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
  115357. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115359. * @param name defines the name of the mesh
  115360. * @param options defines the options used to create the mesh
  115361. * @param scene defines the hosting scene
  115362. * @returns the ribbon mesh
  115363. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115364. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115365. */
  115366. static CreateRibbon(name: string, options: {
  115367. pathArray: Vector3[][];
  115368. closeArray?: boolean;
  115369. closePath?: boolean;
  115370. offset?: number;
  115371. updatable?: boolean;
  115372. sideOrientation?: number;
  115373. frontUVs?: Vector4;
  115374. backUVs?: Vector4;
  115375. instance?: Mesh;
  115376. invertUV?: boolean;
  115377. uvs?: Vector2[];
  115378. colors?: Color4[];
  115379. }, scene?: Nullable<Scene>): Mesh;
  115380. /**
  115381. * Creates a cylinder or a cone mesh
  115382. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115383. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115384. * * 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.
  115385. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115386. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115387. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115388. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115389. * * 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).
  115390. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115391. * * 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).
  115392. * * 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
  115393. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115394. * * 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
  115395. * * 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.
  115396. * * If `enclose` is false, a ring surface is one element.
  115397. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115398. * * 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
  115399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115402. * @param name defines the name of the mesh
  115403. * @param options defines the options used to create the mesh
  115404. * @param scene defines the hosting scene
  115405. * @returns the cylinder mesh
  115406. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115407. */
  115408. static CreateCylinder(name: string, options: {
  115409. height?: number;
  115410. diameterTop?: number;
  115411. diameterBottom?: number;
  115412. diameter?: number;
  115413. tessellation?: number;
  115414. subdivisions?: number;
  115415. arc?: number;
  115416. faceColors?: Color4[];
  115417. faceUV?: Vector4[];
  115418. updatable?: boolean;
  115419. hasRings?: boolean;
  115420. enclose?: boolean;
  115421. cap?: number;
  115422. sideOrientation?: number;
  115423. frontUVs?: Vector4;
  115424. backUVs?: Vector4;
  115425. }, scene?: Nullable<Scene>): Mesh;
  115426. /**
  115427. * Creates a torus mesh
  115428. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115429. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115430. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115434. * @param name defines the name of the mesh
  115435. * @param options defines the options used to create the mesh
  115436. * @param scene defines the hosting scene
  115437. * @returns the torus mesh
  115438. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115439. */
  115440. static CreateTorus(name: string, options: {
  115441. diameter?: number;
  115442. thickness?: number;
  115443. tessellation?: number;
  115444. updatable?: boolean;
  115445. sideOrientation?: number;
  115446. frontUVs?: Vector4;
  115447. backUVs?: Vector4;
  115448. }, scene?: Nullable<Scene>): Mesh;
  115449. /**
  115450. * Creates a torus knot mesh
  115451. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115452. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115453. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115454. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115456. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115458. * @param name defines the name of the mesh
  115459. * @param options defines the options used to create the mesh
  115460. * @param scene defines the hosting scene
  115461. * @returns the torus knot mesh
  115462. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115463. */
  115464. static CreateTorusKnot(name: string, options: {
  115465. radius?: number;
  115466. tube?: number;
  115467. radialSegments?: number;
  115468. tubularSegments?: number;
  115469. p?: number;
  115470. q?: number;
  115471. updatable?: boolean;
  115472. sideOrientation?: number;
  115473. frontUVs?: Vector4;
  115474. backUVs?: Vector4;
  115475. }, scene?: Nullable<Scene>): Mesh;
  115476. /**
  115477. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115478. * * 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
  115479. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115480. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115481. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115482. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115483. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115484. * * 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
  115485. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115488. * @param name defines the name of the new line system
  115489. * @param options defines the options used to create the line system
  115490. * @param scene defines the hosting scene
  115491. * @returns a new line system mesh
  115492. */
  115493. static CreateLineSystem(name: string, options: {
  115494. lines: Vector3[][];
  115495. updatable?: boolean;
  115496. instance?: Nullable<LinesMesh>;
  115497. colors?: Nullable<Color4[][]>;
  115498. useVertexAlpha?: boolean;
  115499. }, scene: Nullable<Scene>): LinesMesh;
  115500. /**
  115501. * Creates a line mesh
  115502. * 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
  115503. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115504. * * The parameter `points` is an array successive Vector3
  115505. * * 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
  115506. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115507. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115508. * * When updating an instance, remember that only point positions can change, not the number of points
  115509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115511. * @param name defines the name of the new line system
  115512. * @param options defines the options used to create the line system
  115513. * @param scene defines the hosting scene
  115514. * @returns a new line mesh
  115515. */
  115516. static CreateLines(name: string, options: {
  115517. points: Vector3[];
  115518. updatable?: boolean;
  115519. instance?: Nullable<LinesMesh>;
  115520. colors?: Color4[];
  115521. useVertexAlpha?: boolean;
  115522. }, scene?: Nullable<Scene>): LinesMesh;
  115523. /**
  115524. * Creates a dashed line mesh
  115525. * * 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
  115526. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115527. * * The parameter `points` is an array successive Vector3
  115528. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  115529. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  115530. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  115531. * * 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
  115532. * * When updating an instance, remember that only point positions can change, not the number of points
  115533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115534. * @param name defines the name of the mesh
  115535. * @param options defines the options used to create the mesh
  115536. * @param scene defines the hosting scene
  115537. * @returns the dashed line mesh
  115538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  115539. */
  115540. static CreateDashedLines(name: string, options: {
  115541. points: Vector3[];
  115542. dashSize?: number;
  115543. gapSize?: number;
  115544. dashNb?: number;
  115545. updatable?: boolean;
  115546. instance?: LinesMesh;
  115547. }, scene?: Nullable<Scene>): LinesMesh;
  115548. /**
  115549. * 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.
  115550. * * 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.
  115551. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115552. * * 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.
  115553. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115554. * * 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
  115555. * * 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
  115556. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115559. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115561. * @param name defines the name of the mesh
  115562. * @param options defines the options used to create the mesh
  115563. * @param scene defines the hosting scene
  115564. * @returns the extruded shape mesh
  115565. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115567. */
  115568. static ExtrudeShape(name: string, options: {
  115569. shape: Vector3[];
  115570. path: Vector3[];
  115571. scale?: number;
  115572. rotation?: number;
  115573. cap?: number;
  115574. updatable?: boolean;
  115575. sideOrientation?: number;
  115576. frontUVs?: Vector4;
  115577. backUVs?: Vector4;
  115578. instance?: Mesh;
  115579. invertUV?: boolean;
  115580. }, scene?: Nullable<Scene>): Mesh;
  115581. /**
  115582. * Creates an custom extruded shape mesh.
  115583. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115584. * * 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.
  115585. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115586. * * 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
  115587. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115588. * * 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
  115589. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115590. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115591. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115592. * * 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
  115593. * * 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
  115594. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115597. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115599. * @param name defines the name of the mesh
  115600. * @param options defines the options used to create the mesh
  115601. * @param scene defines the hosting scene
  115602. * @returns the custom extruded shape mesh
  115603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115604. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115606. */
  115607. static ExtrudeShapeCustom(name: string, options: {
  115608. shape: Vector3[];
  115609. path: Vector3[];
  115610. scaleFunction?: any;
  115611. rotationFunction?: any;
  115612. ribbonCloseArray?: boolean;
  115613. ribbonClosePath?: boolean;
  115614. cap?: number;
  115615. updatable?: boolean;
  115616. sideOrientation?: number;
  115617. frontUVs?: Vector4;
  115618. backUVs?: Vector4;
  115619. instance?: Mesh;
  115620. invertUV?: boolean;
  115621. }, scene?: Nullable<Scene>): Mesh;
  115622. /**
  115623. * Creates lathe mesh.
  115624. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115625. * * 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
  115626. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115627. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115628. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115629. * * 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
  115630. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115631. * * 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
  115632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115634. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115636. * @param name defines the name of the mesh
  115637. * @param options defines the options used to create the mesh
  115638. * @param scene defines the hosting scene
  115639. * @returns the lathe mesh
  115640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115641. */
  115642. static CreateLathe(name: string, options: {
  115643. shape: Vector3[];
  115644. radius?: number;
  115645. tessellation?: number;
  115646. clip?: number;
  115647. arc?: number;
  115648. closed?: boolean;
  115649. updatable?: boolean;
  115650. sideOrientation?: number;
  115651. frontUVs?: Vector4;
  115652. backUVs?: Vector4;
  115653. cap?: number;
  115654. invertUV?: boolean;
  115655. }, scene?: Nullable<Scene>): Mesh;
  115656. /**
  115657. * Creates a tiled plane mesh
  115658. * * You can set a limited pattern arrangement with the tiles
  115659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115662. * @param name defines the name of the mesh
  115663. * @param options defines the options used to create the mesh
  115664. * @param scene defines the hosting scene
  115665. * @returns the plane mesh
  115666. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115667. */
  115668. static CreateTiledPlane(name: string, options: {
  115669. pattern?: number;
  115670. tileSize?: number;
  115671. tileWidth?: number;
  115672. tileHeight?: number;
  115673. size?: number;
  115674. width?: number;
  115675. height?: number;
  115676. alignHorizontal?: number;
  115677. alignVertical?: number;
  115678. sideOrientation?: number;
  115679. frontUVs?: Vector4;
  115680. backUVs?: Vector4;
  115681. updatable?: boolean;
  115682. }, scene?: Nullable<Scene>): Mesh;
  115683. /**
  115684. * Creates a plane mesh
  115685. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115686. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115687. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115691. * @param name defines the name of the mesh
  115692. * @param options defines the options used to create the mesh
  115693. * @param scene defines the hosting scene
  115694. * @returns the plane mesh
  115695. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115696. */
  115697. static CreatePlane(name: string, options: {
  115698. size?: number;
  115699. width?: number;
  115700. height?: number;
  115701. sideOrientation?: number;
  115702. frontUVs?: Vector4;
  115703. backUVs?: Vector4;
  115704. updatable?: boolean;
  115705. sourcePlane?: Plane;
  115706. }, scene?: Nullable<Scene>): Mesh;
  115707. /**
  115708. * Creates a ground mesh
  115709. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115710. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115712. * @param name defines the name of the mesh
  115713. * @param options defines the options used to create the mesh
  115714. * @param scene defines the hosting scene
  115715. * @returns the ground mesh
  115716. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115717. */
  115718. static CreateGround(name: string, options: {
  115719. width?: number;
  115720. height?: number;
  115721. subdivisions?: number;
  115722. subdivisionsX?: number;
  115723. subdivisionsY?: number;
  115724. updatable?: boolean;
  115725. }, scene?: Nullable<Scene>): Mesh;
  115726. /**
  115727. * Creates a tiled ground mesh
  115728. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115729. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115730. * * 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
  115731. * * 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
  115732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115733. * @param name defines the name of the mesh
  115734. * @param options defines the options used to create the mesh
  115735. * @param scene defines the hosting scene
  115736. * @returns the tiled ground mesh
  115737. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115738. */
  115739. static CreateTiledGround(name: string, options: {
  115740. xmin: number;
  115741. zmin: number;
  115742. xmax: number;
  115743. zmax: number;
  115744. subdivisions?: {
  115745. w: number;
  115746. h: number;
  115747. };
  115748. precision?: {
  115749. w: number;
  115750. h: number;
  115751. };
  115752. updatable?: boolean;
  115753. }, scene?: Nullable<Scene>): Mesh;
  115754. /**
  115755. * Creates a ground mesh from a height map
  115756. * * The parameter `url` sets the URL of the height map image resource.
  115757. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115758. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115759. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115760. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115761. * * 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.
  115762. * * 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).
  115763. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115765. * @param name defines the name of the mesh
  115766. * @param url defines the url to the height map
  115767. * @param options defines the options used to create the mesh
  115768. * @param scene defines the hosting scene
  115769. * @returns the ground mesh
  115770. * @see https://doc.babylonjs.com/babylon101/height_map
  115771. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115772. */
  115773. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115774. width?: number;
  115775. height?: number;
  115776. subdivisions?: number;
  115777. minHeight?: number;
  115778. maxHeight?: number;
  115779. colorFilter?: Color3;
  115780. alphaFilter?: number;
  115781. updatable?: boolean;
  115782. onReady?: (mesh: GroundMesh) => void;
  115783. }, scene?: Nullable<Scene>): GroundMesh;
  115784. /**
  115785. * Creates a polygon mesh
  115786. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115787. * * 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
  115788. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115791. * * Remember you can only change the shape positions, not their number when updating a polygon
  115792. * @param name defines the name of the mesh
  115793. * @param options defines the options used to create the mesh
  115794. * @param scene defines the hosting scene
  115795. * @param earcutInjection can be used to inject your own earcut reference
  115796. * @returns the polygon mesh
  115797. */
  115798. static CreatePolygon(name: string, options: {
  115799. shape: Vector3[];
  115800. holes?: Vector3[][];
  115801. depth?: number;
  115802. faceUV?: Vector4[];
  115803. faceColors?: Color4[];
  115804. updatable?: boolean;
  115805. sideOrientation?: number;
  115806. frontUVs?: Vector4;
  115807. backUVs?: Vector4;
  115808. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115809. /**
  115810. * Creates an extruded polygon mesh, with depth in the Y direction.
  115811. * * 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)
  115812. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115813. * @param name defines the name of the mesh
  115814. * @param options defines the options used to create the mesh
  115815. * @param scene defines the hosting scene
  115816. * @param earcutInjection can be used to inject your own earcut reference
  115817. * @returns the polygon mesh
  115818. */
  115819. static ExtrudePolygon(name: string, options: {
  115820. shape: Vector3[];
  115821. holes?: Vector3[][];
  115822. depth?: number;
  115823. faceUV?: Vector4[];
  115824. faceColors?: Color4[];
  115825. updatable?: boolean;
  115826. sideOrientation?: number;
  115827. frontUVs?: Vector4;
  115828. backUVs?: Vector4;
  115829. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115830. /**
  115831. * Creates a tube mesh.
  115832. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115833. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115834. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115835. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115836. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115837. * * 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)
  115838. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115839. * * 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
  115840. * * 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
  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 tube mesh
  115849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115850. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115851. */
  115852. static CreateTube(name: string, options: {
  115853. path: Vector3[];
  115854. radius?: number;
  115855. tessellation?: number;
  115856. radiusFunction?: {
  115857. (i: number, distance: number): number;
  115858. };
  115859. cap?: number;
  115860. arc?: number;
  115861. updatable?: boolean;
  115862. sideOrientation?: number;
  115863. frontUVs?: Vector4;
  115864. backUVs?: Vector4;
  115865. instance?: Mesh;
  115866. invertUV?: boolean;
  115867. }, scene?: Nullable<Scene>): Mesh;
  115868. /**
  115869. * Creates a polyhedron mesh
  115870. * * 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
  115871. * * The parameter `size` (positive float, default 1) sets the polygon size
  115872. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115873. * * 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`
  115874. * * 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
  115875. * * 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)`)
  115876. * * 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
  115877. * * 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
  115878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115881. * @param name defines the name of the mesh
  115882. * @param options defines the options used to create the mesh
  115883. * @param scene defines the hosting scene
  115884. * @returns the polyhedron mesh
  115885. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115886. */
  115887. static CreatePolyhedron(name: string, options: {
  115888. type?: number;
  115889. size?: number;
  115890. sizeX?: number;
  115891. sizeY?: number;
  115892. sizeZ?: number;
  115893. custom?: any;
  115894. faceUV?: Vector4[];
  115895. faceColors?: Color4[];
  115896. flat?: boolean;
  115897. updatable?: boolean;
  115898. sideOrientation?: number;
  115899. frontUVs?: Vector4;
  115900. backUVs?: Vector4;
  115901. }, scene?: Nullable<Scene>): Mesh;
  115902. /**
  115903. * Creates a decal mesh.
  115904. * 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
  115905. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115906. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115907. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115908. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115909. * @param name defines the name of the mesh
  115910. * @param sourceMesh defines the mesh where the decal must be applied
  115911. * @param options defines the options used to create the mesh
  115912. * @param scene defines the hosting scene
  115913. * @returns the decal mesh
  115914. * @see https://doc.babylonjs.com/how_to/decals
  115915. */
  115916. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115917. position?: Vector3;
  115918. normal?: Vector3;
  115919. size?: Vector3;
  115920. angle?: number;
  115921. }): Mesh;
  115922. }
  115923. }
  115924. declare module BABYLON {
  115925. /**
  115926. * A simplifier interface for future simplification implementations
  115927. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115928. */
  115929. export interface ISimplifier {
  115930. /**
  115931. * Simplification of a given mesh according to the given settings.
  115932. * Since this requires computation, it is assumed that the function runs async.
  115933. * @param settings The settings of the simplification, including quality and distance
  115934. * @param successCallback A callback that will be called after the mesh was simplified.
  115935. * @param errorCallback in case of an error, this callback will be called. optional.
  115936. */
  115937. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  115938. }
  115939. /**
  115940. * Expected simplification settings.
  115941. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  115942. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115943. */
  115944. export interface ISimplificationSettings {
  115945. /**
  115946. * Gets or sets the expected quality
  115947. */
  115948. quality: number;
  115949. /**
  115950. * Gets or sets the distance when this optimized version should be used
  115951. */
  115952. distance: number;
  115953. /**
  115954. * Gets an already optimized mesh
  115955. */
  115956. optimizeMesh?: boolean;
  115957. }
  115958. /**
  115959. * Class used to specify simplification options
  115960. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115961. */
  115962. export class SimplificationSettings implements ISimplificationSettings {
  115963. /** expected quality */
  115964. quality: number;
  115965. /** distance when this optimized version should be used */
  115966. distance: number;
  115967. /** already optimized mesh */
  115968. optimizeMesh?: boolean | undefined;
  115969. /**
  115970. * Creates a SimplificationSettings
  115971. * @param quality expected quality
  115972. * @param distance distance when this optimized version should be used
  115973. * @param optimizeMesh already optimized mesh
  115974. */
  115975. constructor(
  115976. /** expected quality */
  115977. quality: number,
  115978. /** distance when this optimized version should be used */
  115979. distance: number,
  115980. /** already optimized mesh */
  115981. optimizeMesh?: boolean | undefined);
  115982. }
  115983. /**
  115984. * Interface used to define a simplification task
  115985. */
  115986. export interface ISimplificationTask {
  115987. /**
  115988. * Array of settings
  115989. */
  115990. settings: Array<ISimplificationSettings>;
  115991. /**
  115992. * Simplification type
  115993. */
  115994. simplificationType: SimplificationType;
  115995. /**
  115996. * Mesh to simplify
  115997. */
  115998. mesh: Mesh;
  115999. /**
  116000. * Callback called on success
  116001. */
  116002. successCallback?: () => void;
  116003. /**
  116004. * Defines if parallel processing can be used
  116005. */
  116006. parallelProcessing: boolean;
  116007. }
  116008. /**
  116009. * Queue used to order the simplification tasks
  116010. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116011. */
  116012. export class SimplificationQueue {
  116013. private _simplificationArray;
  116014. /**
  116015. * Gets a boolean indicating that the process is still running
  116016. */
  116017. running: boolean;
  116018. /**
  116019. * Creates a new queue
  116020. */
  116021. constructor();
  116022. /**
  116023. * Adds a new simplification task
  116024. * @param task defines a task to add
  116025. */
  116026. addTask(task: ISimplificationTask): void;
  116027. /**
  116028. * Execute next task
  116029. */
  116030. executeNext(): void;
  116031. /**
  116032. * Execute a simplification task
  116033. * @param task defines the task to run
  116034. */
  116035. runSimplification(task: ISimplificationTask): void;
  116036. private getSimplifier;
  116037. }
  116038. /**
  116039. * The implemented types of simplification
  116040. * At the moment only Quadratic Error Decimation is implemented
  116041. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116042. */
  116043. export enum SimplificationType {
  116044. /** Quadratic error decimation */
  116045. QUADRATIC = 0
  116046. }
  116047. }
  116048. declare module BABYLON {
  116049. interface Scene {
  116050. /** @hidden (Backing field) */
  116051. _simplificationQueue: SimplificationQueue;
  116052. /**
  116053. * Gets or sets the simplification queue attached to the scene
  116054. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116055. */
  116056. simplificationQueue: SimplificationQueue;
  116057. }
  116058. interface Mesh {
  116059. /**
  116060. * Simplify the mesh according to the given array of settings.
  116061. * Function will return immediately and will simplify async
  116062. * @param settings a collection of simplification settings
  116063. * @param parallelProcessing should all levels calculate parallel or one after the other
  116064. * @param simplificationType the type of simplification to run
  116065. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116066. * @returns the current mesh
  116067. */
  116068. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116069. }
  116070. /**
  116071. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116072. * created in a scene
  116073. */
  116074. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116075. /**
  116076. * The component name helpfull to identify the component in the list of scene components.
  116077. */
  116078. readonly name: string;
  116079. /**
  116080. * The scene the component belongs to.
  116081. */
  116082. scene: Scene;
  116083. /**
  116084. * Creates a new instance of the component for the given scene
  116085. * @param scene Defines the scene to register the component in
  116086. */
  116087. constructor(scene: Scene);
  116088. /**
  116089. * Registers the component in a given scene
  116090. */
  116091. register(): void;
  116092. /**
  116093. * Rebuilds the elements related to this component in case of
  116094. * context lost for instance.
  116095. */
  116096. rebuild(): void;
  116097. /**
  116098. * Disposes the component and the associated ressources
  116099. */
  116100. dispose(): void;
  116101. private _beforeCameraUpdate;
  116102. }
  116103. }
  116104. declare module BABYLON {
  116105. /**
  116106. * Class used to enable access to IndexedDB
  116107. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116108. */
  116109. export class Database implements IOfflineProvider {
  116110. private _callbackManifestChecked;
  116111. private _currentSceneUrl;
  116112. private _db;
  116113. private _enableSceneOffline;
  116114. private _enableTexturesOffline;
  116115. private _manifestVersionFound;
  116116. private _mustUpdateRessources;
  116117. private _hasReachedQuota;
  116118. private _isSupported;
  116119. private _idbFactory;
  116120. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116121. private static IsUASupportingBlobStorage;
  116122. /**
  116123. * Gets a boolean indicating if Database storate is enabled (off by default)
  116124. */
  116125. static IDBStorageEnabled: boolean;
  116126. /**
  116127. * Gets a boolean indicating if scene must be saved in the database
  116128. */
  116129. readonly enableSceneOffline: boolean;
  116130. /**
  116131. * Gets a boolean indicating if textures must be saved in the database
  116132. */
  116133. readonly enableTexturesOffline: boolean;
  116134. /**
  116135. * Creates a new Database
  116136. * @param urlToScene defines the url to load the scene
  116137. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116138. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116139. */
  116140. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116141. private static _ParseURL;
  116142. private static _ReturnFullUrlLocation;
  116143. private _checkManifestFile;
  116144. /**
  116145. * Open the database and make it available
  116146. * @param successCallback defines the callback to call on success
  116147. * @param errorCallback defines the callback to call on error
  116148. */
  116149. open(successCallback: () => void, errorCallback: () => void): void;
  116150. /**
  116151. * Loads an image from the database
  116152. * @param url defines the url to load from
  116153. * @param image defines the target DOM image
  116154. */
  116155. loadImage(url: string, image: HTMLImageElement): void;
  116156. private _loadImageFromDBAsync;
  116157. private _saveImageIntoDBAsync;
  116158. private _checkVersionFromDB;
  116159. private _loadVersionFromDBAsync;
  116160. private _saveVersionIntoDBAsync;
  116161. /**
  116162. * Loads a file from database
  116163. * @param url defines the URL to load from
  116164. * @param sceneLoaded defines a callback to call on success
  116165. * @param progressCallBack defines a callback to call when progress changed
  116166. * @param errorCallback defines a callback to call on error
  116167. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116168. */
  116169. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116170. private _loadFileAsync;
  116171. private _saveFileAsync;
  116172. /**
  116173. * Validates if xhr data is correct
  116174. * @param xhr defines the request to validate
  116175. * @param dataType defines the expected data type
  116176. * @returns true if data is correct
  116177. */
  116178. private static _ValidateXHRData;
  116179. }
  116180. }
  116181. declare module BABYLON {
  116182. /** @hidden */
  116183. export var gpuUpdateParticlesPixelShader: {
  116184. name: string;
  116185. shader: string;
  116186. };
  116187. }
  116188. declare module BABYLON {
  116189. /** @hidden */
  116190. export var gpuUpdateParticlesVertexShader: {
  116191. name: string;
  116192. shader: string;
  116193. };
  116194. }
  116195. declare module BABYLON {
  116196. /** @hidden */
  116197. export var clipPlaneFragmentDeclaration2: {
  116198. name: string;
  116199. shader: string;
  116200. };
  116201. }
  116202. declare module BABYLON {
  116203. /** @hidden */
  116204. export var gpuRenderParticlesPixelShader: {
  116205. name: string;
  116206. shader: string;
  116207. };
  116208. }
  116209. declare module BABYLON {
  116210. /** @hidden */
  116211. export var clipPlaneVertexDeclaration2: {
  116212. name: string;
  116213. shader: string;
  116214. };
  116215. }
  116216. declare module BABYLON {
  116217. /** @hidden */
  116218. export var gpuRenderParticlesVertexShader: {
  116219. name: string;
  116220. shader: string;
  116221. };
  116222. }
  116223. declare module BABYLON {
  116224. /**
  116225. * This represents a GPU particle system in Babylon
  116226. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116227. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116228. */
  116229. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116230. /**
  116231. * The layer mask we are rendering the particles through.
  116232. */
  116233. layerMask: number;
  116234. private _capacity;
  116235. private _activeCount;
  116236. private _currentActiveCount;
  116237. private _accumulatedCount;
  116238. private _renderEffect;
  116239. private _updateEffect;
  116240. private _buffer0;
  116241. private _buffer1;
  116242. private _spriteBuffer;
  116243. private _updateVAO;
  116244. private _renderVAO;
  116245. private _targetIndex;
  116246. private _sourceBuffer;
  116247. private _targetBuffer;
  116248. private _engine;
  116249. private _currentRenderId;
  116250. private _started;
  116251. private _stopped;
  116252. private _timeDelta;
  116253. private _randomTexture;
  116254. private _randomTexture2;
  116255. private _attributesStrideSize;
  116256. private _updateEffectOptions;
  116257. private _randomTextureSize;
  116258. private _actualFrame;
  116259. private readonly _rawTextureWidth;
  116260. /**
  116261. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116262. */
  116263. static readonly IsSupported: boolean;
  116264. /**
  116265. * An event triggered when the system is disposed.
  116266. */
  116267. onDisposeObservable: Observable<GPUParticleSystem>;
  116268. /**
  116269. * Gets the maximum number of particles active at the same time.
  116270. * @returns The max number of active particles.
  116271. */
  116272. getCapacity(): number;
  116273. /**
  116274. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116275. * to override the particles.
  116276. */
  116277. forceDepthWrite: boolean;
  116278. /**
  116279. * Gets or set the number of active particles
  116280. */
  116281. activeParticleCount: number;
  116282. private _preWarmDone;
  116283. /**
  116284. * Is this system ready to be used/rendered
  116285. * @return true if the system is ready
  116286. */
  116287. isReady(): boolean;
  116288. /**
  116289. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116290. * @returns True if it has been started, otherwise false.
  116291. */
  116292. isStarted(): boolean;
  116293. /**
  116294. * Starts the particle system and begins to emit
  116295. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  116296. */
  116297. start(delay?: number): void;
  116298. /**
  116299. * Stops the particle system.
  116300. */
  116301. stop(): void;
  116302. /**
  116303. * Remove all active particles
  116304. */
  116305. reset(): void;
  116306. /**
  116307. * Returns the string "GPUParticleSystem"
  116308. * @returns a string containing the class name
  116309. */
  116310. getClassName(): string;
  116311. private _colorGradientsTexture;
  116312. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  116313. /**
  116314. * Adds a new color gradient
  116315. * @param gradient defines the gradient to use (between 0 and 1)
  116316. * @param color1 defines the color to affect to the specified gradient
  116317. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  116318. * @returns the current particle system
  116319. */
  116320. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  116321. /**
  116322. * Remove a specific color gradient
  116323. * @param gradient defines the gradient to remove
  116324. * @returns the current particle system
  116325. */
  116326. removeColorGradient(gradient: number): GPUParticleSystem;
  116327. private _angularSpeedGradientsTexture;
  116328. private _sizeGradientsTexture;
  116329. private _velocityGradientsTexture;
  116330. private _limitVelocityGradientsTexture;
  116331. private _dragGradientsTexture;
  116332. private _addFactorGradient;
  116333. /**
  116334. * Adds a new size gradient
  116335. * @param gradient defines the gradient to use (between 0 and 1)
  116336. * @param factor defines the size factor to affect to the specified gradient
  116337. * @returns the current particle system
  116338. */
  116339. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  116340. /**
  116341. * Remove a specific size gradient
  116342. * @param gradient defines the gradient to remove
  116343. * @returns the current particle system
  116344. */
  116345. removeSizeGradient(gradient: number): GPUParticleSystem;
  116346. /**
  116347. * Adds a new angular speed gradient
  116348. * @param gradient defines the gradient to use (between 0 and 1)
  116349. * @param factor defines the angular speed to affect to the specified gradient
  116350. * @returns the current particle system
  116351. */
  116352. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  116353. /**
  116354. * Remove a specific angular speed gradient
  116355. * @param gradient defines the gradient to remove
  116356. * @returns the current particle system
  116357. */
  116358. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  116359. /**
  116360. * Adds a new velocity gradient
  116361. * @param gradient defines the gradient to use (between 0 and 1)
  116362. * @param factor defines the velocity to affect to the specified gradient
  116363. * @returns the current particle system
  116364. */
  116365. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116366. /**
  116367. * Remove a specific velocity gradient
  116368. * @param gradient defines the gradient to remove
  116369. * @returns the current particle system
  116370. */
  116371. removeVelocityGradient(gradient: number): GPUParticleSystem;
  116372. /**
  116373. * Adds a new limit velocity gradient
  116374. * @param gradient defines the gradient to use (between 0 and 1)
  116375. * @param factor defines the limit velocity value to affect to the specified gradient
  116376. * @returns the current particle system
  116377. */
  116378. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116379. /**
  116380. * Remove a specific limit velocity gradient
  116381. * @param gradient defines the gradient to remove
  116382. * @returns the current particle system
  116383. */
  116384. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  116385. /**
  116386. * Adds a new drag gradient
  116387. * @param gradient defines the gradient to use (between 0 and 1)
  116388. * @param factor defines the drag value to affect to the specified gradient
  116389. * @returns the current particle system
  116390. */
  116391. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  116392. /**
  116393. * Remove a specific drag gradient
  116394. * @param gradient defines the gradient to remove
  116395. * @returns the current particle system
  116396. */
  116397. removeDragGradient(gradient: number): GPUParticleSystem;
  116398. /**
  116399. * Not supported by GPUParticleSystem
  116400. * @param gradient defines the gradient to use (between 0 and 1)
  116401. * @param factor defines the emit rate value to affect to the specified gradient
  116402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116403. * @returns the current particle system
  116404. */
  116405. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116406. /**
  116407. * Not supported by GPUParticleSystem
  116408. * @param gradient defines the gradient to remove
  116409. * @returns the current particle system
  116410. */
  116411. removeEmitRateGradient(gradient: number): IParticleSystem;
  116412. /**
  116413. * Not supported by GPUParticleSystem
  116414. * @param gradient defines the gradient to use (between 0 and 1)
  116415. * @param factor defines the start size value to affect to the specified gradient
  116416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116417. * @returns the current particle system
  116418. */
  116419. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116420. /**
  116421. * Not supported by GPUParticleSystem
  116422. * @param gradient defines the gradient to remove
  116423. * @returns the current particle system
  116424. */
  116425. removeStartSizeGradient(gradient: number): IParticleSystem;
  116426. /**
  116427. * Not supported by GPUParticleSystem
  116428. * @param gradient defines the gradient to use (between 0 and 1)
  116429. * @param min defines the color remap minimal range
  116430. * @param max defines the color remap maximal range
  116431. * @returns the current particle system
  116432. */
  116433. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116434. /**
  116435. * Not supported by GPUParticleSystem
  116436. * @param gradient defines the gradient to remove
  116437. * @returns the current particle system
  116438. */
  116439. removeColorRemapGradient(): IParticleSystem;
  116440. /**
  116441. * Not supported by GPUParticleSystem
  116442. * @param gradient defines the gradient to use (between 0 and 1)
  116443. * @param min defines the alpha remap minimal range
  116444. * @param max defines the alpha remap maximal range
  116445. * @returns the current particle system
  116446. */
  116447. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116448. /**
  116449. * Not supported by GPUParticleSystem
  116450. * @param gradient defines the gradient to remove
  116451. * @returns the current particle system
  116452. */
  116453. removeAlphaRemapGradient(): IParticleSystem;
  116454. /**
  116455. * Not supported by GPUParticleSystem
  116456. * @param gradient defines the gradient to use (between 0 and 1)
  116457. * @param color defines the color to affect to the specified gradient
  116458. * @returns the current particle system
  116459. */
  116460. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  116461. /**
  116462. * Not supported by GPUParticleSystem
  116463. * @param gradient defines the gradient to remove
  116464. * @returns the current particle system
  116465. */
  116466. removeRampGradient(): IParticleSystem;
  116467. /**
  116468. * Not supported by GPUParticleSystem
  116469. * @returns the list of ramp gradients
  116470. */
  116471. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116472. /**
  116473. * Not supported by GPUParticleSystem
  116474. * Gets or sets a boolean indicating that ramp gradients must be used
  116475. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116476. */
  116477. useRampGradients: boolean;
  116478. /**
  116479. * Not supported by GPUParticleSystem
  116480. * @param gradient defines the gradient to use (between 0 and 1)
  116481. * @param factor defines the life time factor to affect to the specified gradient
  116482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116483. * @returns the current particle system
  116484. */
  116485. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116486. /**
  116487. * Not supported by GPUParticleSystem
  116488. * @param gradient defines the gradient to remove
  116489. * @returns the current particle system
  116490. */
  116491. removeLifeTimeGradient(gradient: number): IParticleSystem;
  116492. /**
  116493. * Instantiates a GPU particle system.
  116494. * 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.
  116495. * @param name The name of the particle system
  116496. * @param options The options used to create the system
  116497. * @param scene The scene the particle system belongs to
  116498. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  116499. */
  116500. constructor(name: string, options: Partial<{
  116501. capacity: number;
  116502. randomTextureSize: number;
  116503. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  116504. protected _reset(): void;
  116505. private _createUpdateVAO;
  116506. private _createRenderVAO;
  116507. private _initialize;
  116508. /** @hidden */
  116509. _recreateUpdateEffect(): void;
  116510. /** @hidden */
  116511. _recreateRenderEffect(): void;
  116512. /**
  116513. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  116514. * @param preWarm defines if we are in the pre-warmimg phase
  116515. */
  116516. animate(preWarm?: boolean): void;
  116517. private _createFactorGradientTexture;
  116518. private _createSizeGradientTexture;
  116519. private _createAngularSpeedGradientTexture;
  116520. private _createVelocityGradientTexture;
  116521. private _createLimitVelocityGradientTexture;
  116522. private _createDragGradientTexture;
  116523. private _createColorGradientTexture;
  116524. /**
  116525. * Renders the particle system in its current state
  116526. * @param preWarm defines if the system should only update the particles but not render them
  116527. * @returns the current number of particles
  116528. */
  116529. render(preWarm?: boolean): number;
  116530. /**
  116531. * Rebuilds the particle system
  116532. */
  116533. rebuild(): void;
  116534. private _releaseBuffers;
  116535. private _releaseVAOs;
  116536. /**
  116537. * Disposes the particle system and free the associated resources
  116538. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  116539. */
  116540. dispose(disposeTexture?: boolean): void;
  116541. /**
  116542. * Clones the particle system.
  116543. * @param name The name of the cloned object
  116544. * @param newEmitter The new emitter to use
  116545. * @returns the cloned particle system
  116546. */
  116547. clone(name: string, newEmitter: any): GPUParticleSystem;
  116548. /**
  116549. * Serializes the particle system to a JSON object.
  116550. * @returns the JSON object
  116551. */
  116552. serialize(): any;
  116553. /**
  116554. * Parses a JSON object to create a GPU particle system.
  116555. * @param parsedParticleSystem The JSON object to parse
  116556. * @param scene The scene to create the particle system in
  116557. * @param rootUrl The root url to use to load external dependencies like texture
  116558. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  116559. * @returns the parsed GPU particle system
  116560. */
  116561. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  116562. }
  116563. }
  116564. declare module BABYLON {
  116565. /**
  116566. * Represents a set of particle systems working together to create a specific effect
  116567. */
  116568. export class ParticleSystemSet implements IDisposable {
  116569. private _emitterCreationOptions;
  116570. private _emitterNode;
  116571. /**
  116572. * Gets the particle system list
  116573. */
  116574. systems: IParticleSystem[];
  116575. /**
  116576. * Gets the emitter node used with this set
  116577. */
  116578. readonly emitterNode: Nullable<TransformNode>;
  116579. /**
  116580. * Creates a new emitter mesh as a sphere
  116581. * @param options defines the options used to create the sphere
  116582. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  116583. * @param scene defines the hosting scene
  116584. */
  116585. setEmitterAsSphere(options: {
  116586. diameter: number;
  116587. segments: number;
  116588. color: Color3;
  116589. }, renderingGroupId: number, scene: Scene): void;
  116590. /**
  116591. * Starts all particle systems of the set
  116592. * @param emitter defines an optional mesh to use as emitter for the particle systems
  116593. */
  116594. start(emitter?: AbstractMesh): void;
  116595. /**
  116596. * Release all associated resources
  116597. */
  116598. dispose(): void;
  116599. /**
  116600. * Serialize the set into a JSON compatible object
  116601. * @returns a JSON compatible representation of the set
  116602. */
  116603. serialize(): any;
  116604. /**
  116605. * Parse a new ParticleSystemSet from a serialized source
  116606. * @param data defines a JSON compatible representation of the set
  116607. * @param scene defines the hosting scene
  116608. * @param gpu defines if we want GPU particles or CPU particles
  116609. * @returns a new ParticleSystemSet
  116610. */
  116611. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  116612. }
  116613. }
  116614. declare module BABYLON {
  116615. /**
  116616. * This class is made for on one-liner static method to help creating particle system set.
  116617. */
  116618. export class ParticleHelper {
  116619. /**
  116620. * Gets or sets base Assets URL
  116621. */
  116622. static BaseAssetsUrl: string;
  116623. /**
  116624. * Create a default particle system that you can tweak
  116625. * @param emitter defines the emitter to use
  116626. * @param capacity defines the system capacity (default is 500 particles)
  116627. * @param scene defines the hosting scene
  116628. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  116629. * @returns the new Particle system
  116630. */
  116631. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  116632. /**
  116633. * This is the main static method (one-liner) of this helper to create different particle systems
  116634. * @param type This string represents the type to the particle system to create
  116635. * @param scene The scene where the particle system should live
  116636. * @param gpu If the system will use gpu
  116637. * @returns the ParticleSystemSet created
  116638. */
  116639. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  116640. /**
  116641. * Static function used to export a particle system to a ParticleSystemSet variable.
  116642. * Please note that the emitter shape is not exported
  116643. * @param systems defines the particle systems to export
  116644. * @returns the created particle system set
  116645. */
  116646. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  116647. }
  116648. }
  116649. declare module BABYLON {
  116650. interface Engine {
  116651. /**
  116652. * Create an effect to use with particle systems.
  116653. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  116654. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  116655. * @param uniformsNames defines a list of attribute names
  116656. * @param samplers defines an array of string used to represent textures
  116657. * @param defines defines the string containing the defines to use to compile the shaders
  116658. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116659. * @param onCompiled defines a function to call when the effect creation is successful
  116660. * @param onError defines a function to call when the effect creation has failed
  116661. * @returns the new Effect
  116662. */
  116663. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  116664. }
  116665. interface Mesh {
  116666. /**
  116667. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  116668. * @returns an array of IParticleSystem
  116669. */
  116670. getEmittedParticleSystems(): IParticleSystem[];
  116671. /**
  116672. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  116673. * @returns an array of IParticleSystem
  116674. */
  116675. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  116676. }
  116677. /**
  116678. * @hidden
  116679. */
  116680. export var _IDoNeedToBeInTheBuild: number;
  116681. }
  116682. declare module BABYLON {
  116683. interface Scene {
  116684. /** @hidden (Backing field) */
  116685. _physicsEngine: Nullable<IPhysicsEngine>;
  116686. /**
  116687. * Gets the current physics engine
  116688. * @returns a IPhysicsEngine or null if none attached
  116689. */
  116690. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  116691. /**
  116692. * Enables physics to the current scene
  116693. * @param gravity defines the scene's gravity for the physics engine
  116694. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116695. * @return a boolean indicating if the physics engine was initialized
  116696. */
  116697. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  116698. /**
  116699. * Disables and disposes the physics engine associated with the scene
  116700. */
  116701. disablePhysicsEngine(): void;
  116702. /**
  116703. * Gets a boolean indicating if there is an active physics engine
  116704. * @returns a boolean indicating if there is an active physics engine
  116705. */
  116706. isPhysicsEnabled(): boolean;
  116707. /**
  116708. * Deletes a physics compound impostor
  116709. * @param compound defines the compound to delete
  116710. */
  116711. deleteCompoundImpostor(compound: any): void;
  116712. /**
  116713. * An event triggered when physic simulation is about to be run
  116714. */
  116715. onBeforePhysicsObservable: Observable<Scene>;
  116716. /**
  116717. * An event triggered when physic simulation has been done
  116718. */
  116719. onAfterPhysicsObservable: Observable<Scene>;
  116720. }
  116721. interface AbstractMesh {
  116722. /** @hidden */
  116723. _physicsImpostor: Nullable<PhysicsImpostor>;
  116724. /**
  116725. * Gets or sets impostor used for physic simulation
  116726. * @see http://doc.babylonjs.com/features/physics_engine
  116727. */
  116728. physicsImpostor: Nullable<PhysicsImpostor>;
  116729. /**
  116730. * Gets the current physics impostor
  116731. * @see http://doc.babylonjs.com/features/physics_engine
  116732. * @returns a physics impostor or null
  116733. */
  116734. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  116735. /** Apply a physic impulse to the mesh
  116736. * @param force defines the force to apply
  116737. * @param contactPoint defines where to apply the force
  116738. * @returns the current mesh
  116739. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116740. */
  116741. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  116742. /**
  116743. * Creates a physic joint between two meshes
  116744. * @param otherMesh defines the other mesh to use
  116745. * @param pivot1 defines the pivot to use on this mesh
  116746. * @param pivot2 defines the pivot to use on the other mesh
  116747. * @param options defines additional options (can be plugin dependent)
  116748. * @returns the current mesh
  116749. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116750. */
  116751. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  116752. /** @hidden */
  116753. _disposePhysicsObserver: Nullable<Observer<Node>>;
  116754. }
  116755. /**
  116756. * Defines the physics engine scene component responsible to manage a physics engine
  116757. */
  116758. export class PhysicsEngineSceneComponent implements ISceneComponent {
  116759. /**
  116760. * The component name helpful to identify the component in the list of scene components.
  116761. */
  116762. readonly name: string;
  116763. /**
  116764. * The scene the component belongs to.
  116765. */
  116766. scene: Scene;
  116767. /**
  116768. * Creates a new instance of the component for the given scene
  116769. * @param scene Defines the scene to register the component in
  116770. */
  116771. constructor(scene: Scene);
  116772. /**
  116773. * Registers the component in a given scene
  116774. */
  116775. register(): void;
  116776. /**
  116777. * Rebuilds the elements related to this component in case of
  116778. * context lost for instance.
  116779. */
  116780. rebuild(): void;
  116781. /**
  116782. * Disposes the component and the associated ressources
  116783. */
  116784. dispose(): void;
  116785. }
  116786. }
  116787. declare module BABYLON {
  116788. /**
  116789. * A helper for physics simulations
  116790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116791. */
  116792. export class PhysicsHelper {
  116793. private _scene;
  116794. private _physicsEngine;
  116795. /**
  116796. * Initializes the Physics helper
  116797. * @param scene Babylon.js scene
  116798. */
  116799. constructor(scene: Scene);
  116800. /**
  116801. * Applies a radial explosion impulse
  116802. * @param origin the origin of the explosion
  116803. * @param radiusOrEventOptions the radius or the options of radial explosion
  116804. * @param strength the explosion strength
  116805. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116806. * @returns A physics radial explosion event, or null
  116807. */
  116808. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116809. /**
  116810. * Applies a radial explosion force
  116811. * @param origin the origin of the explosion
  116812. * @param radiusOrEventOptions the radius or the options of radial explosion
  116813. * @param strength the explosion strength
  116814. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116815. * @returns A physics radial explosion event, or null
  116816. */
  116817. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116818. /**
  116819. * Creates a gravitational field
  116820. * @param origin the origin of the explosion
  116821. * @param radiusOrEventOptions the radius or the options of radial explosion
  116822. * @param strength the explosion strength
  116823. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116824. * @returns A physics gravitational field event, or null
  116825. */
  116826. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  116827. /**
  116828. * Creates a physics updraft event
  116829. * @param origin the origin of the updraft
  116830. * @param radiusOrEventOptions the radius or the options of the updraft
  116831. * @param strength the strength of the updraft
  116832. * @param height the height of the updraft
  116833. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  116834. * @returns A physics updraft event, or null
  116835. */
  116836. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  116837. /**
  116838. * Creates a physics vortex event
  116839. * @param origin the of the vortex
  116840. * @param radiusOrEventOptions the radius or the options of the vortex
  116841. * @param strength the strength of the vortex
  116842. * @param height the height of the vortex
  116843. * @returns a Physics vortex event, or null
  116844. * A physics vortex event or null
  116845. */
  116846. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  116847. }
  116848. /**
  116849. * Represents a physics radial explosion event
  116850. */
  116851. class PhysicsRadialExplosionEvent {
  116852. private _scene;
  116853. private _options;
  116854. private _sphere;
  116855. private _dataFetched;
  116856. /**
  116857. * Initializes a radial explosioin event
  116858. * @param _scene BabylonJS scene
  116859. * @param _options The options for the vortex event
  116860. */
  116861. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  116862. /**
  116863. * Returns the data related to the radial explosion event (sphere).
  116864. * @returns The radial explosion event data
  116865. */
  116866. getData(): PhysicsRadialExplosionEventData;
  116867. /**
  116868. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116869. * @param impostor A physics imposter
  116870. * @param origin the origin of the explosion
  116871. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116872. */
  116873. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  116874. /**
  116875. * Triggers affecterd impostors callbacks
  116876. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116877. */
  116878. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  116879. /**
  116880. * Disposes the sphere.
  116881. * @param force Specifies if the sphere should be disposed by force
  116882. */
  116883. dispose(force?: boolean): void;
  116884. /*** Helpers ***/
  116885. private _prepareSphere;
  116886. private _intersectsWithSphere;
  116887. }
  116888. /**
  116889. * Represents a gravitational field event
  116890. */
  116891. class PhysicsGravitationalFieldEvent {
  116892. private _physicsHelper;
  116893. private _scene;
  116894. private _origin;
  116895. private _options;
  116896. private _tickCallback;
  116897. private _sphere;
  116898. private _dataFetched;
  116899. /**
  116900. * Initializes the physics gravitational field event
  116901. * @param _physicsHelper A physics helper
  116902. * @param _scene BabylonJS scene
  116903. * @param _origin The origin position of the gravitational field event
  116904. * @param _options The options for the vortex event
  116905. */
  116906. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  116907. /**
  116908. * Returns the data related to the gravitational field event (sphere).
  116909. * @returns A gravitational field event
  116910. */
  116911. getData(): PhysicsGravitationalFieldEventData;
  116912. /**
  116913. * Enables the gravitational field.
  116914. */
  116915. enable(): void;
  116916. /**
  116917. * Disables the gravitational field.
  116918. */
  116919. disable(): void;
  116920. /**
  116921. * Disposes the sphere.
  116922. * @param force The force to dispose from the gravitational field event
  116923. */
  116924. dispose(force?: boolean): void;
  116925. private _tick;
  116926. }
  116927. /**
  116928. * Represents a physics updraft event
  116929. */
  116930. class PhysicsUpdraftEvent {
  116931. private _scene;
  116932. private _origin;
  116933. private _options;
  116934. private _physicsEngine;
  116935. private _originTop;
  116936. private _originDirection;
  116937. private _tickCallback;
  116938. private _cylinder;
  116939. private _cylinderPosition;
  116940. private _dataFetched;
  116941. /**
  116942. * Initializes the physics updraft event
  116943. * @param _scene BabylonJS scene
  116944. * @param _origin The origin position of the updraft
  116945. * @param _options The options for the updraft event
  116946. */
  116947. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  116948. /**
  116949. * Returns the data related to the updraft event (cylinder).
  116950. * @returns A physics updraft event
  116951. */
  116952. getData(): PhysicsUpdraftEventData;
  116953. /**
  116954. * Enables the updraft.
  116955. */
  116956. enable(): void;
  116957. /**
  116958. * Disables the updraft.
  116959. */
  116960. disable(): void;
  116961. /**
  116962. * Disposes the cylinder.
  116963. * @param force Specifies if the updraft should be disposed by force
  116964. */
  116965. dispose(force?: boolean): void;
  116966. private getImpostorHitData;
  116967. private _tick;
  116968. /*** Helpers ***/
  116969. private _prepareCylinder;
  116970. private _intersectsWithCylinder;
  116971. }
  116972. /**
  116973. * Represents a physics vortex event
  116974. */
  116975. class PhysicsVortexEvent {
  116976. private _scene;
  116977. private _origin;
  116978. private _options;
  116979. private _physicsEngine;
  116980. private _originTop;
  116981. private _tickCallback;
  116982. private _cylinder;
  116983. private _cylinderPosition;
  116984. private _dataFetched;
  116985. /**
  116986. * Initializes the physics vortex event
  116987. * @param _scene The BabylonJS scene
  116988. * @param _origin The origin position of the vortex
  116989. * @param _options The options for the vortex event
  116990. */
  116991. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  116992. /**
  116993. * Returns the data related to the vortex event (cylinder).
  116994. * @returns The physics vortex event data
  116995. */
  116996. getData(): PhysicsVortexEventData;
  116997. /**
  116998. * Enables the vortex.
  116999. */
  117000. enable(): void;
  117001. /**
  117002. * Disables the cortex.
  117003. */
  117004. disable(): void;
  117005. /**
  117006. * Disposes the sphere.
  117007. * @param force
  117008. */
  117009. dispose(force?: boolean): void;
  117010. private getImpostorHitData;
  117011. private _tick;
  117012. /*** Helpers ***/
  117013. private _prepareCylinder;
  117014. private _intersectsWithCylinder;
  117015. }
  117016. /**
  117017. * Options fot the radial explosion event
  117018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117019. */
  117020. export class PhysicsRadialExplosionEventOptions {
  117021. /**
  117022. * The radius of the sphere for the radial explosion.
  117023. */
  117024. radius: number;
  117025. /**
  117026. * The strenth of the explosion.
  117027. */
  117028. strength: number;
  117029. /**
  117030. * The strenght of the force in correspondence to the distance of the affected object
  117031. */
  117032. falloff: PhysicsRadialImpulseFalloff;
  117033. /**
  117034. * Sphere options for the radial explosion.
  117035. */
  117036. sphere: {
  117037. segments: number;
  117038. diameter: number;
  117039. };
  117040. /**
  117041. * Sphere options for the radial explosion.
  117042. */
  117043. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117044. }
  117045. /**
  117046. * Options fot the updraft event
  117047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117048. */
  117049. export class PhysicsUpdraftEventOptions {
  117050. /**
  117051. * The radius of the cylinder for the vortex
  117052. */
  117053. radius: number;
  117054. /**
  117055. * The strenth of the updraft.
  117056. */
  117057. strength: number;
  117058. /**
  117059. * The height of the cylinder for the updraft.
  117060. */
  117061. height: number;
  117062. /**
  117063. * The mode for the the updraft.
  117064. */
  117065. updraftMode: PhysicsUpdraftMode;
  117066. }
  117067. /**
  117068. * Options fot the vortex event
  117069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117070. */
  117071. export class PhysicsVortexEventOptions {
  117072. /**
  117073. * The radius of the cylinder for the vortex
  117074. */
  117075. radius: number;
  117076. /**
  117077. * The strenth of the vortex.
  117078. */
  117079. strength: number;
  117080. /**
  117081. * The height of the cylinder for the vortex.
  117082. */
  117083. height: number;
  117084. /**
  117085. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117086. */
  117087. centripetalForceThreshold: number;
  117088. /**
  117089. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117090. */
  117091. centripetalForceMultiplier: number;
  117092. /**
  117093. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117094. */
  117095. centrifugalForceMultiplier: number;
  117096. /**
  117097. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117098. */
  117099. updraftForceMultiplier: number;
  117100. }
  117101. /**
  117102. * The strenght of the force in correspondence to the distance of the affected object
  117103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117104. */
  117105. export enum PhysicsRadialImpulseFalloff {
  117106. /** Defines that impulse is constant in strength across it's whole radius */
  117107. Constant = 0,
  117108. /** Defines that impulse gets weaker if it's further from the origin */
  117109. Linear = 1
  117110. }
  117111. /**
  117112. * The strength of the force in correspondence to the distance of the affected object
  117113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117114. */
  117115. export enum PhysicsUpdraftMode {
  117116. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117117. Center = 0,
  117118. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117119. Perpendicular = 1
  117120. }
  117121. /**
  117122. * Interface for a physics hit data
  117123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117124. */
  117125. export interface PhysicsHitData {
  117126. /**
  117127. * The force applied at the contact point
  117128. */
  117129. force: Vector3;
  117130. /**
  117131. * The contact point
  117132. */
  117133. contactPoint: Vector3;
  117134. /**
  117135. * The distance from the origin to the contact point
  117136. */
  117137. distanceFromOrigin: number;
  117138. }
  117139. /**
  117140. * Interface for radial explosion event data
  117141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117142. */
  117143. export interface PhysicsRadialExplosionEventData {
  117144. /**
  117145. * A sphere used for the radial explosion event
  117146. */
  117147. sphere: Mesh;
  117148. }
  117149. /**
  117150. * Interface for gravitational field event data
  117151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117152. */
  117153. export interface PhysicsGravitationalFieldEventData {
  117154. /**
  117155. * A sphere mesh used for the gravitational field event
  117156. */
  117157. sphere: Mesh;
  117158. }
  117159. /**
  117160. * Interface for updraft event data
  117161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117162. */
  117163. export interface PhysicsUpdraftEventData {
  117164. /**
  117165. * A cylinder used for the updraft event
  117166. */
  117167. cylinder: Mesh;
  117168. }
  117169. /**
  117170. * Interface for vortex event data
  117171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117172. */
  117173. export interface PhysicsVortexEventData {
  117174. /**
  117175. * A cylinder used for the vortex event
  117176. */
  117177. cylinder: Mesh;
  117178. }
  117179. /**
  117180. * Interface for an affected physics impostor
  117181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117182. */
  117183. export interface PhysicsAffectedImpostorWithData {
  117184. /**
  117185. * The impostor affected by the effect
  117186. */
  117187. impostor: PhysicsImpostor;
  117188. /**
  117189. * The data about the hit/horce from the explosion
  117190. */
  117191. hitData: PhysicsHitData;
  117192. }
  117193. }
  117194. declare module BABYLON {
  117195. /** @hidden */
  117196. export var blackAndWhitePixelShader: {
  117197. name: string;
  117198. shader: string;
  117199. };
  117200. }
  117201. declare module BABYLON {
  117202. /**
  117203. * Post process used to render in black and white
  117204. */
  117205. export class BlackAndWhitePostProcess extends PostProcess {
  117206. /**
  117207. * Linear about to convert he result to black and white (default: 1)
  117208. */
  117209. degree: number;
  117210. /**
  117211. * Creates a black and white post process
  117212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117213. * @param name The name of the effect.
  117214. * @param options The required width/height ratio to downsize to before computing the render pass.
  117215. * @param camera The camera to apply the render pass to.
  117216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117217. * @param engine The engine which the post process will be applied. (default: current engine)
  117218. * @param reusable If the post process can be reused on the same frame. (default: false)
  117219. */
  117220. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117221. }
  117222. }
  117223. declare module BABYLON {
  117224. /**
  117225. * This represents a set of one or more post processes in Babylon.
  117226. * A post process can be used to apply a shader to a texture after it is rendered.
  117227. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117228. */
  117229. export class PostProcessRenderEffect {
  117230. private _postProcesses;
  117231. private _getPostProcesses;
  117232. private _singleInstance;
  117233. private _cameras;
  117234. private _indicesForCamera;
  117235. /**
  117236. * Name of the effect
  117237. * @hidden
  117238. */
  117239. _name: string;
  117240. /**
  117241. * Instantiates a post process render effect.
  117242. * A post process can be used to apply a shader to a texture after it is rendered.
  117243. * @param engine The engine the effect is tied to
  117244. * @param name The name of the effect
  117245. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117246. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117247. */
  117248. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117249. /**
  117250. * Checks if all the post processes in the effect are supported.
  117251. */
  117252. readonly isSupported: boolean;
  117253. /**
  117254. * Updates the current state of the effect
  117255. * @hidden
  117256. */
  117257. _update(): void;
  117258. /**
  117259. * Attaches the effect on cameras
  117260. * @param cameras The camera to attach to.
  117261. * @hidden
  117262. */
  117263. _attachCameras(cameras: Camera): void;
  117264. /**
  117265. * Attaches the effect on cameras
  117266. * @param cameras The camera to attach to.
  117267. * @hidden
  117268. */
  117269. _attachCameras(cameras: Camera[]): void;
  117270. /**
  117271. * Detaches the effect on cameras
  117272. * @param cameras The camera to detatch from.
  117273. * @hidden
  117274. */
  117275. _detachCameras(cameras: Camera): void;
  117276. /**
  117277. * Detatches the effect on cameras
  117278. * @param cameras The camera to detatch from.
  117279. * @hidden
  117280. */
  117281. _detachCameras(cameras: Camera[]): void;
  117282. /**
  117283. * Enables the effect on given cameras
  117284. * @param cameras The camera to enable.
  117285. * @hidden
  117286. */
  117287. _enable(cameras: Camera): void;
  117288. /**
  117289. * Enables the effect on given cameras
  117290. * @param cameras The camera to enable.
  117291. * @hidden
  117292. */
  117293. _enable(cameras: Nullable<Camera[]>): void;
  117294. /**
  117295. * Disables the effect on the given cameras
  117296. * @param cameras The camera to disable.
  117297. * @hidden
  117298. */
  117299. _disable(cameras: Camera): void;
  117300. /**
  117301. * Disables the effect on the given cameras
  117302. * @param cameras The camera to disable.
  117303. * @hidden
  117304. */
  117305. _disable(cameras: Nullable<Camera[]>): void;
  117306. /**
  117307. * Gets a list of the post processes contained in the effect.
  117308. * @param camera The camera to get the post processes on.
  117309. * @returns The list of the post processes in the effect.
  117310. */
  117311. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  117312. }
  117313. }
  117314. declare module BABYLON {
  117315. /** @hidden */
  117316. export var extractHighlightsPixelShader: {
  117317. name: string;
  117318. shader: string;
  117319. };
  117320. }
  117321. declare module BABYLON {
  117322. /**
  117323. * 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.
  117324. */
  117325. export class ExtractHighlightsPostProcess extends PostProcess {
  117326. /**
  117327. * The luminance threshold, pixels below this value will be set to black.
  117328. */
  117329. threshold: number;
  117330. /** @hidden */
  117331. _exposure: number;
  117332. /**
  117333. * Post process which has the input texture to be used when performing highlight extraction
  117334. * @hidden
  117335. */
  117336. _inputPostProcess: Nullable<PostProcess>;
  117337. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117338. }
  117339. }
  117340. declare module BABYLON {
  117341. /** @hidden */
  117342. export var bloomMergePixelShader: {
  117343. name: string;
  117344. shader: string;
  117345. };
  117346. }
  117347. declare module BABYLON {
  117348. /**
  117349. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117350. */
  117351. export class BloomMergePostProcess extends PostProcess {
  117352. /** Weight of the bloom to be added to the original input. */
  117353. weight: number;
  117354. /**
  117355. * Creates a new instance of @see BloomMergePostProcess
  117356. * @param name The name of the effect.
  117357. * @param originalFromInput Post process which's input will be used for the merge.
  117358. * @param blurred Blurred highlights post process which's output will be used.
  117359. * @param weight Weight of the bloom to be added to the original input.
  117360. * @param options The required width/height ratio to downsize to before computing the render pass.
  117361. * @param camera The camera to apply the render pass to.
  117362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117363. * @param engine The engine which the post process will be applied. (default: current engine)
  117364. * @param reusable If the post process can be reused on the same frame. (default: false)
  117365. * @param textureType Type of textures used when performing the post process. (default: 0)
  117366. * @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)
  117367. */
  117368. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  117369. /** Weight of the bloom to be added to the original input. */
  117370. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117371. }
  117372. }
  117373. declare module BABYLON {
  117374. /**
  117375. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  117376. */
  117377. export class BloomEffect extends PostProcessRenderEffect {
  117378. private bloomScale;
  117379. /**
  117380. * @hidden Internal
  117381. */
  117382. _effects: Array<PostProcess>;
  117383. /**
  117384. * @hidden Internal
  117385. */
  117386. _downscale: ExtractHighlightsPostProcess;
  117387. private _blurX;
  117388. private _blurY;
  117389. private _merge;
  117390. /**
  117391. * The luminance threshold to find bright areas of the image to bloom.
  117392. */
  117393. threshold: number;
  117394. /**
  117395. * The strength of the bloom.
  117396. */
  117397. weight: number;
  117398. /**
  117399. * Specifies the size of the bloom blur kernel, relative to the final output size
  117400. */
  117401. kernel: number;
  117402. /**
  117403. * Creates a new instance of @see BloomEffect
  117404. * @param scene The scene the effect belongs to.
  117405. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  117406. * @param bloomKernel The size of the kernel to be used when applying the blur.
  117407. * @param bloomWeight The the strength of bloom.
  117408. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117409. * @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)
  117410. */
  117411. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  117412. /**
  117413. * Disposes each of the internal effects for a given camera.
  117414. * @param camera The camera to dispose the effect on.
  117415. */
  117416. disposeEffects(camera: Camera): void;
  117417. /**
  117418. * @hidden Internal
  117419. */
  117420. _updateEffects(): void;
  117421. /**
  117422. * Internal
  117423. * @returns if all the contained post processes are ready.
  117424. * @hidden
  117425. */
  117426. _isReady(): boolean;
  117427. }
  117428. }
  117429. declare module BABYLON {
  117430. /** @hidden */
  117431. export var chromaticAberrationPixelShader: {
  117432. name: string;
  117433. shader: string;
  117434. };
  117435. }
  117436. declare module BABYLON {
  117437. /**
  117438. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117439. */
  117440. export class ChromaticAberrationPostProcess extends PostProcess {
  117441. /**
  117442. * The amount of seperation of rgb channels (default: 30)
  117443. */
  117444. aberrationAmount: number;
  117445. /**
  117446. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117447. */
  117448. radialIntensity: number;
  117449. /**
  117450. * 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))
  117451. */
  117452. direction: Vector2;
  117453. /**
  117454. * 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))
  117455. */
  117456. centerPosition: Vector2;
  117457. /**
  117458. * Creates a new instance ChromaticAberrationPostProcess
  117459. * @param name The name of the effect.
  117460. * @param screenWidth The width of the screen to apply the effect on.
  117461. * @param screenHeight The height of the screen to apply the effect on.
  117462. * @param options The required width/height ratio to downsize to before computing the render pass.
  117463. * @param camera The camera to apply the render pass to.
  117464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117465. * @param engine The engine which the post process will be applied. (default: current engine)
  117466. * @param reusable If the post process can be reused on the same frame. (default: false)
  117467. * @param textureType Type of textures used when performing the post process. (default: 0)
  117468. * @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)
  117469. */
  117470. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117471. }
  117472. }
  117473. declare module BABYLON {
  117474. /** @hidden */
  117475. export var circleOfConfusionPixelShader: {
  117476. name: string;
  117477. shader: string;
  117478. };
  117479. }
  117480. declare module BABYLON {
  117481. /**
  117482. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117483. */
  117484. export class CircleOfConfusionPostProcess extends PostProcess {
  117485. /**
  117486. * 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.
  117487. */
  117488. lensSize: number;
  117489. /**
  117490. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117491. */
  117492. fStop: number;
  117493. /**
  117494. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117495. */
  117496. focusDistance: number;
  117497. /**
  117498. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117499. */
  117500. focalLength: number;
  117501. private _depthTexture;
  117502. /**
  117503. * Creates a new instance CircleOfConfusionPostProcess
  117504. * @param name The name of the effect.
  117505. * @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.
  117506. * @param options The required width/height ratio to downsize to before computing the render pass.
  117507. * @param camera The camera to apply the render pass to.
  117508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117509. * @param engine The engine which the post process will be applied. (default: current engine)
  117510. * @param reusable If the post process can be reused on the same frame. (default: false)
  117511. * @param textureType Type of textures used when performing the post process. (default: 0)
  117512. * @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)
  117513. */
  117514. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117515. /**
  117516. * 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.
  117517. */
  117518. depthTexture: RenderTargetTexture;
  117519. }
  117520. }
  117521. declare module BABYLON {
  117522. /** @hidden */
  117523. export var colorCorrectionPixelShader: {
  117524. name: string;
  117525. shader: string;
  117526. };
  117527. }
  117528. declare module BABYLON {
  117529. /**
  117530. *
  117531. * This post-process allows the modification of rendered colors by using
  117532. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117533. *
  117534. * The object needs to be provided an url to a texture containing the color
  117535. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117536. * Use an image editing software to tweak the LUT to match your needs.
  117537. *
  117538. * For an example of a color LUT, see here:
  117539. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117540. * For explanations on color grading, see here:
  117541. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117542. *
  117543. */
  117544. export class ColorCorrectionPostProcess extends PostProcess {
  117545. private _colorTableTexture;
  117546. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117547. }
  117548. }
  117549. declare module BABYLON {
  117550. /** @hidden */
  117551. export var convolutionPixelShader: {
  117552. name: string;
  117553. shader: string;
  117554. };
  117555. }
  117556. declare module BABYLON {
  117557. /**
  117558. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117559. * input texture to perform effects such as edge detection or sharpening
  117560. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117561. */
  117562. export class ConvolutionPostProcess extends PostProcess {
  117563. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117564. kernel: number[];
  117565. /**
  117566. * Creates a new instance ConvolutionPostProcess
  117567. * @param name The name of the effect.
  117568. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  117569. * @param options The required width/height ratio to downsize to before computing the render pass.
  117570. * @param camera The camera to apply the render pass to.
  117571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117572. * @param engine The engine which the post process will be applied. (default: current engine)
  117573. * @param reusable If the post process can be reused on the same frame. (default: false)
  117574. * @param textureType Type of textures used when performing the post process. (default: 0)
  117575. */
  117576. constructor(name: string,
  117577. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117578. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117579. /**
  117580. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117581. */
  117582. static EdgeDetect0Kernel: number[];
  117583. /**
  117584. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117585. */
  117586. static EdgeDetect1Kernel: number[];
  117587. /**
  117588. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117589. */
  117590. static EdgeDetect2Kernel: number[];
  117591. /**
  117592. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117593. */
  117594. static SharpenKernel: number[];
  117595. /**
  117596. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117597. */
  117598. static EmbossKernel: number[];
  117599. /**
  117600. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117601. */
  117602. static GaussianKernel: number[];
  117603. }
  117604. }
  117605. declare module BABYLON {
  117606. /**
  117607. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117608. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117609. * based on samples that have a large difference in distance than the center pixel.
  117610. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117611. */
  117612. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  117613. direction: Vector2;
  117614. /**
  117615. * Creates a new instance CircleOfConfusionPostProcess
  117616. * @param name The name of the effect.
  117617. * @param scene The scene the effect belongs to.
  117618. * @param direction The direction the blur should be applied.
  117619. * @param kernel The size of the kernel used to blur.
  117620. * @param options The required width/height ratio to downsize to before computing the render pass.
  117621. * @param camera The camera to apply the render pass to.
  117622. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117623. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117625. * @param engine The engine which the post process will be applied. (default: current engine)
  117626. * @param reusable If the post process can be reused on the same frame. (default: false)
  117627. * @param textureType Type of textures used when performing the post process. (default: 0)
  117628. * @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)
  117629. */
  117630. 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);
  117631. }
  117632. }
  117633. declare module BABYLON {
  117634. /** @hidden */
  117635. export var depthOfFieldMergePixelShader: {
  117636. name: string;
  117637. shader: string;
  117638. };
  117639. }
  117640. declare module BABYLON {
  117641. /**
  117642. * Options to be set when merging outputs from the default pipeline.
  117643. */
  117644. export class DepthOfFieldMergePostProcessOptions {
  117645. /**
  117646. * The original image to merge on top of
  117647. */
  117648. originalFromInput: PostProcess;
  117649. /**
  117650. * Parameters to perform the merge of the depth of field effect
  117651. */
  117652. depthOfField?: {
  117653. circleOfConfusion: PostProcess;
  117654. blurSteps: Array<PostProcess>;
  117655. };
  117656. /**
  117657. * Parameters to perform the merge of bloom effect
  117658. */
  117659. bloom?: {
  117660. blurred: PostProcess;
  117661. weight: number;
  117662. };
  117663. }
  117664. /**
  117665. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117666. */
  117667. export class DepthOfFieldMergePostProcess extends PostProcess {
  117668. private blurSteps;
  117669. /**
  117670. * Creates a new instance of DepthOfFieldMergePostProcess
  117671. * @param name The name of the effect.
  117672. * @param originalFromInput Post process which's input will be used for the merge.
  117673. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117674. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117675. * @param options The required width/height ratio to downsize to before computing the render pass.
  117676. * @param camera The camera to apply the render pass to.
  117677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117678. * @param engine The engine which the post process will be applied. (default: current engine)
  117679. * @param reusable If the post process can be reused on the same frame. (default: false)
  117680. * @param textureType Type of textures used when performing the post process. (default: 0)
  117681. * @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)
  117682. */
  117683. 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);
  117684. /**
  117685. * Updates the effect with the current post process compile time values and recompiles the shader.
  117686. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117687. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117688. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117689. * @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
  117690. * @param onCompiled Called when the shader has been compiled.
  117691. * @param onError Called if there is an error when compiling a shader.
  117692. */
  117693. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  117694. }
  117695. }
  117696. declare module BABYLON {
  117697. /**
  117698. * Specifies the level of max blur that should be applied when using the depth of field effect
  117699. */
  117700. export enum DepthOfFieldEffectBlurLevel {
  117701. /**
  117702. * Subtle blur
  117703. */
  117704. Low = 0,
  117705. /**
  117706. * Medium blur
  117707. */
  117708. Medium = 1,
  117709. /**
  117710. * Large blur
  117711. */
  117712. High = 2
  117713. }
  117714. /**
  117715. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117716. */
  117717. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  117718. private _circleOfConfusion;
  117719. /**
  117720. * @hidden Internal, blurs from high to low
  117721. */
  117722. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  117723. private _depthOfFieldBlurY;
  117724. private _dofMerge;
  117725. /**
  117726. * @hidden Internal post processes in depth of field effect
  117727. */
  117728. _effects: Array<PostProcess>;
  117729. /**
  117730. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117731. */
  117732. focalLength: number;
  117733. /**
  117734. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117735. */
  117736. fStop: number;
  117737. /**
  117738. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117739. */
  117740. focusDistance: number;
  117741. /**
  117742. * 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.
  117743. */
  117744. lensSize: number;
  117745. /**
  117746. * Creates a new instance DepthOfFieldEffect
  117747. * @param scene The scene the effect belongs to.
  117748. * @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.
  117749. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117750. * @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)
  117751. */
  117752. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  117753. /**
  117754. * Get the current class name of the current effet
  117755. * @returns "DepthOfFieldEffect"
  117756. */
  117757. getClassName(): string;
  117758. /**
  117759. * 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.
  117760. */
  117761. depthTexture: RenderTargetTexture;
  117762. /**
  117763. * Disposes each of the internal effects for a given camera.
  117764. * @param camera The camera to dispose the effect on.
  117765. */
  117766. disposeEffects(camera: Camera): void;
  117767. /**
  117768. * @hidden Internal
  117769. */
  117770. _updateEffects(): void;
  117771. /**
  117772. * Internal
  117773. * @returns if all the contained post processes are ready.
  117774. * @hidden
  117775. */
  117776. _isReady(): boolean;
  117777. }
  117778. }
  117779. declare module BABYLON {
  117780. /** @hidden */
  117781. export var displayPassPixelShader: {
  117782. name: string;
  117783. shader: string;
  117784. };
  117785. }
  117786. declare module BABYLON {
  117787. /**
  117788. * DisplayPassPostProcess which produces an output the same as it's input
  117789. */
  117790. export class DisplayPassPostProcess extends PostProcess {
  117791. /**
  117792. * Creates the DisplayPassPostProcess
  117793. * @param name The name of the effect.
  117794. * @param options The required width/height ratio to downsize to before computing the render pass.
  117795. * @param camera The camera to apply the render pass to.
  117796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117797. * @param engine The engine which the post process will be applied. (default: current engine)
  117798. * @param reusable If the post process can be reused on the same frame. (default: false)
  117799. */
  117800. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117801. }
  117802. }
  117803. declare module BABYLON {
  117804. /** @hidden */
  117805. export var filterPixelShader: {
  117806. name: string;
  117807. shader: string;
  117808. };
  117809. }
  117810. declare module BABYLON {
  117811. /**
  117812. * Applies a kernel filter to the image
  117813. */
  117814. export class FilterPostProcess extends PostProcess {
  117815. /** The matrix to be applied to the image */
  117816. kernelMatrix: Matrix;
  117817. /**
  117818. *
  117819. * @param name The name of the effect.
  117820. * @param kernelMatrix The matrix to be applied to the image
  117821. * @param options The required width/height ratio to downsize to before computing the render pass.
  117822. * @param camera The camera to apply the render pass to.
  117823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117824. * @param engine The engine which the post process will be applied. (default: current engine)
  117825. * @param reusable If the post process can be reused on the same frame. (default: false)
  117826. */
  117827. constructor(name: string,
  117828. /** The matrix to be applied to the image */
  117829. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117830. }
  117831. }
  117832. declare module BABYLON {
  117833. /** @hidden */
  117834. export var fxaaPixelShader: {
  117835. name: string;
  117836. shader: string;
  117837. };
  117838. }
  117839. declare module BABYLON {
  117840. /** @hidden */
  117841. export var fxaaVertexShader: {
  117842. name: string;
  117843. shader: string;
  117844. };
  117845. }
  117846. declare module BABYLON {
  117847. /**
  117848. * Fxaa post process
  117849. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117850. */
  117851. export class FxaaPostProcess extends PostProcess {
  117852. /** @hidden */
  117853. texelWidth: number;
  117854. /** @hidden */
  117855. texelHeight: number;
  117856. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117857. private _getDefines;
  117858. }
  117859. }
  117860. declare module BABYLON {
  117861. /** @hidden */
  117862. export var grainPixelShader: {
  117863. name: string;
  117864. shader: string;
  117865. };
  117866. }
  117867. declare module BABYLON {
  117868. /**
  117869. * The GrainPostProcess adds noise to the image at mid luminance levels
  117870. */
  117871. export class GrainPostProcess extends PostProcess {
  117872. /**
  117873. * The intensity of the grain added (default: 30)
  117874. */
  117875. intensity: number;
  117876. /**
  117877. * If the grain should be randomized on every frame
  117878. */
  117879. animated: boolean;
  117880. /**
  117881. * Creates a new instance of @see GrainPostProcess
  117882. * @param name The name of the effect.
  117883. * @param options The required width/height ratio to downsize to before computing the render pass.
  117884. * @param camera The camera to apply the render pass to.
  117885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117886. * @param engine The engine which the post process will be applied. (default: current engine)
  117887. * @param reusable If the post process can be reused on the same frame. (default: false)
  117888. * @param textureType Type of textures used when performing the post process. (default: 0)
  117889. * @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)
  117890. */
  117891. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117892. }
  117893. }
  117894. declare module BABYLON {
  117895. /** @hidden */
  117896. export var highlightsPixelShader: {
  117897. name: string;
  117898. shader: string;
  117899. };
  117900. }
  117901. declare module BABYLON {
  117902. /**
  117903. * Extracts highlights from the image
  117904. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117905. */
  117906. export class HighlightsPostProcess extends PostProcess {
  117907. /**
  117908. * Extracts highlights from the image
  117909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117910. * @param name The name of the effect.
  117911. * @param options The required width/height ratio to downsize to before computing the render pass.
  117912. * @param camera The camera to apply the render pass to.
  117913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117914. * @param engine The engine which the post process will be applied. (default: current engine)
  117915. * @param reusable If the post process can be reused on the same frame. (default: false)
  117916. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117917. */
  117918. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117919. }
  117920. }
  117921. declare module BABYLON {
  117922. /** @hidden */
  117923. export var mrtFragmentDeclaration: {
  117924. name: string;
  117925. shader: string;
  117926. };
  117927. }
  117928. declare module BABYLON {
  117929. /** @hidden */
  117930. export var geometryPixelShader: {
  117931. name: string;
  117932. shader: string;
  117933. };
  117934. }
  117935. declare module BABYLON {
  117936. /** @hidden */
  117937. export var geometryVertexShader: {
  117938. name: string;
  117939. shader: string;
  117940. };
  117941. }
  117942. declare module BABYLON {
  117943. /** @hidden */
  117944. interface ISavedTransformationMatrix {
  117945. world: Matrix;
  117946. viewProjection: Matrix;
  117947. }
  117948. /**
  117949. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  117950. */
  117951. export class GeometryBufferRenderer {
  117952. /**
  117953. * Constant used to retrieve the position texture index in the G-Buffer textures array
  117954. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  117955. */
  117956. static readonly POSITION_TEXTURE_TYPE: number;
  117957. /**
  117958. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  117959. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  117960. */
  117961. static readonly VELOCITY_TEXTURE_TYPE: number;
  117962. /**
  117963. * Dictionary used to store the previous transformation matrices of each rendered mesh
  117964. * in order to compute objects velocities when enableVelocity is set to "true"
  117965. * @hidden
  117966. */
  117967. _previousTransformationMatrices: {
  117968. [index: number]: ISavedTransformationMatrix;
  117969. };
  117970. /**
  117971. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  117972. * in order to compute objects velocities when enableVelocity is set to "true"
  117973. * @hidden
  117974. */
  117975. _previousBonesTransformationMatrices: {
  117976. [index: number]: Float32Array;
  117977. };
  117978. /**
  117979. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  117980. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  117981. */
  117982. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  117983. private _scene;
  117984. private _multiRenderTarget;
  117985. private _ratio;
  117986. private _enablePosition;
  117987. private _enableVelocity;
  117988. private _positionIndex;
  117989. private _velocityIndex;
  117990. protected _effect: Effect;
  117991. protected _cachedDefines: string;
  117992. /**
  117993. * Set the render list (meshes to be rendered) used in the G buffer.
  117994. */
  117995. renderList: Mesh[];
  117996. /**
  117997. * Gets wether or not G buffer are supported by the running hardware.
  117998. * This requires draw buffer supports
  117999. */
  118000. readonly isSupported: boolean;
  118001. /**
  118002. * Returns the index of the given texture type in the G-Buffer textures array
  118003. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118004. * @returns the index of the given texture type in the G-Buffer textures array
  118005. */
  118006. getTextureIndex(textureType: number): number;
  118007. /**
  118008. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118009. */
  118010. /**
  118011. * Sets whether or not objects positions are enabled for the G buffer.
  118012. */
  118013. enablePosition: boolean;
  118014. /**
  118015. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118016. */
  118017. /**
  118018. * Sets wether or not objects velocities are enabled for the G buffer.
  118019. */
  118020. enableVelocity: boolean;
  118021. /**
  118022. * Gets the scene associated with the buffer.
  118023. */
  118024. readonly scene: Scene;
  118025. /**
  118026. * Gets the ratio used by the buffer during its creation.
  118027. * How big is the buffer related to the main canvas.
  118028. */
  118029. readonly ratio: number;
  118030. /** @hidden */
  118031. static _SceneComponentInitialization: (scene: Scene) => void;
  118032. /**
  118033. * Creates a new G Buffer for the scene
  118034. * @param scene The scene the buffer belongs to
  118035. * @param ratio How big is the buffer related to the main canvas.
  118036. */
  118037. constructor(scene: Scene, ratio?: number);
  118038. /**
  118039. * Checks wether everything is ready to render a submesh to the G buffer.
  118040. * @param subMesh the submesh to check readiness for
  118041. * @param useInstances is the mesh drawn using instance or not
  118042. * @returns true if ready otherwise false
  118043. */
  118044. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118045. /**
  118046. * Gets the current underlying G Buffer.
  118047. * @returns the buffer
  118048. */
  118049. getGBuffer(): MultiRenderTarget;
  118050. /**
  118051. * Gets the number of samples used to render the buffer (anti aliasing).
  118052. */
  118053. /**
  118054. * Sets the number of samples used to render the buffer (anti aliasing).
  118055. */
  118056. samples: number;
  118057. /**
  118058. * Disposes the renderer and frees up associated resources.
  118059. */
  118060. dispose(): void;
  118061. protected _createRenderTargets(): void;
  118062. private _copyBonesTransformationMatrices;
  118063. }
  118064. }
  118065. declare module BABYLON {
  118066. interface Scene {
  118067. /** @hidden (Backing field) */
  118068. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118069. /**
  118070. * Gets or Sets the current geometry buffer associated to the scene.
  118071. */
  118072. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118073. /**
  118074. * Enables a GeometryBufferRender and associates it with the scene
  118075. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118076. * @returns the GeometryBufferRenderer
  118077. */
  118078. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118079. /**
  118080. * Disables the GeometryBufferRender associated with the scene
  118081. */
  118082. disableGeometryBufferRenderer(): void;
  118083. }
  118084. /**
  118085. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118086. * in several rendering techniques.
  118087. */
  118088. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118089. /**
  118090. * The component name helpful to identify the component in the list of scene components.
  118091. */
  118092. readonly name: string;
  118093. /**
  118094. * The scene the component belongs to.
  118095. */
  118096. scene: Scene;
  118097. /**
  118098. * Creates a new instance of the component for the given scene
  118099. * @param scene Defines the scene to register the component in
  118100. */
  118101. constructor(scene: Scene);
  118102. /**
  118103. * Registers the component in a given scene
  118104. */
  118105. register(): void;
  118106. /**
  118107. * Rebuilds the elements related to this component in case of
  118108. * context lost for instance.
  118109. */
  118110. rebuild(): void;
  118111. /**
  118112. * Disposes the component and the associated ressources
  118113. */
  118114. dispose(): void;
  118115. private _gatherRenderTargets;
  118116. }
  118117. }
  118118. declare module BABYLON {
  118119. /** @hidden */
  118120. export var motionBlurPixelShader: {
  118121. name: string;
  118122. shader: string;
  118123. };
  118124. }
  118125. declare module BABYLON {
  118126. /**
  118127. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118128. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118129. * As an example, all you have to do is to create the post-process:
  118130. * var mb = new BABYLON.MotionBlurPostProcess(
  118131. * 'mb', // The name of the effect.
  118132. * scene, // The scene containing the objects to blur according to their velocity.
  118133. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118134. * camera // The camera to apply the render pass to.
  118135. * );
  118136. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118137. */
  118138. export class MotionBlurPostProcess extends PostProcess {
  118139. /**
  118140. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118141. */
  118142. motionStrength: number;
  118143. /**
  118144. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118145. */
  118146. /**
  118147. * Sets the number of iterations to be used for motion blur quality
  118148. */
  118149. motionBlurSamples: number;
  118150. private _motionBlurSamples;
  118151. private _geometryBufferRenderer;
  118152. /**
  118153. * Creates a new instance MotionBlurPostProcess
  118154. * @param name The name of the effect.
  118155. * @param scene The scene containing the objects to blur according to their velocity.
  118156. * @param options The required width/height ratio to downsize to before computing the render pass.
  118157. * @param camera The camera to apply the render pass to.
  118158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118159. * @param engine The engine which the post process will be applied. (default: current engine)
  118160. * @param reusable If the post process can be reused on the same frame. (default: false)
  118161. * @param textureType Type of textures used when performing the post process. (default: 0)
  118162. * @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)
  118163. */
  118164. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118165. /**
  118166. * Excludes the given skinned mesh from computing bones velocities.
  118167. * 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.
  118168. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118169. */
  118170. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118171. /**
  118172. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118173. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118174. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118175. */
  118176. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118177. /**
  118178. * Disposes the post process.
  118179. * @param camera The camera to dispose the post process on.
  118180. */
  118181. dispose(camera?: Camera): void;
  118182. }
  118183. }
  118184. declare module BABYLON {
  118185. /** @hidden */
  118186. export var refractionPixelShader: {
  118187. name: string;
  118188. shader: string;
  118189. };
  118190. }
  118191. declare module BABYLON {
  118192. /**
  118193. * Post process which applies a refractin texture
  118194. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118195. */
  118196. export class RefractionPostProcess extends PostProcess {
  118197. /** the base color of the refraction (used to taint the rendering) */
  118198. color: Color3;
  118199. /** simulated refraction depth */
  118200. depth: number;
  118201. /** the coefficient of the base color (0 to remove base color tainting) */
  118202. colorLevel: number;
  118203. private _refTexture;
  118204. private _ownRefractionTexture;
  118205. /**
  118206. * Gets or sets the refraction texture
  118207. * Please note that you are responsible for disposing the texture if you set it manually
  118208. */
  118209. refractionTexture: Texture;
  118210. /**
  118211. * Initializes the RefractionPostProcess
  118212. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118213. * @param name The name of the effect.
  118214. * @param refractionTextureUrl Url of the refraction texture to use
  118215. * @param color the base color of the refraction (used to taint the rendering)
  118216. * @param depth simulated refraction depth
  118217. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118218. * @param camera The camera to apply the render pass to.
  118219. * @param options The required width/height ratio to downsize to before computing the render pass.
  118220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118221. * @param engine The engine which the post process will be applied. (default: current engine)
  118222. * @param reusable If the post process can be reused on the same frame. (default: false)
  118223. */
  118224. constructor(name: string, refractionTextureUrl: string,
  118225. /** the base color of the refraction (used to taint the rendering) */
  118226. color: Color3,
  118227. /** simulated refraction depth */
  118228. depth: number,
  118229. /** the coefficient of the base color (0 to remove base color tainting) */
  118230. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118231. /**
  118232. * Disposes of the post process
  118233. * @param camera Camera to dispose post process on
  118234. */
  118235. dispose(camera: Camera): void;
  118236. }
  118237. }
  118238. declare module BABYLON {
  118239. /** @hidden */
  118240. export var sharpenPixelShader: {
  118241. name: string;
  118242. shader: string;
  118243. };
  118244. }
  118245. declare module BABYLON {
  118246. /**
  118247. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118248. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118249. */
  118250. export class SharpenPostProcess extends PostProcess {
  118251. /**
  118252. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118253. */
  118254. colorAmount: number;
  118255. /**
  118256. * How much sharpness should be applied (default: 0.3)
  118257. */
  118258. edgeAmount: number;
  118259. /**
  118260. * Creates a new instance ConvolutionPostProcess
  118261. * @param name The name of the effect.
  118262. * @param options The required width/height ratio to downsize to before computing the render pass.
  118263. * @param camera The camera to apply the render pass to.
  118264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118265. * @param engine The engine which the post process will be applied. (default: current engine)
  118266. * @param reusable If the post process can be reused on the same frame. (default: false)
  118267. * @param textureType Type of textures used when performing the post process. (default: 0)
  118268. * @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)
  118269. */
  118270. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118271. }
  118272. }
  118273. declare module BABYLON {
  118274. /**
  118275. * PostProcessRenderPipeline
  118276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118277. */
  118278. export class PostProcessRenderPipeline {
  118279. private engine;
  118280. private _renderEffects;
  118281. private _renderEffectsForIsolatedPass;
  118282. /**
  118283. * List of inspectable custom properties (used by the Inspector)
  118284. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118285. */
  118286. inspectableCustomProperties: IInspectable[];
  118287. /**
  118288. * @hidden
  118289. */
  118290. protected _cameras: Camera[];
  118291. /** @hidden */
  118292. _name: string;
  118293. /**
  118294. * Gets pipeline name
  118295. */
  118296. readonly name: string;
  118297. /**
  118298. * Initializes a PostProcessRenderPipeline
  118299. * @param engine engine to add the pipeline to
  118300. * @param name name of the pipeline
  118301. */
  118302. constructor(engine: Engine, name: string);
  118303. /**
  118304. * Gets the class name
  118305. * @returns "PostProcessRenderPipeline"
  118306. */
  118307. getClassName(): string;
  118308. /**
  118309. * If all the render effects in the pipeline are supported
  118310. */
  118311. readonly isSupported: boolean;
  118312. /**
  118313. * Adds an effect to the pipeline
  118314. * @param renderEffect the effect to add
  118315. */
  118316. addEffect(renderEffect: PostProcessRenderEffect): void;
  118317. /** @hidden */
  118318. _rebuild(): void;
  118319. /** @hidden */
  118320. _enableEffect(renderEffectName: string, cameras: Camera): void;
  118321. /** @hidden */
  118322. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  118323. /** @hidden */
  118324. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118325. /** @hidden */
  118326. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118327. /** @hidden */
  118328. _attachCameras(cameras: Camera, unique: boolean): void;
  118329. /** @hidden */
  118330. _attachCameras(cameras: Camera[], unique: boolean): void;
  118331. /** @hidden */
  118332. _detachCameras(cameras: Camera): void;
  118333. /** @hidden */
  118334. _detachCameras(cameras: Nullable<Camera[]>): void;
  118335. /** @hidden */
  118336. _update(): void;
  118337. /** @hidden */
  118338. _reset(): void;
  118339. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  118340. /**
  118341. * Disposes of the pipeline
  118342. */
  118343. dispose(): void;
  118344. }
  118345. }
  118346. declare module BABYLON {
  118347. /**
  118348. * PostProcessRenderPipelineManager class
  118349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118350. */
  118351. export class PostProcessRenderPipelineManager {
  118352. private _renderPipelines;
  118353. /**
  118354. * Initializes a PostProcessRenderPipelineManager
  118355. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118356. */
  118357. constructor();
  118358. /**
  118359. * Gets the list of supported render pipelines
  118360. */
  118361. readonly supportedPipelines: PostProcessRenderPipeline[];
  118362. /**
  118363. * Adds a pipeline to the manager
  118364. * @param renderPipeline The pipeline to add
  118365. */
  118366. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  118367. /**
  118368. * Attaches a camera to the pipeline
  118369. * @param renderPipelineName The name of the pipeline to attach to
  118370. * @param cameras the camera to attach
  118371. * @param unique if the camera can be attached multiple times to the pipeline
  118372. */
  118373. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  118374. /**
  118375. * Detaches a camera from the pipeline
  118376. * @param renderPipelineName The name of the pipeline to detach from
  118377. * @param cameras the camera to detach
  118378. */
  118379. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  118380. /**
  118381. * Enables an effect by name on a pipeline
  118382. * @param renderPipelineName the name of the pipeline to enable the effect in
  118383. * @param renderEffectName the name of the effect to enable
  118384. * @param cameras the cameras that the effect should be enabled on
  118385. */
  118386. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118387. /**
  118388. * Disables an effect by name on a pipeline
  118389. * @param renderPipelineName the name of the pipeline to disable the effect in
  118390. * @param renderEffectName the name of the effect to disable
  118391. * @param cameras the cameras that the effect should be disabled on
  118392. */
  118393. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118394. /**
  118395. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  118396. */
  118397. update(): void;
  118398. /** @hidden */
  118399. _rebuild(): void;
  118400. /**
  118401. * Disposes of the manager and pipelines
  118402. */
  118403. dispose(): void;
  118404. }
  118405. }
  118406. declare module BABYLON {
  118407. interface Scene {
  118408. /** @hidden (Backing field) */
  118409. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118410. /**
  118411. * Gets the postprocess render pipeline manager
  118412. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118413. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118414. */
  118415. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118416. }
  118417. /**
  118418. * Defines the Render Pipeline scene component responsible to rendering pipelines
  118419. */
  118420. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  118421. /**
  118422. * The component name helpfull to identify the component in the list of scene components.
  118423. */
  118424. readonly name: string;
  118425. /**
  118426. * The scene the component belongs to.
  118427. */
  118428. scene: Scene;
  118429. /**
  118430. * Creates a new instance of the component for the given scene
  118431. * @param scene Defines the scene to register the component in
  118432. */
  118433. constructor(scene: Scene);
  118434. /**
  118435. * Registers the component in a given scene
  118436. */
  118437. register(): void;
  118438. /**
  118439. * Rebuilds the elements related to this component in case of
  118440. * context lost for instance.
  118441. */
  118442. rebuild(): void;
  118443. /**
  118444. * Disposes the component and the associated ressources
  118445. */
  118446. dispose(): void;
  118447. private _gatherRenderTargets;
  118448. }
  118449. }
  118450. declare module BABYLON {
  118451. /**
  118452. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118453. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118454. */
  118455. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118456. private _scene;
  118457. private _camerasToBeAttached;
  118458. /**
  118459. * ID of the sharpen post process,
  118460. */
  118461. private readonly SharpenPostProcessId;
  118462. /**
  118463. * @ignore
  118464. * ID of the image processing post process;
  118465. */
  118466. readonly ImageProcessingPostProcessId: string;
  118467. /**
  118468. * @ignore
  118469. * ID of the Fast Approximate Anti-Aliasing post process;
  118470. */
  118471. readonly FxaaPostProcessId: string;
  118472. /**
  118473. * ID of the chromatic aberration post process,
  118474. */
  118475. private readonly ChromaticAberrationPostProcessId;
  118476. /**
  118477. * ID of the grain post process
  118478. */
  118479. private readonly GrainPostProcessId;
  118480. /**
  118481. * Sharpen post process which will apply a sharpen convolution to enhance edges
  118482. */
  118483. sharpen: SharpenPostProcess;
  118484. private _sharpenEffect;
  118485. private bloom;
  118486. /**
  118487. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  118488. */
  118489. depthOfField: DepthOfFieldEffect;
  118490. /**
  118491. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118492. */
  118493. fxaa: FxaaPostProcess;
  118494. /**
  118495. * Image post processing pass used to perform operations such as tone mapping or color grading.
  118496. */
  118497. imageProcessing: ImageProcessingPostProcess;
  118498. /**
  118499. * Chromatic aberration post process which will shift rgb colors in the image
  118500. */
  118501. chromaticAberration: ChromaticAberrationPostProcess;
  118502. private _chromaticAberrationEffect;
  118503. /**
  118504. * Grain post process which add noise to the image
  118505. */
  118506. grain: GrainPostProcess;
  118507. private _grainEffect;
  118508. /**
  118509. * Glow post process which adds a glow to emissive areas of the image
  118510. */
  118511. private _glowLayer;
  118512. /**
  118513. * Animations which can be used to tweak settings over a period of time
  118514. */
  118515. animations: Animation[];
  118516. private _imageProcessingConfigurationObserver;
  118517. private _sharpenEnabled;
  118518. private _bloomEnabled;
  118519. private _depthOfFieldEnabled;
  118520. private _depthOfFieldBlurLevel;
  118521. private _fxaaEnabled;
  118522. private _imageProcessingEnabled;
  118523. private _defaultPipelineTextureType;
  118524. private _bloomScale;
  118525. private _chromaticAberrationEnabled;
  118526. private _grainEnabled;
  118527. private _buildAllowed;
  118528. /**
  118529. * Gets active scene
  118530. */
  118531. readonly scene: Scene;
  118532. /**
  118533. * Enable or disable the sharpen process from the pipeline
  118534. */
  118535. sharpenEnabled: boolean;
  118536. private _resizeObserver;
  118537. private _hardwareScaleLevel;
  118538. private _bloomKernel;
  118539. /**
  118540. * Specifies the size of the bloom blur kernel, relative to the final output size
  118541. */
  118542. bloomKernel: number;
  118543. /**
  118544. * Specifies the weight of the bloom in the final rendering
  118545. */
  118546. private _bloomWeight;
  118547. /**
  118548. * Specifies the luma threshold for the area that will be blurred by the bloom
  118549. */
  118550. private _bloomThreshold;
  118551. private _hdr;
  118552. /**
  118553. * The strength of the bloom.
  118554. */
  118555. bloomWeight: number;
  118556. /**
  118557. * The strength of the bloom.
  118558. */
  118559. bloomThreshold: number;
  118560. /**
  118561. * The scale of the bloom, lower value will provide better performance.
  118562. */
  118563. bloomScale: number;
  118564. /**
  118565. * Enable or disable the bloom from the pipeline
  118566. */
  118567. bloomEnabled: boolean;
  118568. private _rebuildBloom;
  118569. /**
  118570. * If the depth of field is enabled.
  118571. */
  118572. depthOfFieldEnabled: boolean;
  118573. /**
  118574. * Blur level of the depth of field effect. (Higher blur will effect performance)
  118575. */
  118576. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  118577. /**
  118578. * If the anti aliasing is enabled.
  118579. */
  118580. fxaaEnabled: boolean;
  118581. private _samples;
  118582. /**
  118583. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118584. */
  118585. samples: number;
  118586. /**
  118587. * If image processing is enabled.
  118588. */
  118589. imageProcessingEnabled: boolean;
  118590. /**
  118591. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  118592. */
  118593. glowLayerEnabled: boolean;
  118594. /**
  118595. * Gets the glow layer (or null if not defined)
  118596. */
  118597. readonly glowLayer: Nullable<GlowLayer>;
  118598. /**
  118599. * Enable or disable the chromaticAberration process from the pipeline
  118600. */
  118601. chromaticAberrationEnabled: boolean;
  118602. /**
  118603. * Enable or disable the grain process from the pipeline
  118604. */
  118605. grainEnabled: boolean;
  118606. /**
  118607. * @constructor
  118608. * @param name - The rendering pipeline name (default: "")
  118609. * @param hdr - If high dynamic range textures should be used (default: true)
  118610. * @param scene - The scene linked to this pipeline (default: the last created scene)
  118611. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  118612. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  118613. */
  118614. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  118615. /**
  118616. * Get the class name
  118617. * @returns "DefaultRenderingPipeline"
  118618. */
  118619. getClassName(): string;
  118620. /**
  118621. * Force the compilation of the entire pipeline.
  118622. */
  118623. prepare(): void;
  118624. private _hasCleared;
  118625. private _prevPostProcess;
  118626. private _prevPrevPostProcess;
  118627. private _setAutoClearAndTextureSharing;
  118628. private _depthOfFieldSceneObserver;
  118629. private _buildPipeline;
  118630. private _disposePostProcesses;
  118631. /**
  118632. * Adds a camera to the pipeline
  118633. * @param camera the camera to be added
  118634. */
  118635. addCamera(camera: Camera): void;
  118636. /**
  118637. * Removes a camera from the pipeline
  118638. * @param camera the camera to remove
  118639. */
  118640. removeCamera(camera: Camera): void;
  118641. /**
  118642. * Dispose of the pipeline and stop all post processes
  118643. */
  118644. dispose(): void;
  118645. /**
  118646. * Serialize the rendering pipeline (Used when exporting)
  118647. * @returns the serialized object
  118648. */
  118649. serialize(): any;
  118650. /**
  118651. * Parse the serialized pipeline
  118652. * @param source Source pipeline.
  118653. * @param scene The scene to load the pipeline to.
  118654. * @param rootUrl The URL of the serialized pipeline.
  118655. * @returns An instantiated pipeline from the serialized object.
  118656. */
  118657. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  118658. }
  118659. }
  118660. declare module BABYLON {
  118661. /** @hidden */
  118662. export var lensHighlightsPixelShader: {
  118663. name: string;
  118664. shader: string;
  118665. };
  118666. }
  118667. declare module BABYLON {
  118668. /** @hidden */
  118669. export var depthOfFieldPixelShader: {
  118670. name: string;
  118671. shader: string;
  118672. };
  118673. }
  118674. declare module BABYLON {
  118675. /**
  118676. * BABYLON.JS Chromatic Aberration GLSL Shader
  118677. * Author: Olivier Guyot
  118678. * Separates very slightly R, G and B colors on the edges of the screen
  118679. * Inspired by Francois Tarlier & Martins Upitis
  118680. */
  118681. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  118682. /**
  118683. * @ignore
  118684. * The chromatic aberration PostProcess id in the pipeline
  118685. */
  118686. LensChromaticAberrationEffect: string;
  118687. /**
  118688. * @ignore
  118689. * The highlights enhancing PostProcess id in the pipeline
  118690. */
  118691. HighlightsEnhancingEffect: string;
  118692. /**
  118693. * @ignore
  118694. * The depth-of-field PostProcess id in the pipeline
  118695. */
  118696. LensDepthOfFieldEffect: string;
  118697. private _scene;
  118698. private _depthTexture;
  118699. private _grainTexture;
  118700. private _chromaticAberrationPostProcess;
  118701. private _highlightsPostProcess;
  118702. private _depthOfFieldPostProcess;
  118703. private _edgeBlur;
  118704. private _grainAmount;
  118705. private _chromaticAberration;
  118706. private _distortion;
  118707. private _highlightsGain;
  118708. private _highlightsThreshold;
  118709. private _dofDistance;
  118710. private _dofAperture;
  118711. private _dofDarken;
  118712. private _dofPentagon;
  118713. private _blurNoise;
  118714. /**
  118715. * @constructor
  118716. *
  118717. * Effect parameters are as follow:
  118718. * {
  118719. * chromatic_aberration: number; // from 0 to x (1 for realism)
  118720. * edge_blur: number; // from 0 to x (1 for realism)
  118721. * distortion: number; // from 0 to x (1 for realism)
  118722. * grain_amount: number; // from 0 to 1
  118723. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  118724. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  118725. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  118726. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  118727. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  118728. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  118729. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  118730. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  118731. * }
  118732. * Note: if an effect parameter is unset, effect is disabled
  118733. *
  118734. * @param name The rendering pipeline name
  118735. * @param parameters - An object containing all parameters (see above)
  118736. * @param scene The scene linked to this pipeline
  118737. * @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)
  118738. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118739. */
  118740. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  118741. /**
  118742. * Get the class name
  118743. * @returns "LensRenderingPipeline"
  118744. */
  118745. getClassName(): string;
  118746. /**
  118747. * Gets associated scene
  118748. */
  118749. readonly scene: Scene;
  118750. /**
  118751. * Gets or sets the edge blur
  118752. */
  118753. edgeBlur: number;
  118754. /**
  118755. * Gets or sets the grain amount
  118756. */
  118757. grainAmount: number;
  118758. /**
  118759. * Gets or sets the chromatic aberration amount
  118760. */
  118761. chromaticAberration: number;
  118762. /**
  118763. * Gets or sets the depth of field aperture
  118764. */
  118765. dofAperture: number;
  118766. /**
  118767. * Gets or sets the edge distortion
  118768. */
  118769. edgeDistortion: number;
  118770. /**
  118771. * Gets or sets the depth of field distortion
  118772. */
  118773. dofDistortion: number;
  118774. /**
  118775. * Gets or sets the darken out of focus amount
  118776. */
  118777. darkenOutOfFocus: number;
  118778. /**
  118779. * Gets or sets a boolean indicating if blur noise is enabled
  118780. */
  118781. blurNoise: boolean;
  118782. /**
  118783. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  118784. */
  118785. pentagonBokeh: boolean;
  118786. /**
  118787. * Gets or sets the highlight grain amount
  118788. */
  118789. highlightsGain: number;
  118790. /**
  118791. * Gets or sets the highlight threshold
  118792. */
  118793. highlightsThreshold: number;
  118794. /**
  118795. * Sets the amount of blur at the edges
  118796. * @param amount blur amount
  118797. */
  118798. setEdgeBlur(amount: number): void;
  118799. /**
  118800. * Sets edge blur to 0
  118801. */
  118802. disableEdgeBlur(): void;
  118803. /**
  118804. * Sets the amout of grain
  118805. * @param amount Amount of grain
  118806. */
  118807. setGrainAmount(amount: number): void;
  118808. /**
  118809. * Set grain amount to 0
  118810. */
  118811. disableGrain(): void;
  118812. /**
  118813. * Sets the chromatic aberration amount
  118814. * @param amount amount of chromatic aberration
  118815. */
  118816. setChromaticAberration(amount: number): void;
  118817. /**
  118818. * Sets chromatic aberration amount to 0
  118819. */
  118820. disableChromaticAberration(): void;
  118821. /**
  118822. * Sets the EdgeDistortion amount
  118823. * @param amount amount of EdgeDistortion
  118824. */
  118825. setEdgeDistortion(amount: number): void;
  118826. /**
  118827. * Sets edge distortion to 0
  118828. */
  118829. disableEdgeDistortion(): void;
  118830. /**
  118831. * Sets the FocusDistance amount
  118832. * @param amount amount of FocusDistance
  118833. */
  118834. setFocusDistance(amount: number): void;
  118835. /**
  118836. * Disables depth of field
  118837. */
  118838. disableDepthOfField(): void;
  118839. /**
  118840. * Sets the Aperture amount
  118841. * @param amount amount of Aperture
  118842. */
  118843. setAperture(amount: number): void;
  118844. /**
  118845. * Sets the DarkenOutOfFocus amount
  118846. * @param amount amount of DarkenOutOfFocus
  118847. */
  118848. setDarkenOutOfFocus(amount: number): void;
  118849. private _pentagonBokehIsEnabled;
  118850. /**
  118851. * Creates a pentagon bokeh effect
  118852. */
  118853. enablePentagonBokeh(): void;
  118854. /**
  118855. * Disables the pentagon bokeh effect
  118856. */
  118857. disablePentagonBokeh(): void;
  118858. /**
  118859. * Enables noise blur
  118860. */
  118861. enableNoiseBlur(): void;
  118862. /**
  118863. * Disables noise blur
  118864. */
  118865. disableNoiseBlur(): void;
  118866. /**
  118867. * Sets the HighlightsGain amount
  118868. * @param amount amount of HighlightsGain
  118869. */
  118870. setHighlightsGain(amount: number): void;
  118871. /**
  118872. * Sets the HighlightsThreshold amount
  118873. * @param amount amount of HighlightsThreshold
  118874. */
  118875. setHighlightsThreshold(amount: number): void;
  118876. /**
  118877. * Disables highlights
  118878. */
  118879. disableHighlights(): void;
  118880. /**
  118881. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  118882. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  118883. */
  118884. dispose(disableDepthRender?: boolean): void;
  118885. private _createChromaticAberrationPostProcess;
  118886. private _createHighlightsPostProcess;
  118887. private _createDepthOfFieldPostProcess;
  118888. private _createGrainTexture;
  118889. }
  118890. }
  118891. declare module BABYLON {
  118892. /** @hidden */
  118893. export var ssao2PixelShader: {
  118894. name: string;
  118895. shader: string;
  118896. };
  118897. }
  118898. declare module BABYLON {
  118899. /** @hidden */
  118900. export var ssaoCombinePixelShader: {
  118901. name: string;
  118902. shader: string;
  118903. };
  118904. }
  118905. declare module BABYLON {
  118906. /**
  118907. * Render pipeline to produce ssao effect
  118908. */
  118909. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  118910. /**
  118911. * @ignore
  118912. * The PassPostProcess id in the pipeline that contains the original scene color
  118913. */
  118914. SSAOOriginalSceneColorEffect: string;
  118915. /**
  118916. * @ignore
  118917. * The SSAO PostProcess id in the pipeline
  118918. */
  118919. SSAORenderEffect: string;
  118920. /**
  118921. * @ignore
  118922. * The horizontal blur PostProcess id in the pipeline
  118923. */
  118924. SSAOBlurHRenderEffect: string;
  118925. /**
  118926. * @ignore
  118927. * The vertical blur PostProcess id in the pipeline
  118928. */
  118929. SSAOBlurVRenderEffect: string;
  118930. /**
  118931. * @ignore
  118932. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118933. */
  118934. SSAOCombineRenderEffect: string;
  118935. /**
  118936. * The output strength of the SSAO post-process. Default value is 1.0.
  118937. */
  118938. totalStrength: number;
  118939. /**
  118940. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  118941. */
  118942. maxZ: number;
  118943. /**
  118944. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  118945. */
  118946. minZAspect: number;
  118947. private _samples;
  118948. /**
  118949. * Number of samples used for the SSAO calculations. Default value is 8
  118950. */
  118951. samples: number;
  118952. private _textureSamples;
  118953. /**
  118954. * Number of samples to use for antialiasing
  118955. */
  118956. textureSamples: number;
  118957. /**
  118958. * Ratio object used for SSAO ratio and blur ratio
  118959. */
  118960. private _ratio;
  118961. /**
  118962. * Dynamically generated sphere sampler.
  118963. */
  118964. private _sampleSphere;
  118965. /**
  118966. * Blur filter offsets
  118967. */
  118968. private _samplerOffsets;
  118969. private _expensiveBlur;
  118970. /**
  118971. * If bilateral blur should be used
  118972. */
  118973. expensiveBlur: boolean;
  118974. /**
  118975. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  118976. */
  118977. radius: number;
  118978. /**
  118979. * The base color of the SSAO post-process
  118980. * The final result is "base + ssao" between [0, 1]
  118981. */
  118982. base: number;
  118983. /**
  118984. * Support test.
  118985. */
  118986. static readonly IsSupported: boolean;
  118987. private _scene;
  118988. private _depthTexture;
  118989. private _normalTexture;
  118990. private _randomTexture;
  118991. private _originalColorPostProcess;
  118992. private _ssaoPostProcess;
  118993. private _blurHPostProcess;
  118994. private _blurVPostProcess;
  118995. private _ssaoCombinePostProcess;
  118996. private _firstUpdate;
  118997. /**
  118998. * Gets active scene
  118999. */
  119000. readonly scene: Scene;
  119001. /**
  119002. * @constructor
  119003. * @param name The rendering pipeline name
  119004. * @param scene The scene linked to this pipeline
  119005. * @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 }
  119006. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119007. */
  119008. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119009. /**
  119010. * Get the class name
  119011. * @returns "SSAO2RenderingPipeline"
  119012. */
  119013. getClassName(): string;
  119014. /**
  119015. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119016. */
  119017. dispose(disableGeometryBufferRenderer?: boolean): void;
  119018. private _createBlurPostProcess;
  119019. /** @hidden */
  119020. _rebuild(): void;
  119021. private _bits;
  119022. private _radicalInverse_VdC;
  119023. private _hammersley;
  119024. private _hemisphereSample_uniform;
  119025. private _generateHemisphere;
  119026. private _createSSAOPostProcess;
  119027. private _createSSAOCombinePostProcess;
  119028. private _createRandomTexture;
  119029. /**
  119030. * Serialize the rendering pipeline (Used when exporting)
  119031. * @returns the serialized object
  119032. */
  119033. serialize(): any;
  119034. /**
  119035. * Parse the serialized pipeline
  119036. * @param source Source pipeline.
  119037. * @param scene The scene to load the pipeline to.
  119038. * @param rootUrl The URL of the serialized pipeline.
  119039. * @returns An instantiated pipeline from the serialized object.
  119040. */
  119041. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119042. }
  119043. }
  119044. declare module BABYLON {
  119045. /** @hidden */
  119046. export var ssaoPixelShader: {
  119047. name: string;
  119048. shader: string;
  119049. };
  119050. }
  119051. declare module BABYLON {
  119052. /**
  119053. * Render pipeline to produce ssao effect
  119054. */
  119055. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119056. /**
  119057. * @ignore
  119058. * The PassPostProcess id in the pipeline that contains the original scene color
  119059. */
  119060. SSAOOriginalSceneColorEffect: string;
  119061. /**
  119062. * @ignore
  119063. * The SSAO PostProcess id in the pipeline
  119064. */
  119065. SSAORenderEffect: string;
  119066. /**
  119067. * @ignore
  119068. * The horizontal blur PostProcess id in the pipeline
  119069. */
  119070. SSAOBlurHRenderEffect: string;
  119071. /**
  119072. * @ignore
  119073. * The vertical blur PostProcess id in the pipeline
  119074. */
  119075. SSAOBlurVRenderEffect: string;
  119076. /**
  119077. * @ignore
  119078. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119079. */
  119080. SSAOCombineRenderEffect: string;
  119081. /**
  119082. * The output strength of the SSAO post-process. Default value is 1.0.
  119083. */
  119084. totalStrength: number;
  119085. /**
  119086. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119087. */
  119088. radius: number;
  119089. /**
  119090. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119091. * Must not be equal to fallOff and superior to fallOff.
  119092. * Default value is 0.0075
  119093. */
  119094. area: number;
  119095. /**
  119096. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119097. * Must not be equal to area and inferior to area.
  119098. * Default value is 0.000001
  119099. */
  119100. fallOff: number;
  119101. /**
  119102. * The base color of the SSAO post-process
  119103. * The final result is "base + ssao" between [0, 1]
  119104. */
  119105. base: number;
  119106. private _scene;
  119107. private _depthTexture;
  119108. private _randomTexture;
  119109. private _originalColorPostProcess;
  119110. private _ssaoPostProcess;
  119111. private _blurHPostProcess;
  119112. private _blurVPostProcess;
  119113. private _ssaoCombinePostProcess;
  119114. private _firstUpdate;
  119115. /**
  119116. * Gets active scene
  119117. */
  119118. readonly scene: Scene;
  119119. /**
  119120. * @constructor
  119121. * @param name - The rendering pipeline name
  119122. * @param scene - The scene linked to this pipeline
  119123. * @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 }
  119124. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119125. */
  119126. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119127. /**
  119128. * Get the class name
  119129. * @returns "SSAORenderingPipeline"
  119130. */
  119131. getClassName(): string;
  119132. /**
  119133. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119134. */
  119135. dispose(disableDepthRender?: boolean): void;
  119136. private _createBlurPostProcess;
  119137. /** @hidden */
  119138. _rebuild(): void;
  119139. private _createSSAOPostProcess;
  119140. private _createSSAOCombinePostProcess;
  119141. private _createRandomTexture;
  119142. }
  119143. }
  119144. declare module BABYLON {
  119145. /** @hidden */
  119146. export var standardPixelShader: {
  119147. name: string;
  119148. shader: string;
  119149. };
  119150. }
  119151. declare module BABYLON {
  119152. /**
  119153. * Standard rendering pipeline
  119154. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119155. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119156. */
  119157. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119158. /**
  119159. * Public members
  119160. */
  119161. /**
  119162. * Post-process which contains the original scene color before the pipeline applies all the effects
  119163. */
  119164. originalPostProcess: Nullable<PostProcess>;
  119165. /**
  119166. * Post-process used to down scale an image x4
  119167. */
  119168. downSampleX4PostProcess: Nullable<PostProcess>;
  119169. /**
  119170. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119171. */
  119172. brightPassPostProcess: Nullable<PostProcess>;
  119173. /**
  119174. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119175. */
  119176. blurHPostProcesses: PostProcess[];
  119177. /**
  119178. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119179. */
  119180. blurVPostProcesses: PostProcess[];
  119181. /**
  119182. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119183. */
  119184. textureAdderPostProcess: Nullable<PostProcess>;
  119185. /**
  119186. * Post-process used to create volumetric lighting effect
  119187. */
  119188. volumetricLightPostProcess: Nullable<PostProcess>;
  119189. /**
  119190. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119191. */
  119192. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119193. /**
  119194. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119195. */
  119196. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119197. /**
  119198. * Post-process used to merge the volumetric light effect and the real scene color
  119199. */
  119200. volumetricLightMergePostProces: Nullable<PostProcess>;
  119201. /**
  119202. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119203. */
  119204. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119205. /**
  119206. * Base post-process used to calculate the average luminance of the final image for HDR
  119207. */
  119208. luminancePostProcess: Nullable<PostProcess>;
  119209. /**
  119210. * Post-processes used to create down sample post-processes in order to get
  119211. * the average luminance of the final image for HDR
  119212. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119213. */
  119214. luminanceDownSamplePostProcesses: PostProcess[];
  119215. /**
  119216. * Post-process used to create a HDR effect (light adaptation)
  119217. */
  119218. hdrPostProcess: Nullable<PostProcess>;
  119219. /**
  119220. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119221. */
  119222. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119223. /**
  119224. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119225. */
  119226. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119227. /**
  119228. * Post-process used to merge the final HDR post-process and the real scene color
  119229. */
  119230. hdrFinalPostProcess: Nullable<PostProcess>;
  119231. /**
  119232. * Post-process used to create a lens flare effect
  119233. */
  119234. lensFlarePostProcess: Nullable<PostProcess>;
  119235. /**
  119236. * Post-process that merges the result of the lens flare post-process and the real scene color
  119237. */
  119238. lensFlareComposePostProcess: Nullable<PostProcess>;
  119239. /**
  119240. * Post-process used to create a motion blur effect
  119241. */
  119242. motionBlurPostProcess: Nullable<PostProcess>;
  119243. /**
  119244. * Post-process used to create a depth of field effect
  119245. */
  119246. depthOfFieldPostProcess: Nullable<PostProcess>;
  119247. /**
  119248. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119249. */
  119250. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119251. /**
  119252. * Represents the brightness threshold in order to configure the illuminated surfaces
  119253. */
  119254. brightThreshold: number;
  119255. /**
  119256. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119257. */
  119258. blurWidth: number;
  119259. /**
  119260. * Sets if the blur for highlighted surfaces must be only horizontal
  119261. */
  119262. horizontalBlur: boolean;
  119263. /**
  119264. * Gets the overall exposure used by the pipeline
  119265. */
  119266. /**
  119267. * Sets the overall exposure used by the pipeline
  119268. */
  119269. exposure: number;
  119270. /**
  119271. * Texture used typically to simulate "dirty" on camera lens
  119272. */
  119273. lensTexture: Nullable<Texture>;
  119274. /**
  119275. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119276. */
  119277. volumetricLightCoefficient: number;
  119278. /**
  119279. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119280. */
  119281. volumetricLightPower: number;
  119282. /**
  119283. * Used the set the blur intensity to smooth the volumetric lights
  119284. */
  119285. volumetricLightBlurScale: number;
  119286. /**
  119287. * Light (spot or directional) used to generate the volumetric lights rays
  119288. * The source light must have a shadow generate so the pipeline can get its
  119289. * depth map
  119290. */
  119291. sourceLight: Nullable<SpotLight | DirectionalLight>;
  119292. /**
  119293. * For eye adaptation, represents the minimum luminance the eye can see
  119294. */
  119295. hdrMinimumLuminance: number;
  119296. /**
  119297. * For eye adaptation, represents the decrease luminance speed
  119298. */
  119299. hdrDecreaseRate: number;
  119300. /**
  119301. * For eye adaptation, represents the increase luminance speed
  119302. */
  119303. hdrIncreaseRate: number;
  119304. /**
  119305. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119306. */
  119307. /**
  119308. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119309. */
  119310. hdrAutoExposure: boolean;
  119311. /**
  119312. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119313. */
  119314. lensColorTexture: Nullable<Texture>;
  119315. /**
  119316. * The overall strengh for the lens flare effect
  119317. */
  119318. lensFlareStrength: number;
  119319. /**
  119320. * Dispersion coefficient for lens flare ghosts
  119321. */
  119322. lensFlareGhostDispersal: number;
  119323. /**
  119324. * Main lens flare halo width
  119325. */
  119326. lensFlareHaloWidth: number;
  119327. /**
  119328. * Based on the lens distortion effect, defines how much the lens flare result
  119329. * is distorted
  119330. */
  119331. lensFlareDistortionStrength: number;
  119332. /**
  119333. * Lens star texture must be used to simulate rays on the flares and is available
  119334. * in the documentation
  119335. */
  119336. lensStarTexture: Nullable<Texture>;
  119337. /**
  119338. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119339. * flare effect by taking account of the dirt texture
  119340. */
  119341. lensFlareDirtTexture: Nullable<Texture>;
  119342. /**
  119343. * Represents the focal length for the depth of field effect
  119344. */
  119345. depthOfFieldDistance: number;
  119346. /**
  119347. * Represents the blur intensity for the blurred part of the depth of field effect
  119348. */
  119349. depthOfFieldBlurWidth: number;
  119350. /**
  119351. * Gets how much the image is blurred by the movement while using the motion blur post-process
  119352. */
  119353. /**
  119354. * Sets how much the image is blurred by the movement while using the motion blur post-process
  119355. */
  119356. motionStrength: number;
  119357. /**
  119358. * Gets wether or not the motion blur post-process is object based or screen based.
  119359. */
  119360. /**
  119361. * Sets wether or not the motion blur post-process should be object based or screen based
  119362. */
  119363. objectBasedMotionBlur: boolean;
  119364. /**
  119365. * List of animations for the pipeline (IAnimatable implementation)
  119366. */
  119367. animations: Animation[];
  119368. /**
  119369. * Private members
  119370. */
  119371. private _scene;
  119372. private _currentDepthOfFieldSource;
  119373. private _basePostProcess;
  119374. private _fixedExposure;
  119375. private _currentExposure;
  119376. private _hdrAutoExposure;
  119377. private _hdrCurrentLuminance;
  119378. private _motionStrength;
  119379. private _isObjectBasedMotionBlur;
  119380. private _floatTextureType;
  119381. private _ratio;
  119382. private _bloomEnabled;
  119383. private _depthOfFieldEnabled;
  119384. private _vlsEnabled;
  119385. private _lensFlareEnabled;
  119386. private _hdrEnabled;
  119387. private _motionBlurEnabled;
  119388. private _fxaaEnabled;
  119389. private _motionBlurSamples;
  119390. private _volumetricLightStepsCount;
  119391. private _samples;
  119392. /**
  119393. * @ignore
  119394. * Specifies if the bloom pipeline is enabled
  119395. */
  119396. BloomEnabled: boolean;
  119397. /**
  119398. * @ignore
  119399. * Specifies if the depth of field pipeline is enabed
  119400. */
  119401. DepthOfFieldEnabled: boolean;
  119402. /**
  119403. * @ignore
  119404. * Specifies if the lens flare pipeline is enabed
  119405. */
  119406. LensFlareEnabled: boolean;
  119407. /**
  119408. * @ignore
  119409. * Specifies if the HDR pipeline is enabled
  119410. */
  119411. HDREnabled: boolean;
  119412. /**
  119413. * @ignore
  119414. * Specifies if the volumetric lights scattering effect is enabled
  119415. */
  119416. VLSEnabled: boolean;
  119417. /**
  119418. * @ignore
  119419. * Specifies if the motion blur effect is enabled
  119420. */
  119421. MotionBlurEnabled: boolean;
  119422. /**
  119423. * Specifies if anti-aliasing is enabled
  119424. */
  119425. fxaaEnabled: boolean;
  119426. /**
  119427. * Specifies the number of steps used to calculate the volumetric lights
  119428. * Typically in interval [50, 200]
  119429. */
  119430. volumetricLightStepsCount: number;
  119431. /**
  119432. * Specifies the number of samples used for the motion blur effect
  119433. * Typically in interval [16, 64]
  119434. */
  119435. motionBlurSamples: number;
  119436. /**
  119437. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119438. */
  119439. samples: number;
  119440. /**
  119441. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119442. * @constructor
  119443. * @param name The rendering pipeline name
  119444. * @param scene The scene linked to this pipeline
  119445. * @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)
  119446. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119447. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119448. */
  119449. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  119450. private _buildPipeline;
  119451. private _createDownSampleX4PostProcess;
  119452. private _createBrightPassPostProcess;
  119453. private _createBlurPostProcesses;
  119454. private _createTextureAdderPostProcess;
  119455. private _createVolumetricLightPostProcess;
  119456. private _createLuminancePostProcesses;
  119457. private _createHdrPostProcess;
  119458. private _createLensFlarePostProcess;
  119459. private _createDepthOfFieldPostProcess;
  119460. private _createMotionBlurPostProcess;
  119461. private _getDepthTexture;
  119462. private _disposePostProcesses;
  119463. /**
  119464. * Dispose of the pipeline and stop all post processes
  119465. */
  119466. dispose(): void;
  119467. /**
  119468. * Serialize the rendering pipeline (Used when exporting)
  119469. * @returns the serialized object
  119470. */
  119471. serialize(): any;
  119472. /**
  119473. * Parse the serialized pipeline
  119474. * @param source Source pipeline.
  119475. * @param scene The scene to load the pipeline to.
  119476. * @param rootUrl The URL of the serialized pipeline.
  119477. * @returns An instantiated pipeline from the serialized object.
  119478. */
  119479. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119480. /**
  119481. * Luminance steps
  119482. */
  119483. static LuminanceSteps: number;
  119484. }
  119485. }
  119486. declare module BABYLON {
  119487. /** @hidden */
  119488. export var tonemapPixelShader: {
  119489. name: string;
  119490. shader: string;
  119491. };
  119492. }
  119493. declare module BABYLON {
  119494. /** Defines operator used for tonemapping */
  119495. export enum TonemappingOperator {
  119496. /** Hable */
  119497. Hable = 0,
  119498. /** Reinhard */
  119499. Reinhard = 1,
  119500. /** HejiDawson */
  119501. HejiDawson = 2,
  119502. /** Photographic */
  119503. Photographic = 3
  119504. }
  119505. /**
  119506. * Defines a post process to apply tone mapping
  119507. */
  119508. export class TonemapPostProcess extends PostProcess {
  119509. private _operator;
  119510. /** Defines the required exposure adjustement */
  119511. exposureAdjustment: number;
  119512. /**
  119513. * Creates a new TonemapPostProcess
  119514. * @param name defines the name of the postprocess
  119515. * @param _operator defines the operator to use
  119516. * @param exposureAdjustment defines the required exposure adjustement
  119517. * @param camera defines the camera to use (can be null)
  119518. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119519. * @param engine defines the hosting engine (can be ignore if camera is set)
  119520. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119521. */
  119522. constructor(name: string, _operator: TonemappingOperator,
  119523. /** Defines the required exposure adjustement */
  119524. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  119525. }
  119526. }
  119527. declare module BABYLON {
  119528. /** @hidden */
  119529. export var depthVertexShader: {
  119530. name: string;
  119531. shader: string;
  119532. };
  119533. }
  119534. declare module BABYLON {
  119535. /** @hidden */
  119536. export var volumetricLightScatteringPixelShader: {
  119537. name: string;
  119538. shader: string;
  119539. };
  119540. }
  119541. declare module BABYLON {
  119542. /** @hidden */
  119543. export var volumetricLightScatteringPassPixelShader: {
  119544. name: string;
  119545. shader: string;
  119546. };
  119547. }
  119548. declare module BABYLON {
  119549. /**
  119550. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119551. */
  119552. export class VolumetricLightScatteringPostProcess extends PostProcess {
  119553. private _volumetricLightScatteringPass;
  119554. private _volumetricLightScatteringRTT;
  119555. private _viewPort;
  119556. private _screenCoordinates;
  119557. private _cachedDefines;
  119558. /**
  119559. * If not undefined, the mesh position is computed from the attached node position
  119560. */
  119561. attachedNode: {
  119562. position: Vector3;
  119563. };
  119564. /**
  119565. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119566. */
  119567. customMeshPosition: Vector3;
  119568. /**
  119569. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119570. */
  119571. useCustomMeshPosition: boolean;
  119572. /**
  119573. * If the post-process should inverse the light scattering direction
  119574. */
  119575. invert: boolean;
  119576. /**
  119577. * The internal mesh used by the post-process
  119578. */
  119579. mesh: Mesh;
  119580. /**
  119581. * @hidden
  119582. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119583. */
  119584. useDiffuseColor: boolean;
  119585. /**
  119586. * Array containing the excluded meshes not rendered in the internal pass
  119587. */
  119588. excludedMeshes: AbstractMesh[];
  119589. /**
  119590. * Controls the overall intensity of the post-process
  119591. */
  119592. exposure: number;
  119593. /**
  119594. * Dissipates each sample's contribution in range [0, 1]
  119595. */
  119596. decay: number;
  119597. /**
  119598. * Controls the overall intensity of each sample
  119599. */
  119600. weight: number;
  119601. /**
  119602. * Controls the density of each sample
  119603. */
  119604. density: number;
  119605. /**
  119606. * @constructor
  119607. * @param name The post-process name
  119608. * @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)
  119609. * @param camera The camera that the post-process will be attached to
  119610. * @param mesh The mesh used to create the light scattering
  119611. * @param samples The post-process quality, default 100
  119612. * @param samplingModeThe post-process filtering mode
  119613. * @param engine The babylon engine
  119614. * @param reusable If the post-process is reusable
  119615. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119616. */
  119617. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  119618. /**
  119619. * Returns the string "VolumetricLightScatteringPostProcess"
  119620. * @returns "VolumetricLightScatteringPostProcess"
  119621. */
  119622. getClassName(): string;
  119623. private _isReady;
  119624. /**
  119625. * Sets the new light position for light scattering effect
  119626. * @param position The new custom light position
  119627. */
  119628. setCustomMeshPosition(position: Vector3): void;
  119629. /**
  119630. * Returns the light position for light scattering effect
  119631. * @return Vector3 The custom light position
  119632. */
  119633. getCustomMeshPosition(): Vector3;
  119634. /**
  119635. * Disposes the internal assets and detaches the post-process from the camera
  119636. */
  119637. dispose(camera: Camera): void;
  119638. /**
  119639. * Returns the render target texture used by the post-process
  119640. * @return the render target texture used by the post-process
  119641. */
  119642. getPass(): RenderTargetTexture;
  119643. private _meshExcluded;
  119644. private _createPass;
  119645. private _updateMeshScreenCoordinates;
  119646. /**
  119647. * Creates a default mesh for the Volumeric Light Scattering post-process
  119648. * @param name The mesh name
  119649. * @param scene The scene where to create the mesh
  119650. * @return the default mesh
  119651. */
  119652. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  119653. }
  119654. }
  119655. declare module BABYLON {
  119656. interface Scene {
  119657. /** @hidden (Backing field) */
  119658. _boundingBoxRenderer: BoundingBoxRenderer;
  119659. /** @hidden (Backing field) */
  119660. _forceShowBoundingBoxes: boolean;
  119661. /**
  119662. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  119663. */
  119664. forceShowBoundingBoxes: boolean;
  119665. /**
  119666. * Gets the bounding box renderer associated with the scene
  119667. * @returns a BoundingBoxRenderer
  119668. */
  119669. getBoundingBoxRenderer(): BoundingBoxRenderer;
  119670. }
  119671. interface AbstractMesh {
  119672. /** @hidden (Backing field) */
  119673. _showBoundingBox: boolean;
  119674. /**
  119675. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  119676. */
  119677. showBoundingBox: boolean;
  119678. }
  119679. /**
  119680. * Component responsible of rendering the bounding box of the meshes in a scene.
  119681. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119682. */
  119683. export class BoundingBoxRenderer implements ISceneComponent {
  119684. /**
  119685. * The component name helpfull to identify the component in the list of scene components.
  119686. */
  119687. readonly name: string;
  119688. /**
  119689. * The scene the component belongs to.
  119690. */
  119691. scene: Scene;
  119692. /**
  119693. * Color of the bounding box lines placed in front of an object
  119694. */
  119695. frontColor: Color3;
  119696. /**
  119697. * Color of the bounding box lines placed behind an object
  119698. */
  119699. backColor: Color3;
  119700. /**
  119701. * Defines if the renderer should show the back lines or not
  119702. */
  119703. showBackLines: boolean;
  119704. /**
  119705. * @hidden
  119706. */
  119707. renderList: SmartArray<BoundingBox>;
  119708. private _colorShader;
  119709. private _vertexBuffers;
  119710. private _indexBuffer;
  119711. private _fillIndexBuffer;
  119712. private _fillIndexData;
  119713. /**
  119714. * Instantiates a new bounding box renderer in a scene.
  119715. * @param scene the scene the renderer renders in
  119716. */
  119717. constructor(scene: Scene);
  119718. /**
  119719. * Registers the component in a given scene
  119720. */
  119721. register(): void;
  119722. private _evaluateSubMesh;
  119723. private _activeMesh;
  119724. private _prepareRessources;
  119725. private _createIndexBuffer;
  119726. /**
  119727. * Rebuilds the elements related to this component in case of
  119728. * context lost for instance.
  119729. */
  119730. rebuild(): void;
  119731. /**
  119732. * @hidden
  119733. */
  119734. reset(): void;
  119735. /**
  119736. * Render the bounding boxes of a specific rendering group
  119737. * @param renderingGroupId defines the rendering group to render
  119738. */
  119739. render(renderingGroupId: number): void;
  119740. /**
  119741. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119742. * @param mesh Define the mesh to render the occlusion bounding box for
  119743. */
  119744. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  119745. /**
  119746. * Dispose and release the resources attached to this renderer.
  119747. */
  119748. dispose(): void;
  119749. }
  119750. }
  119751. declare module BABYLON {
  119752. /** @hidden */
  119753. export var depthPixelShader: {
  119754. name: string;
  119755. shader: string;
  119756. };
  119757. }
  119758. declare module BABYLON {
  119759. /**
  119760. * This represents a depth renderer in Babylon.
  119761. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119762. */
  119763. export class DepthRenderer {
  119764. private _scene;
  119765. private _depthMap;
  119766. private _effect;
  119767. private _cachedDefines;
  119768. private _camera;
  119769. /**
  119770. * Specifiess that the depth renderer will only be used within
  119771. * the camera it is created for.
  119772. * This can help forcing its rendering during the camera processing.
  119773. */
  119774. useOnlyInActiveCamera: boolean;
  119775. /** @hidden */
  119776. static _SceneComponentInitialization: (scene: Scene) => void;
  119777. /**
  119778. * Instantiates a depth renderer
  119779. * @param scene The scene the renderer belongs to
  119780. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119781. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119782. */
  119783. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  119784. /**
  119785. * Creates the depth rendering effect and checks if the effect is ready.
  119786. * @param subMesh The submesh to be used to render the depth map of
  119787. * @param useInstances If multiple world instances should be used
  119788. * @returns if the depth renderer is ready to render the depth map
  119789. */
  119790. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119791. /**
  119792. * Gets the texture which the depth map will be written to.
  119793. * @returns The depth map texture
  119794. */
  119795. getDepthMap(): RenderTargetTexture;
  119796. /**
  119797. * Disposes of the depth renderer.
  119798. */
  119799. dispose(): void;
  119800. }
  119801. }
  119802. declare module BABYLON {
  119803. interface Scene {
  119804. /** @hidden (Backing field) */
  119805. _depthRenderer: {
  119806. [id: string]: DepthRenderer;
  119807. };
  119808. /**
  119809. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  119810. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  119811. * @returns the created depth renderer
  119812. */
  119813. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  119814. /**
  119815. * Disables a depth renderer for a given camera
  119816. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  119817. */
  119818. disableDepthRenderer(camera?: Nullable<Camera>): void;
  119819. }
  119820. /**
  119821. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119822. * in several rendering techniques.
  119823. */
  119824. export class DepthRendererSceneComponent implements ISceneComponent {
  119825. /**
  119826. * The component name helpfull to identify the component in the list of scene components.
  119827. */
  119828. readonly name: string;
  119829. /**
  119830. * The scene the component belongs to.
  119831. */
  119832. scene: Scene;
  119833. /**
  119834. * Creates a new instance of the component for the given scene
  119835. * @param scene Defines the scene to register the component in
  119836. */
  119837. constructor(scene: Scene);
  119838. /**
  119839. * Registers the component in a given scene
  119840. */
  119841. register(): void;
  119842. /**
  119843. * Rebuilds the elements related to this component in case of
  119844. * context lost for instance.
  119845. */
  119846. rebuild(): void;
  119847. /**
  119848. * Disposes the component and the associated ressources
  119849. */
  119850. dispose(): void;
  119851. private _gatherRenderTargets;
  119852. private _gatherActiveCameraRenderTargets;
  119853. }
  119854. }
  119855. declare module BABYLON {
  119856. /** @hidden */
  119857. export var outlinePixelShader: {
  119858. name: string;
  119859. shader: string;
  119860. };
  119861. }
  119862. declare module BABYLON {
  119863. /** @hidden */
  119864. export var outlineVertexShader: {
  119865. name: string;
  119866. shader: string;
  119867. };
  119868. }
  119869. declare module BABYLON {
  119870. interface Scene {
  119871. /** @hidden */
  119872. _outlineRenderer: OutlineRenderer;
  119873. /**
  119874. * Gets the outline renderer associated with the scene
  119875. * @returns a OutlineRenderer
  119876. */
  119877. getOutlineRenderer(): OutlineRenderer;
  119878. }
  119879. interface AbstractMesh {
  119880. /** @hidden (Backing field) */
  119881. _renderOutline: boolean;
  119882. /**
  119883. * Gets or sets a boolean indicating if the outline must be rendered as well
  119884. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  119885. */
  119886. renderOutline: boolean;
  119887. /** @hidden (Backing field) */
  119888. _renderOverlay: boolean;
  119889. /**
  119890. * Gets or sets a boolean indicating if the overlay must be rendered as well
  119891. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  119892. */
  119893. renderOverlay: boolean;
  119894. }
  119895. /**
  119896. * This class is responsible to draw bothe outline/overlay of meshes.
  119897. * It should not be used directly but through the available method on mesh.
  119898. */
  119899. export class OutlineRenderer implements ISceneComponent {
  119900. /**
  119901. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  119902. */
  119903. private static _StencilReference;
  119904. /**
  119905. * The name of the component. Each component must have a unique name.
  119906. */
  119907. name: string;
  119908. /**
  119909. * The scene the component belongs to.
  119910. */
  119911. scene: Scene;
  119912. /**
  119913. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  119914. */
  119915. zOffset: number;
  119916. private _engine;
  119917. private _effect;
  119918. private _cachedDefines;
  119919. private _savedDepthWrite;
  119920. /**
  119921. * Instantiates a new outline renderer. (There could be only one per scene).
  119922. * @param scene Defines the scene it belongs to
  119923. */
  119924. constructor(scene: Scene);
  119925. /**
  119926. * Register the component to one instance of a scene.
  119927. */
  119928. register(): void;
  119929. /**
  119930. * Rebuilds the elements related to this component in case of
  119931. * context lost for instance.
  119932. */
  119933. rebuild(): void;
  119934. /**
  119935. * Disposes the component and the associated ressources.
  119936. */
  119937. dispose(): void;
  119938. /**
  119939. * Renders the outline in the canvas.
  119940. * @param subMesh Defines the sumesh to render
  119941. * @param batch Defines the batch of meshes in case of instances
  119942. * @param useOverlay Defines if the rendering is for the overlay or the outline
  119943. */
  119944. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  119945. /**
  119946. * Returns whether or not the outline renderer is ready for a given submesh.
  119947. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  119948. * @param subMesh Defines the submesh to check readyness for
  119949. * @param useInstances Defines wheter wee are trying to render instances or not
  119950. * @returns true if ready otherwise false
  119951. */
  119952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119953. private _beforeRenderingMesh;
  119954. private _afterRenderingMesh;
  119955. }
  119956. }
  119957. declare module BABYLON {
  119958. /**
  119959. * Defines the list of states available for a task inside a AssetsManager
  119960. */
  119961. export enum AssetTaskState {
  119962. /**
  119963. * Initialization
  119964. */
  119965. INIT = 0,
  119966. /**
  119967. * Running
  119968. */
  119969. RUNNING = 1,
  119970. /**
  119971. * Done
  119972. */
  119973. DONE = 2,
  119974. /**
  119975. * Error
  119976. */
  119977. ERROR = 3
  119978. }
  119979. /**
  119980. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  119981. */
  119982. export abstract class AbstractAssetTask {
  119983. /**
  119984. * Task name
  119985. */ name: string;
  119986. /**
  119987. * Callback called when the task is successful
  119988. */
  119989. onSuccess: (task: any) => void;
  119990. /**
  119991. * Callback called when the task is not successful
  119992. */
  119993. onError: (task: any, message?: string, exception?: any) => void;
  119994. /**
  119995. * Creates a new AssetsManager
  119996. * @param name defines the name of the task
  119997. */
  119998. constructor(
  119999. /**
  120000. * Task name
  120001. */ name: string);
  120002. private _isCompleted;
  120003. private _taskState;
  120004. private _errorObject;
  120005. /**
  120006. * Get if the task is completed
  120007. */
  120008. readonly isCompleted: boolean;
  120009. /**
  120010. * Gets the current state of the task
  120011. */
  120012. readonly taskState: AssetTaskState;
  120013. /**
  120014. * Gets the current error object (if task is in error)
  120015. */
  120016. readonly errorObject: {
  120017. message?: string;
  120018. exception?: any;
  120019. };
  120020. /**
  120021. * Internal only
  120022. * @hidden
  120023. */
  120024. _setErrorObject(message?: string, exception?: any): void;
  120025. /**
  120026. * Execute the current task
  120027. * @param scene defines the scene where you want your assets to be loaded
  120028. * @param onSuccess is a callback called when the task is successfully executed
  120029. * @param onError is a callback called if an error occurs
  120030. */
  120031. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120032. /**
  120033. * Execute the current task
  120034. * @param scene defines the scene where you want your assets to be loaded
  120035. * @param onSuccess is a callback called when the task is successfully executed
  120036. * @param onError is a callback called if an error occurs
  120037. */
  120038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120039. /**
  120040. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120041. * This can be used with failed tasks that have the reason for failure fixed.
  120042. */
  120043. reset(): void;
  120044. private onErrorCallback;
  120045. private onDoneCallback;
  120046. }
  120047. /**
  120048. * Define the interface used by progress events raised during assets loading
  120049. */
  120050. export interface IAssetsProgressEvent {
  120051. /**
  120052. * Defines the number of remaining tasks to process
  120053. */
  120054. remainingCount: number;
  120055. /**
  120056. * Defines the total number of tasks
  120057. */
  120058. totalCount: number;
  120059. /**
  120060. * Defines the task that was just processed
  120061. */
  120062. task: AbstractAssetTask;
  120063. }
  120064. /**
  120065. * Class used to share progress information about assets loading
  120066. */
  120067. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120068. /**
  120069. * Defines the number of remaining tasks to process
  120070. */
  120071. remainingCount: number;
  120072. /**
  120073. * Defines the total number of tasks
  120074. */
  120075. totalCount: number;
  120076. /**
  120077. * Defines the task that was just processed
  120078. */
  120079. task: AbstractAssetTask;
  120080. /**
  120081. * Creates a AssetsProgressEvent
  120082. * @param remainingCount defines the number of remaining tasks to process
  120083. * @param totalCount defines the total number of tasks
  120084. * @param task defines the task that was just processed
  120085. */
  120086. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120087. }
  120088. /**
  120089. * Define a task used by AssetsManager to load meshes
  120090. */
  120091. export class MeshAssetTask extends AbstractAssetTask {
  120092. /**
  120093. * Defines the name of the task
  120094. */
  120095. name: string;
  120096. /**
  120097. * Defines the list of mesh's names you want to load
  120098. */
  120099. meshesNames: any;
  120100. /**
  120101. * Defines the root url to use as a base to load your meshes and associated resources
  120102. */
  120103. rootUrl: string;
  120104. /**
  120105. * Defines the filename of the scene to load from
  120106. */
  120107. sceneFilename: string;
  120108. /**
  120109. * Gets the list of loaded meshes
  120110. */
  120111. loadedMeshes: Array<AbstractMesh>;
  120112. /**
  120113. * Gets the list of loaded particle systems
  120114. */
  120115. loadedParticleSystems: Array<IParticleSystem>;
  120116. /**
  120117. * Gets the list of loaded skeletons
  120118. */
  120119. loadedSkeletons: Array<Skeleton>;
  120120. /**
  120121. * Gets the list of loaded animation groups
  120122. */
  120123. loadedAnimationGroups: Array<AnimationGroup>;
  120124. /**
  120125. * Callback called when the task is successful
  120126. */
  120127. onSuccess: (task: MeshAssetTask) => void;
  120128. /**
  120129. * Callback called when the task is successful
  120130. */
  120131. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120132. /**
  120133. * Creates a new MeshAssetTask
  120134. * @param name defines the name of the task
  120135. * @param meshesNames defines the list of mesh's names you want to load
  120136. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120137. * @param sceneFilename defines the filename of the scene to load from
  120138. */
  120139. constructor(
  120140. /**
  120141. * Defines the name of the task
  120142. */
  120143. name: string,
  120144. /**
  120145. * Defines the list of mesh's names you want to load
  120146. */
  120147. meshesNames: any,
  120148. /**
  120149. * Defines the root url to use as a base to load your meshes and associated resources
  120150. */
  120151. rootUrl: string,
  120152. /**
  120153. * Defines the filename of the scene to load from
  120154. */
  120155. sceneFilename: string);
  120156. /**
  120157. * Execute the current task
  120158. * @param scene defines the scene where you want your assets to be loaded
  120159. * @param onSuccess is a callback called when the task is successfully executed
  120160. * @param onError is a callback called if an error occurs
  120161. */
  120162. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120163. }
  120164. /**
  120165. * Define a task used by AssetsManager to load text content
  120166. */
  120167. export class TextFileAssetTask extends AbstractAssetTask {
  120168. /**
  120169. * Defines the name of the task
  120170. */
  120171. name: string;
  120172. /**
  120173. * Defines the location of the file to load
  120174. */
  120175. url: string;
  120176. /**
  120177. * Gets the loaded text string
  120178. */
  120179. text: string;
  120180. /**
  120181. * Callback called when the task is successful
  120182. */
  120183. onSuccess: (task: TextFileAssetTask) => void;
  120184. /**
  120185. * Callback called when the task is successful
  120186. */
  120187. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120188. /**
  120189. * Creates a new TextFileAssetTask object
  120190. * @param name defines the name of the task
  120191. * @param url defines the location of the file to load
  120192. */
  120193. constructor(
  120194. /**
  120195. * Defines the name of the task
  120196. */
  120197. name: string,
  120198. /**
  120199. * Defines the location of the file to load
  120200. */
  120201. url: string);
  120202. /**
  120203. * Execute the current task
  120204. * @param scene defines the scene where you want your assets to be loaded
  120205. * @param onSuccess is a callback called when the task is successfully executed
  120206. * @param onError is a callback called if an error occurs
  120207. */
  120208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120209. }
  120210. /**
  120211. * Define a task used by AssetsManager to load binary data
  120212. */
  120213. export class BinaryFileAssetTask extends AbstractAssetTask {
  120214. /**
  120215. * Defines the name of the task
  120216. */
  120217. name: string;
  120218. /**
  120219. * Defines the location of the file to load
  120220. */
  120221. url: string;
  120222. /**
  120223. * Gets the lodaded data (as an array buffer)
  120224. */
  120225. data: ArrayBuffer;
  120226. /**
  120227. * Callback called when the task is successful
  120228. */
  120229. onSuccess: (task: BinaryFileAssetTask) => void;
  120230. /**
  120231. * Callback called when the task is successful
  120232. */
  120233. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120234. /**
  120235. * Creates a new BinaryFileAssetTask object
  120236. * @param name defines the name of the new task
  120237. * @param url defines the location of the file to load
  120238. */
  120239. constructor(
  120240. /**
  120241. * Defines the name of the task
  120242. */
  120243. name: string,
  120244. /**
  120245. * Defines the location of the file to load
  120246. */
  120247. url: string);
  120248. /**
  120249. * Execute the current task
  120250. * @param scene defines the scene where you want your assets to be loaded
  120251. * @param onSuccess is a callback called when the task is successfully executed
  120252. * @param onError is a callback called if an error occurs
  120253. */
  120254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120255. }
  120256. /**
  120257. * Define a task used by AssetsManager to load images
  120258. */
  120259. export class ImageAssetTask extends AbstractAssetTask {
  120260. /**
  120261. * Defines the name of the task
  120262. */
  120263. name: string;
  120264. /**
  120265. * Defines the location of the image to load
  120266. */
  120267. url: string;
  120268. /**
  120269. * Gets the loaded images
  120270. */
  120271. image: HTMLImageElement;
  120272. /**
  120273. * Callback called when the task is successful
  120274. */
  120275. onSuccess: (task: ImageAssetTask) => void;
  120276. /**
  120277. * Callback called when the task is successful
  120278. */
  120279. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120280. /**
  120281. * Creates a new ImageAssetTask
  120282. * @param name defines the name of the task
  120283. * @param url defines the location of the image to load
  120284. */
  120285. constructor(
  120286. /**
  120287. * Defines the name of the task
  120288. */
  120289. name: string,
  120290. /**
  120291. * Defines the location of the image to load
  120292. */
  120293. url: string);
  120294. /**
  120295. * Execute the current task
  120296. * @param scene defines the scene where you want your assets to be loaded
  120297. * @param onSuccess is a callback called when the task is successfully executed
  120298. * @param onError is a callback called if an error occurs
  120299. */
  120300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120301. }
  120302. /**
  120303. * Defines the interface used by texture loading tasks
  120304. */
  120305. export interface ITextureAssetTask<TEX extends BaseTexture> {
  120306. /**
  120307. * Gets the loaded texture
  120308. */
  120309. texture: TEX;
  120310. }
  120311. /**
  120312. * Define a task used by AssetsManager to load 2D textures
  120313. */
  120314. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  120315. /**
  120316. * Defines the name of the task
  120317. */
  120318. name: string;
  120319. /**
  120320. * Defines the location of the file to load
  120321. */
  120322. url: string;
  120323. /**
  120324. * Defines if mipmap should not be generated (default is false)
  120325. */
  120326. noMipmap?: boolean | undefined;
  120327. /**
  120328. * Defines if texture must be inverted on Y axis (default is false)
  120329. */
  120330. invertY?: boolean | undefined;
  120331. /**
  120332. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120333. */
  120334. samplingMode: number;
  120335. /**
  120336. * Gets the loaded texture
  120337. */
  120338. texture: Texture;
  120339. /**
  120340. * Callback called when the task is successful
  120341. */
  120342. onSuccess: (task: TextureAssetTask) => void;
  120343. /**
  120344. * Callback called when the task is successful
  120345. */
  120346. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  120347. /**
  120348. * Creates a new TextureAssetTask object
  120349. * @param name defines the name of the task
  120350. * @param url defines the location of the file to load
  120351. * @param noMipmap defines if mipmap should not be generated (default is false)
  120352. * @param invertY defines if texture must be inverted on Y axis (default is false)
  120353. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120354. */
  120355. constructor(
  120356. /**
  120357. * Defines the name of the task
  120358. */
  120359. name: string,
  120360. /**
  120361. * Defines the location of the file to load
  120362. */
  120363. url: string,
  120364. /**
  120365. * Defines if mipmap should not be generated (default is false)
  120366. */
  120367. noMipmap?: boolean | undefined,
  120368. /**
  120369. * Defines if texture must be inverted on Y axis (default is false)
  120370. */
  120371. invertY?: boolean | undefined,
  120372. /**
  120373. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120374. */
  120375. samplingMode?: number);
  120376. /**
  120377. * Execute the current task
  120378. * @param scene defines the scene where you want your assets to be loaded
  120379. * @param onSuccess is a callback called when the task is successfully executed
  120380. * @param onError is a callback called if an error occurs
  120381. */
  120382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120383. }
  120384. /**
  120385. * Define a task used by AssetsManager to load cube textures
  120386. */
  120387. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  120388. /**
  120389. * Defines the name of the task
  120390. */
  120391. name: string;
  120392. /**
  120393. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120394. */
  120395. url: string;
  120396. /**
  120397. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120398. */
  120399. extensions?: string[] | undefined;
  120400. /**
  120401. * Defines if mipmaps should not be generated (default is false)
  120402. */
  120403. noMipmap?: boolean | undefined;
  120404. /**
  120405. * Defines the explicit list of files (undefined by default)
  120406. */
  120407. files?: string[] | undefined;
  120408. /**
  120409. * Gets the loaded texture
  120410. */
  120411. texture: CubeTexture;
  120412. /**
  120413. * Callback called when the task is successful
  120414. */
  120415. onSuccess: (task: CubeTextureAssetTask) => void;
  120416. /**
  120417. * Callback called when the task is successful
  120418. */
  120419. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  120420. /**
  120421. * Creates a new CubeTextureAssetTask
  120422. * @param name defines the name of the task
  120423. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120424. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120425. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120426. * @param files defines the explicit list of files (undefined by default)
  120427. */
  120428. constructor(
  120429. /**
  120430. * Defines the name of the task
  120431. */
  120432. name: string,
  120433. /**
  120434. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120435. */
  120436. url: string,
  120437. /**
  120438. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120439. */
  120440. extensions?: string[] | undefined,
  120441. /**
  120442. * Defines if mipmaps should not be generated (default is false)
  120443. */
  120444. noMipmap?: boolean | undefined,
  120445. /**
  120446. * Defines the explicit list of files (undefined by default)
  120447. */
  120448. files?: string[] | undefined);
  120449. /**
  120450. * Execute the current task
  120451. * @param scene defines the scene where you want your assets to be loaded
  120452. * @param onSuccess is a callback called when the task is successfully executed
  120453. * @param onError is a callback called if an error occurs
  120454. */
  120455. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120456. }
  120457. /**
  120458. * Define a task used by AssetsManager to load HDR cube textures
  120459. */
  120460. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  120461. /**
  120462. * Defines the name of the task
  120463. */
  120464. name: string;
  120465. /**
  120466. * Defines the location of the file to load
  120467. */
  120468. url: string;
  120469. /**
  120470. * Defines the desired size (the more it increases the longer the generation will be)
  120471. */
  120472. size: number;
  120473. /**
  120474. * Defines if mipmaps should not be generated (default is false)
  120475. */
  120476. noMipmap: boolean;
  120477. /**
  120478. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120479. */
  120480. generateHarmonics: boolean;
  120481. /**
  120482. * 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)
  120483. */
  120484. gammaSpace: boolean;
  120485. /**
  120486. * Internal Use Only
  120487. */
  120488. reserved: boolean;
  120489. /**
  120490. * Gets the loaded texture
  120491. */
  120492. texture: HDRCubeTexture;
  120493. /**
  120494. * Callback called when the task is successful
  120495. */
  120496. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  120497. /**
  120498. * Callback called when the task is successful
  120499. */
  120500. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  120501. /**
  120502. * Creates a new HDRCubeTextureAssetTask object
  120503. * @param name defines the name of the task
  120504. * @param url defines the location of the file to load
  120505. * @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.
  120506. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120507. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120508. * @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)
  120509. * @param reserved Internal use only
  120510. */
  120511. constructor(
  120512. /**
  120513. * Defines the name of the task
  120514. */
  120515. name: string,
  120516. /**
  120517. * Defines the location of the file to load
  120518. */
  120519. url: string,
  120520. /**
  120521. * Defines the desired size (the more it increases the longer the generation will be)
  120522. */
  120523. size: number,
  120524. /**
  120525. * Defines if mipmaps should not be generated (default is false)
  120526. */
  120527. noMipmap?: boolean,
  120528. /**
  120529. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120530. */
  120531. generateHarmonics?: boolean,
  120532. /**
  120533. * 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)
  120534. */
  120535. gammaSpace?: boolean,
  120536. /**
  120537. * Internal Use Only
  120538. */
  120539. reserved?: boolean);
  120540. /**
  120541. * Execute the current task
  120542. * @param scene defines the scene where you want your assets to be loaded
  120543. * @param onSuccess is a callback called when the task is successfully executed
  120544. * @param onError is a callback called if an error occurs
  120545. */
  120546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120547. }
  120548. /**
  120549. * Define a task used by AssetsManager to load Equirectangular cube textures
  120550. */
  120551. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  120552. /**
  120553. * Defines the name of the task
  120554. */
  120555. name: string;
  120556. /**
  120557. * Defines the location of the file to load
  120558. */
  120559. url: string;
  120560. /**
  120561. * Defines the desired size (the more it increases the longer the generation will be)
  120562. */
  120563. size: number;
  120564. /**
  120565. * Defines if mipmaps should not be generated (default is false)
  120566. */
  120567. noMipmap: boolean;
  120568. /**
  120569. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120570. * but the standard material would require them in Gamma space) (default is true)
  120571. */
  120572. gammaSpace: boolean;
  120573. /**
  120574. * Gets the loaded texture
  120575. */
  120576. texture: EquiRectangularCubeTexture;
  120577. /**
  120578. * Callback called when the task is successful
  120579. */
  120580. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  120581. /**
  120582. * Callback called when the task is successful
  120583. */
  120584. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  120585. /**
  120586. * Creates a new EquiRectangularCubeTextureAssetTask object
  120587. * @param name defines the name of the task
  120588. * @param url defines the location of the file to load
  120589. * @param size defines the desired size (the more it increases the longer the generation will be)
  120590. * If the size is omitted this implies you are using a preprocessed cubemap.
  120591. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120592. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  120593. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  120594. * (default is true)
  120595. */
  120596. constructor(
  120597. /**
  120598. * Defines the name of the task
  120599. */
  120600. name: string,
  120601. /**
  120602. * Defines the location of the file to load
  120603. */
  120604. url: string,
  120605. /**
  120606. * Defines the desired size (the more it increases the longer the generation will be)
  120607. */
  120608. size: number,
  120609. /**
  120610. * Defines if mipmaps should not be generated (default is false)
  120611. */
  120612. noMipmap?: boolean,
  120613. /**
  120614. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120615. * but the standard material would require them in Gamma space) (default is true)
  120616. */
  120617. gammaSpace?: boolean);
  120618. /**
  120619. * Execute the current task
  120620. * @param scene defines the scene where you want your assets to be loaded
  120621. * @param onSuccess is a callback called when the task is successfully executed
  120622. * @param onError is a callback called if an error occurs
  120623. */
  120624. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120625. }
  120626. /**
  120627. * This class can be used to easily import assets into a scene
  120628. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  120629. */
  120630. export class AssetsManager {
  120631. private _scene;
  120632. private _isLoading;
  120633. protected _tasks: AbstractAssetTask[];
  120634. protected _waitingTasksCount: number;
  120635. protected _totalTasksCount: number;
  120636. /**
  120637. * Callback called when all tasks are processed
  120638. */
  120639. onFinish: (tasks: AbstractAssetTask[]) => void;
  120640. /**
  120641. * Callback called when a task is successful
  120642. */
  120643. onTaskSuccess: (task: AbstractAssetTask) => void;
  120644. /**
  120645. * Callback called when a task had an error
  120646. */
  120647. onTaskError: (task: AbstractAssetTask) => void;
  120648. /**
  120649. * Callback called when a task is done (whatever the result is)
  120650. */
  120651. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  120652. /**
  120653. * Observable called when all tasks are processed
  120654. */
  120655. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  120656. /**
  120657. * Observable called when a task had an error
  120658. */
  120659. onTaskErrorObservable: Observable<AbstractAssetTask>;
  120660. /**
  120661. * Observable called when all tasks were executed
  120662. */
  120663. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  120664. /**
  120665. * Observable called when a task is done (whatever the result is)
  120666. */
  120667. onProgressObservable: Observable<IAssetsProgressEvent>;
  120668. /**
  120669. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  120670. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120671. */
  120672. useDefaultLoadingScreen: boolean;
  120673. /**
  120674. * Creates a new AssetsManager
  120675. * @param scene defines the scene to work on
  120676. */
  120677. constructor(scene: Scene);
  120678. /**
  120679. * Add a MeshAssetTask to the list of active tasks
  120680. * @param taskName defines the name of the new task
  120681. * @param meshesNames defines the name of meshes to load
  120682. * @param rootUrl defines the root url to use to locate files
  120683. * @param sceneFilename defines the filename of the scene file
  120684. * @returns a new MeshAssetTask object
  120685. */
  120686. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  120687. /**
  120688. * Add a TextFileAssetTask to the list of active tasks
  120689. * @param taskName defines the name of the new task
  120690. * @param url defines the url of the file to load
  120691. * @returns a new TextFileAssetTask object
  120692. */
  120693. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  120694. /**
  120695. * Add a BinaryFileAssetTask to the list of active tasks
  120696. * @param taskName defines the name of the new task
  120697. * @param url defines the url of the file to load
  120698. * @returns a new BinaryFileAssetTask object
  120699. */
  120700. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  120701. /**
  120702. * Add a ImageAssetTask to the list of active tasks
  120703. * @param taskName defines the name of the new task
  120704. * @param url defines the url of the file to load
  120705. * @returns a new ImageAssetTask object
  120706. */
  120707. addImageTask(taskName: string, url: string): ImageAssetTask;
  120708. /**
  120709. * Add a TextureAssetTask to the list of active tasks
  120710. * @param taskName defines the name of the new task
  120711. * @param url defines the url of the file to load
  120712. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120713. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  120714. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120715. * @returns a new TextureAssetTask object
  120716. */
  120717. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  120718. /**
  120719. * Add a CubeTextureAssetTask to the list of active tasks
  120720. * @param taskName defines the name of the new task
  120721. * @param url defines the url of the file to load
  120722. * @param extensions defines the extension to use to load the cube map (can be null)
  120723. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120724. * @param files defines the list of files to load (can be null)
  120725. * @returns a new CubeTextureAssetTask object
  120726. */
  120727. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  120728. /**
  120729. *
  120730. * Add a HDRCubeTextureAssetTask to the list of active tasks
  120731. * @param taskName defines the name of the new task
  120732. * @param url defines the url of the file to load
  120733. * @param size defines the size you want for the cubemap (can be null)
  120734. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120735. * @param generateHarmonics defines if you want to automatically generate (true by default)
  120736. * @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)
  120737. * @param reserved Internal use only
  120738. * @returns a new HDRCubeTextureAssetTask object
  120739. */
  120740. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  120741. /**
  120742. *
  120743. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  120744. * @param taskName defines the name of the new task
  120745. * @param url defines the url of the file to load
  120746. * @param size defines the size you want for the cubemap (can be null)
  120747. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120748. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120749. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120750. * @returns a new EquiRectangularCubeTextureAssetTask object
  120751. */
  120752. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  120753. /**
  120754. * Remove a task from the assets manager.
  120755. * @param task the task to remove
  120756. */
  120757. removeTask(task: AbstractAssetTask): void;
  120758. private _decreaseWaitingTasksCount;
  120759. private _runTask;
  120760. /**
  120761. * Reset the AssetsManager and remove all tasks
  120762. * @return the current instance of the AssetsManager
  120763. */
  120764. reset(): AssetsManager;
  120765. /**
  120766. * Start the loading process
  120767. * @return the current instance of the AssetsManager
  120768. */
  120769. load(): AssetsManager;
  120770. /**
  120771. * Start the loading process as an async operation
  120772. * @return a promise returning the list of failed tasks
  120773. */
  120774. loadAsync(): Promise<void>;
  120775. }
  120776. }
  120777. declare module BABYLON {
  120778. /**
  120779. * Wrapper class for promise with external resolve and reject.
  120780. */
  120781. export class Deferred<T> {
  120782. /**
  120783. * The promise associated with this deferred object.
  120784. */
  120785. readonly promise: Promise<T>;
  120786. private _resolve;
  120787. private _reject;
  120788. /**
  120789. * The resolve method of the promise associated with this deferred object.
  120790. */
  120791. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  120792. /**
  120793. * The reject method of the promise associated with this deferred object.
  120794. */
  120795. readonly reject: (reason?: any) => void;
  120796. /**
  120797. * Constructor for this deferred object.
  120798. */
  120799. constructor();
  120800. }
  120801. }
  120802. declare module BABYLON {
  120803. /**
  120804. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  120805. */
  120806. export class MeshExploder {
  120807. private _centerMesh;
  120808. private _meshes;
  120809. private _meshesOrigins;
  120810. private _toCenterVectors;
  120811. private _scaledDirection;
  120812. private _newPosition;
  120813. private _centerPosition;
  120814. /**
  120815. * Explodes meshes from a center mesh.
  120816. * @param meshes The meshes to explode.
  120817. * @param centerMesh The mesh to be center of explosion.
  120818. */
  120819. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  120820. private _setCenterMesh;
  120821. /**
  120822. * Get class name
  120823. * @returns "MeshExploder"
  120824. */
  120825. getClassName(): string;
  120826. /**
  120827. * "Exploded meshes"
  120828. * @returns Array of meshes with the centerMesh at index 0.
  120829. */
  120830. getMeshes(): Array<Mesh>;
  120831. /**
  120832. * Explodes meshes giving a specific direction
  120833. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  120834. */
  120835. explode(direction?: number): void;
  120836. }
  120837. }
  120838. declare module BABYLON {
  120839. /**
  120840. * Class used to help managing file picking and drag'n'drop
  120841. */
  120842. export class FilesInput {
  120843. /**
  120844. * List of files ready to be loaded
  120845. */
  120846. static readonly FilesToLoad: {
  120847. [key: string]: File;
  120848. };
  120849. /**
  120850. * Callback called when a file is processed
  120851. */
  120852. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  120853. private _engine;
  120854. private _currentScene;
  120855. private _sceneLoadedCallback;
  120856. private _progressCallback;
  120857. private _additionalRenderLoopLogicCallback;
  120858. private _textureLoadingCallback;
  120859. private _startingProcessingFilesCallback;
  120860. private _onReloadCallback;
  120861. private _errorCallback;
  120862. private _elementToMonitor;
  120863. private _sceneFileToLoad;
  120864. private _filesToLoad;
  120865. /**
  120866. * Creates a new FilesInput
  120867. * @param engine defines the rendering engine
  120868. * @param scene defines the hosting scene
  120869. * @param sceneLoadedCallback callback called when scene is loaded
  120870. * @param progressCallback callback called to track progress
  120871. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  120872. * @param textureLoadingCallback callback called when a texture is loading
  120873. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  120874. * @param onReloadCallback callback called when a reload is requested
  120875. * @param errorCallback callback call if an error occurs
  120876. */
  120877. 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);
  120878. private _dragEnterHandler;
  120879. private _dragOverHandler;
  120880. private _dropHandler;
  120881. /**
  120882. * Calls this function to listen to drag'n'drop events on a specific DOM element
  120883. * @param elementToMonitor defines the DOM element to track
  120884. */
  120885. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  120886. /**
  120887. * Release all associated resources
  120888. */
  120889. dispose(): void;
  120890. private renderFunction;
  120891. private drag;
  120892. private drop;
  120893. private _traverseFolder;
  120894. private _processFiles;
  120895. /**
  120896. * Load files from a drop event
  120897. * @param event defines the drop event to use as source
  120898. */
  120899. loadFiles(event: any): void;
  120900. private _processReload;
  120901. /**
  120902. * Reload the current scene from the loaded files
  120903. */
  120904. reload(): void;
  120905. }
  120906. }
  120907. declare module BABYLON {
  120908. /**
  120909. * Defines the root class used to create scene optimization to use with SceneOptimizer
  120910. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120911. */
  120912. export class SceneOptimization {
  120913. /**
  120914. * Defines the priority of this optimization (0 by default which means first in the list)
  120915. */
  120916. priority: number;
  120917. /**
  120918. * Gets a string describing the action executed by the current optimization
  120919. * @returns description string
  120920. */
  120921. getDescription(): string;
  120922. /**
  120923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120924. * @param scene defines the current scene where to apply this optimization
  120925. * @param optimizer defines the current optimizer
  120926. * @returns true if everything that can be done was applied
  120927. */
  120928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120929. /**
  120930. * Creates the SceneOptimization object
  120931. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120932. * @param desc defines the description associated with the optimization
  120933. */
  120934. constructor(
  120935. /**
  120936. * Defines the priority of this optimization (0 by default which means first in the list)
  120937. */
  120938. priority?: number);
  120939. }
  120940. /**
  120941. * Defines an optimization used to reduce the size of render target textures
  120942. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120943. */
  120944. export class TextureOptimization extends SceneOptimization {
  120945. /**
  120946. * Defines the priority of this optimization (0 by default which means first in the list)
  120947. */
  120948. priority: number;
  120949. /**
  120950. * 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
  120951. */
  120952. maximumSize: number;
  120953. /**
  120954. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120955. */
  120956. step: number;
  120957. /**
  120958. * Gets a string describing the action executed by the current optimization
  120959. * @returns description string
  120960. */
  120961. getDescription(): string;
  120962. /**
  120963. * Creates the TextureOptimization object
  120964. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120965. * @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
  120966. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120967. */
  120968. constructor(
  120969. /**
  120970. * Defines the priority of this optimization (0 by default which means first in the list)
  120971. */
  120972. priority?: number,
  120973. /**
  120974. * 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
  120975. */
  120976. maximumSize?: number,
  120977. /**
  120978. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120979. */
  120980. step?: number);
  120981. /**
  120982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120983. * @param scene defines the current scene where to apply this optimization
  120984. * @param optimizer defines the current optimizer
  120985. * @returns true if everything that can be done was applied
  120986. */
  120987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120988. }
  120989. /**
  120990. * Defines an optimization used to increase or decrease the rendering resolution
  120991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120992. */
  120993. export class HardwareScalingOptimization extends SceneOptimization {
  120994. /**
  120995. * Defines the priority of this optimization (0 by default which means first in the list)
  120996. */
  120997. priority: number;
  120998. /**
  120999. * Defines the maximum scale to use (2 by default)
  121000. */
  121001. maximumScale: number;
  121002. /**
  121003. * Defines the step to use between two passes (0.5 by default)
  121004. */
  121005. step: number;
  121006. private _currentScale;
  121007. private _directionOffset;
  121008. /**
  121009. * Gets a string describing the action executed by the current optimization
  121010. * @return description string
  121011. */
  121012. getDescription(): string;
  121013. /**
  121014. * Creates the HardwareScalingOptimization object
  121015. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121016. * @param maximumScale defines the maximum scale to use (2 by default)
  121017. * @param step defines the step to use between two passes (0.5 by default)
  121018. */
  121019. constructor(
  121020. /**
  121021. * Defines the priority of this optimization (0 by default which means first in the list)
  121022. */
  121023. priority?: number,
  121024. /**
  121025. * Defines the maximum scale to use (2 by default)
  121026. */
  121027. maximumScale?: number,
  121028. /**
  121029. * Defines the step to use between two passes (0.5 by default)
  121030. */
  121031. step?: number);
  121032. /**
  121033. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121034. * @param scene defines the current scene where to apply this optimization
  121035. * @param optimizer defines the current optimizer
  121036. * @returns true if everything that can be done was applied
  121037. */
  121038. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121039. }
  121040. /**
  121041. * Defines an optimization used to remove shadows
  121042. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121043. */
  121044. export class ShadowsOptimization extends SceneOptimization {
  121045. /**
  121046. * Gets a string describing the action executed by the current optimization
  121047. * @return description string
  121048. */
  121049. getDescription(): string;
  121050. /**
  121051. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121052. * @param scene defines the current scene where to apply this optimization
  121053. * @param optimizer defines the current optimizer
  121054. * @returns true if everything that can be done was applied
  121055. */
  121056. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121057. }
  121058. /**
  121059. * Defines an optimization used to turn post-processes off
  121060. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121061. */
  121062. export class PostProcessesOptimization extends SceneOptimization {
  121063. /**
  121064. * Gets a string describing the action executed by the current optimization
  121065. * @return description string
  121066. */
  121067. getDescription(): string;
  121068. /**
  121069. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121070. * @param scene defines the current scene where to apply this optimization
  121071. * @param optimizer defines the current optimizer
  121072. * @returns true if everything that can be done was applied
  121073. */
  121074. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121075. }
  121076. /**
  121077. * Defines an optimization used to turn lens flares off
  121078. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121079. */
  121080. export class LensFlaresOptimization extends SceneOptimization {
  121081. /**
  121082. * Gets a string describing the action executed by the current optimization
  121083. * @return description string
  121084. */
  121085. getDescription(): string;
  121086. /**
  121087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121088. * @param scene defines the current scene where to apply this optimization
  121089. * @param optimizer defines the current optimizer
  121090. * @returns true if everything that can be done was applied
  121091. */
  121092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121093. }
  121094. /**
  121095. * Defines an optimization based on user defined callback.
  121096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121097. */
  121098. export class CustomOptimization extends SceneOptimization {
  121099. /**
  121100. * Callback called to apply the custom optimization.
  121101. */
  121102. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121103. /**
  121104. * Callback called to get custom description
  121105. */
  121106. onGetDescription: () => string;
  121107. /**
  121108. * Gets a string describing the action executed by the current optimization
  121109. * @returns description string
  121110. */
  121111. getDescription(): string;
  121112. /**
  121113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121114. * @param scene defines the current scene where to apply this optimization
  121115. * @param optimizer defines the current optimizer
  121116. * @returns true if everything that can be done was applied
  121117. */
  121118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121119. }
  121120. /**
  121121. * Defines an optimization used to turn particles off
  121122. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121123. */
  121124. export class ParticlesOptimization extends SceneOptimization {
  121125. /**
  121126. * Gets a string describing the action executed by the current optimization
  121127. * @return description string
  121128. */
  121129. getDescription(): string;
  121130. /**
  121131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121132. * @param scene defines the current scene where to apply this optimization
  121133. * @param optimizer defines the current optimizer
  121134. * @returns true if everything that can be done was applied
  121135. */
  121136. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121137. }
  121138. /**
  121139. * Defines an optimization used to turn render targets off
  121140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121141. */
  121142. export class RenderTargetsOptimization extends SceneOptimization {
  121143. /**
  121144. * Gets a string describing the action executed by the current optimization
  121145. * @return description string
  121146. */
  121147. getDescription(): string;
  121148. /**
  121149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121150. * @param scene defines the current scene where to apply this optimization
  121151. * @param optimizer defines the current optimizer
  121152. * @returns true if everything that can be done was applied
  121153. */
  121154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121155. }
  121156. /**
  121157. * Defines an optimization used to merge meshes with compatible materials
  121158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121159. */
  121160. export class MergeMeshesOptimization extends SceneOptimization {
  121161. private static _UpdateSelectionTree;
  121162. /**
  121163. * Gets or sets a boolean which defines if optimization octree has to be updated
  121164. */
  121165. /**
  121166. * Gets or sets a boolean which defines if optimization octree has to be updated
  121167. */
  121168. static UpdateSelectionTree: boolean;
  121169. /**
  121170. * Gets a string describing the action executed by the current optimization
  121171. * @return description string
  121172. */
  121173. getDescription(): string;
  121174. private _canBeMerged;
  121175. /**
  121176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121177. * @param scene defines the current scene where to apply this optimization
  121178. * @param optimizer defines the current optimizer
  121179. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121180. * @returns true if everything that can be done was applied
  121181. */
  121182. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121183. }
  121184. /**
  121185. * Defines a list of options used by SceneOptimizer
  121186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121187. */
  121188. export class SceneOptimizerOptions {
  121189. /**
  121190. * Defines the target frame rate to reach (60 by default)
  121191. */
  121192. targetFrameRate: number;
  121193. /**
  121194. * Defines the interval between two checkes (2000ms by default)
  121195. */
  121196. trackerDuration: number;
  121197. /**
  121198. * Gets the list of optimizations to apply
  121199. */
  121200. optimizations: SceneOptimization[];
  121201. /**
  121202. * Creates a new list of options used by SceneOptimizer
  121203. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121204. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121205. */
  121206. constructor(
  121207. /**
  121208. * Defines the target frame rate to reach (60 by default)
  121209. */
  121210. targetFrameRate?: number,
  121211. /**
  121212. * Defines the interval between two checkes (2000ms by default)
  121213. */
  121214. trackerDuration?: number);
  121215. /**
  121216. * Add a new optimization
  121217. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121218. * @returns the current SceneOptimizerOptions
  121219. */
  121220. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121221. /**
  121222. * Add a new custom optimization
  121223. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121224. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121225. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121226. * @returns the current SceneOptimizerOptions
  121227. */
  121228. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121229. /**
  121230. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121231. * @param targetFrameRate defines the target frame rate (60 by default)
  121232. * @returns a SceneOptimizerOptions object
  121233. */
  121234. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121235. /**
  121236. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121237. * @param targetFrameRate defines the target frame rate (60 by default)
  121238. * @returns a SceneOptimizerOptions object
  121239. */
  121240. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121241. /**
  121242. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121243. * @param targetFrameRate defines the target frame rate (60 by default)
  121244. * @returns a SceneOptimizerOptions object
  121245. */
  121246. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121247. }
  121248. /**
  121249. * Class used to run optimizations in order to reach a target frame rate
  121250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121251. */
  121252. export class SceneOptimizer implements IDisposable {
  121253. private _isRunning;
  121254. private _options;
  121255. private _scene;
  121256. private _currentPriorityLevel;
  121257. private _targetFrameRate;
  121258. private _trackerDuration;
  121259. private _currentFrameRate;
  121260. private _sceneDisposeObserver;
  121261. private _improvementMode;
  121262. /**
  121263. * Defines an observable called when the optimizer reaches the target frame rate
  121264. */
  121265. onSuccessObservable: Observable<SceneOptimizer>;
  121266. /**
  121267. * Defines an observable called when the optimizer enables an optimization
  121268. */
  121269. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121270. /**
  121271. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121272. */
  121273. onFailureObservable: Observable<SceneOptimizer>;
  121274. /**
  121275. * Gets a boolean indicating if the optimizer is in improvement mode
  121276. */
  121277. readonly isInImprovementMode: boolean;
  121278. /**
  121279. * Gets the current priority level (0 at start)
  121280. */
  121281. readonly currentPriorityLevel: number;
  121282. /**
  121283. * Gets the current frame rate checked by the SceneOptimizer
  121284. */
  121285. readonly currentFrameRate: number;
  121286. /**
  121287. * Gets or sets the current target frame rate (60 by default)
  121288. */
  121289. /**
  121290. * Gets or sets the current target frame rate (60 by default)
  121291. */
  121292. targetFrameRate: number;
  121293. /**
  121294. * Gets or sets the current interval between two checks (every 2000ms by default)
  121295. */
  121296. /**
  121297. * Gets or sets the current interval between two checks (every 2000ms by default)
  121298. */
  121299. trackerDuration: number;
  121300. /**
  121301. * Gets the list of active optimizations
  121302. */
  121303. readonly optimizations: SceneOptimization[];
  121304. /**
  121305. * Creates a new SceneOptimizer
  121306. * @param scene defines the scene to work on
  121307. * @param options defines the options to use with the SceneOptimizer
  121308. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  121309. * @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)
  121310. */
  121311. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  121312. /**
  121313. * Stops the current optimizer
  121314. */
  121315. stop(): void;
  121316. /**
  121317. * Reset the optimizer to initial step (current priority level = 0)
  121318. */
  121319. reset(): void;
  121320. /**
  121321. * Start the optimizer. By default it will try to reach a specific framerate
  121322. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  121323. */
  121324. start(): void;
  121325. private _checkCurrentState;
  121326. /**
  121327. * Release all resources
  121328. */
  121329. dispose(): void;
  121330. /**
  121331. * Helper function to create a SceneOptimizer with one single line of code
  121332. * @param scene defines the scene to work on
  121333. * @param options defines the options to use with the SceneOptimizer
  121334. * @param onSuccess defines a callback to call on success
  121335. * @param onFailure defines a callback to call on failure
  121336. * @returns the new SceneOptimizer object
  121337. */
  121338. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  121339. }
  121340. }
  121341. declare module BABYLON {
  121342. /**
  121343. * Class used to serialize a scene into a string
  121344. */
  121345. export class SceneSerializer {
  121346. /**
  121347. * Clear cache used by a previous serialization
  121348. */
  121349. static ClearCache(): void;
  121350. /**
  121351. * Serialize a scene into a JSON compatible object
  121352. * @param scene defines the scene to serialize
  121353. * @returns a JSON compatible object
  121354. */
  121355. static Serialize(scene: Scene): any;
  121356. /**
  121357. * Serialize a mesh into a JSON compatible object
  121358. * @param toSerialize defines the mesh to serialize
  121359. * @param withParents defines if parents must be serialized as well
  121360. * @param withChildren defines if children must be serialized as well
  121361. * @returns a JSON compatible object
  121362. */
  121363. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  121364. }
  121365. }
  121366. declare module BABYLON {
  121367. /**
  121368. * Class used to host texture specific utilities
  121369. */
  121370. export class TextureTools {
  121371. /**
  121372. * Uses the GPU to create a copy texture rescaled at a given size
  121373. * @param texture Texture to copy from
  121374. * @param width defines the desired width
  121375. * @param height defines the desired height
  121376. * @param useBilinearMode defines if bilinear mode has to be used
  121377. * @return the generated texture
  121378. */
  121379. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  121380. }
  121381. }
  121382. declare module BABYLON {
  121383. /**
  121384. * This represents the different options available for the video capture.
  121385. */
  121386. export interface VideoRecorderOptions {
  121387. /** Defines the mime type of the video. */
  121388. mimeType: string;
  121389. /** Defines the FPS the video should be recorded at. */
  121390. fps: number;
  121391. /** Defines the chunk size for the recording data. */
  121392. recordChunckSize: number;
  121393. /** The audio tracks to attach to the recording. */
  121394. audioTracks?: MediaStreamTrack[];
  121395. }
  121396. /**
  121397. * This can help with recording videos from BabylonJS.
  121398. * This is based on the available WebRTC functionalities of the browser.
  121399. *
  121400. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  121401. */
  121402. export class VideoRecorder {
  121403. private static readonly _defaultOptions;
  121404. /**
  121405. * Returns whether or not the VideoRecorder is available in your browser.
  121406. * @param engine Defines the Babylon Engine.
  121407. * @returns true if supported otherwise false.
  121408. */
  121409. static IsSupported(engine: Engine): boolean;
  121410. private readonly _options;
  121411. private _canvas;
  121412. private _mediaRecorder;
  121413. private _recordedChunks;
  121414. private _fileName;
  121415. private _resolve;
  121416. private _reject;
  121417. /**
  121418. * True when a recording is already in progress.
  121419. */
  121420. readonly isRecording: boolean;
  121421. /**
  121422. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  121423. * @param engine Defines the BabylonJS Engine you wish to record.
  121424. * @param options Defines options that can be used to customize the capture.
  121425. */
  121426. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  121427. /**
  121428. * Stops the current recording before the default capture timeout passed in the startRecording function.
  121429. */
  121430. stopRecording(): void;
  121431. /**
  121432. * Starts recording the canvas for a max duration specified in parameters.
  121433. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  121434. * If null no automatic download will start and you can rely on the promise to get the data back.
  121435. * @param maxDuration Defines the maximum recording time in seconds.
  121436. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  121437. * @return A promise callback at the end of the recording with the video data in Blob.
  121438. */
  121439. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  121440. /**
  121441. * Releases internal resources used during the recording.
  121442. */
  121443. dispose(): void;
  121444. private _handleDataAvailable;
  121445. private _handleError;
  121446. private _handleStop;
  121447. }
  121448. }
  121449. declare module BABYLON {
  121450. /**
  121451. * Class containing a set of static utilities functions for screenshots
  121452. */
  121453. export class ScreenshotTools {
  121454. /**
  121455. * Captures a screenshot of the current rendering
  121456. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121457. * @param engine defines the rendering engine
  121458. * @param camera defines the source camera
  121459. * @param size This parameter can be set to a single number or to an object with the
  121460. * following (optional) properties: precision, width, height. If a single number is passed,
  121461. * it will be used for both width and height. If an object is passed, the screenshot size
  121462. * will be derived from the parameters. The precision property is a multiplier allowing
  121463. * rendering at a higher or lower resolution
  121464. * @param successCallback defines the callback receives a single parameter which contains the
  121465. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121466. * src parameter of an <img> to display it
  121467. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  121468. * Check your browser for supported MIME types
  121469. */
  121470. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  121471. /**
  121472. * Generates an image screenshot from the specified camera.
  121473. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121474. * @param engine The engine to use for rendering
  121475. * @param camera The camera to use for rendering
  121476. * @param size This parameter can be set to a single number or to an object with the
  121477. * following (optional) properties: precision, width, height. If a single number is passed,
  121478. * it will be used for both width and height. If an object is passed, the screenshot size
  121479. * will be derived from the parameters. The precision property is a multiplier allowing
  121480. * rendering at a higher or lower resolution
  121481. * @param successCallback The callback receives a single parameter which contains the
  121482. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121483. * src parameter of an <img> to display it
  121484. * @param mimeType The MIME type of the screenshot image (default: image/png).
  121485. * Check your browser for supported MIME types
  121486. * @param samples Texture samples (default: 1)
  121487. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  121488. * @param fileName A name for for the downloaded file.
  121489. */
  121490. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  121491. }
  121492. }
  121493. declare module BABYLON {
  121494. /**
  121495. * A cursor which tracks a point on a path
  121496. */
  121497. export class PathCursor {
  121498. private path;
  121499. /**
  121500. * Stores path cursor callbacks for when an onchange event is triggered
  121501. */
  121502. private _onchange;
  121503. /**
  121504. * The value of the path cursor
  121505. */
  121506. value: number;
  121507. /**
  121508. * The animation array of the path cursor
  121509. */
  121510. animations: Animation[];
  121511. /**
  121512. * Initializes the path cursor
  121513. * @param path The path to track
  121514. */
  121515. constructor(path: Path2);
  121516. /**
  121517. * Gets the cursor point on the path
  121518. * @returns A point on the path cursor at the cursor location
  121519. */
  121520. getPoint(): Vector3;
  121521. /**
  121522. * Moves the cursor ahead by the step amount
  121523. * @param step The amount to move the cursor forward
  121524. * @returns This path cursor
  121525. */
  121526. moveAhead(step?: number): PathCursor;
  121527. /**
  121528. * Moves the cursor behind by the step amount
  121529. * @param step The amount to move the cursor back
  121530. * @returns This path cursor
  121531. */
  121532. moveBack(step?: number): PathCursor;
  121533. /**
  121534. * Moves the cursor by the step amount
  121535. * If the step amount is greater than one, an exception is thrown
  121536. * @param step The amount to move the cursor
  121537. * @returns This path cursor
  121538. */
  121539. move(step: number): PathCursor;
  121540. /**
  121541. * Ensures that the value is limited between zero and one
  121542. * @returns This path cursor
  121543. */
  121544. private ensureLimits;
  121545. /**
  121546. * Runs onchange callbacks on change (used by the animation engine)
  121547. * @returns This path cursor
  121548. */
  121549. private raiseOnChange;
  121550. /**
  121551. * Executes a function on change
  121552. * @param f A path cursor onchange callback
  121553. * @returns This path cursor
  121554. */
  121555. onchange(f: (cursor: PathCursor) => void): PathCursor;
  121556. }
  121557. }
  121558. declare module BABYLON {
  121559. /** @hidden */
  121560. export var blurPixelShader: {
  121561. name: string;
  121562. shader: string;
  121563. };
  121564. }
  121565. declare module BABYLON {
  121566. /** @hidden */
  121567. export var bones300Declaration: {
  121568. name: string;
  121569. shader: string;
  121570. };
  121571. }
  121572. declare module BABYLON {
  121573. /** @hidden */
  121574. export var instances300Declaration: {
  121575. name: string;
  121576. shader: string;
  121577. };
  121578. }
  121579. declare module BABYLON {
  121580. /** @hidden */
  121581. export var pointCloudVertexDeclaration: {
  121582. name: string;
  121583. shader: string;
  121584. };
  121585. }
  121586. // Mixins
  121587. interface Window {
  121588. mozIndexedDB: IDBFactory;
  121589. webkitIndexedDB: IDBFactory;
  121590. msIndexedDB: IDBFactory;
  121591. webkitURL: typeof URL;
  121592. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  121593. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  121594. WebGLRenderingContext: WebGLRenderingContext;
  121595. MSGesture: MSGesture;
  121596. CANNON: any;
  121597. AudioContext: AudioContext;
  121598. webkitAudioContext: AudioContext;
  121599. PointerEvent: any;
  121600. Math: Math;
  121601. Uint8Array: Uint8ArrayConstructor;
  121602. Float32Array: Float32ArrayConstructor;
  121603. mozURL: typeof URL;
  121604. msURL: typeof URL;
  121605. VRFrameData: any; // WebVR, from specs 1.1
  121606. DracoDecoderModule: any;
  121607. setImmediate(handler: (...args: any[]) => void): number;
  121608. }
  121609. interface HTMLCanvasElement {
  121610. requestPointerLock(): void;
  121611. msRequestPointerLock?(): void;
  121612. mozRequestPointerLock?(): void;
  121613. webkitRequestPointerLock?(): void;
  121614. /** Track wether a record is in progress */
  121615. isRecording: boolean;
  121616. /** Capture Stream method defined by some browsers */
  121617. captureStream(fps?: number): MediaStream;
  121618. }
  121619. interface CanvasRenderingContext2D {
  121620. msImageSmoothingEnabled: boolean;
  121621. }
  121622. interface MouseEvent {
  121623. mozMovementX: number;
  121624. mozMovementY: number;
  121625. webkitMovementX: number;
  121626. webkitMovementY: number;
  121627. msMovementX: number;
  121628. msMovementY: number;
  121629. }
  121630. interface Navigator {
  121631. mozGetVRDevices: (any: any) => any;
  121632. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121633. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121634. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121635. webkitGetGamepads(): Gamepad[];
  121636. msGetGamepads(): Gamepad[];
  121637. webkitGamepads(): Gamepad[];
  121638. }
  121639. interface HTMLVideoElement {
  121640. mozSrcObject: any;
  121641. }
  121642. interface Math {
  121643. fround(x: number): number;
  121644. imul(a: number, b: number): number;
  121645. }
  121646. interface WebGLRenderingContext {
  121647. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  121648. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  121649. vertexAttribDivisor(index: number, divisor: number): void;
  121650. createVertexArray(): any;
  121651. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  121652. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  121653. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  121654. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  121655. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  121656. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  121657. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  121658. // Queries
  121659. createQuery(): WebGLQuery;
  121660. deleteQuery(query: WebGLQuery): void;
  121661. beginQuery(target: number, query: WebGLQuery): void;
  121662. endQuery(target: number): void;
  121663. getQueryParameter(query: WebGLQuery, pname: number): any;
  121664. getQuery(target: number, pname: number): any;
  121665. MAX_SAMPLES: number;
  121666. RGBA8: number;
  121667. READ_FRAMEBUFFER: number;
  121668. DRAW_FRAMEBUFFER: number;
  121669. UNIFORM_BUFFER: number;
  121670. HALF_FLOAT_OES: number;
  121671. RGBA16F: number;
  121672. RGBA32F: number;
  121673. R32F: number;
  121674. RG32F: number;
  121675. RGB32F: number;
  121676. R16F: number;
  121677. RG16F: number;
  121678. RGB16F: number;
  121679. RED: number;
  121680. RG: number;
  121681. R8: number;
  121682. RG8: number;
  121683. UNSIGNED_INT_24_8: number;
  121684. DEPTH24_STENCIL8: number;
  121685. /* Multiple Render Targets */
  121686. drawBuffers(buffers: number[]): void;
  121687. readBuffer(src: number): void;
  121688. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  121689. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  121690. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  121691. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  121692. // Occlusion Query
  121693. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  121694. ANY_SAMPLES_PASSED: number;
  121695. QUERY_RESULT_AVAILABLE: number;
  121696. QUERY_RESULT: number;
  121697. }
  121698. interface WebGLProgram {
  121699. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  121700. }
  121701. interface EXT_disjoint_timer_query {
  121702. QUERY_COUNTER_BITS_EXT: number;
  121703. TIME_ELAPSED_EXT: number;
  121704. TIMESTAMP_EXT: number;
  121705. GPU_DISJOINT_EXT: number;
  121706. QUERY_RESULT_EXT: number;
  121707. QUERY_RESULT_AVAILABLE_EXT: number;
  121708. queryCounterEXT(query: WebGLQuery, target: number): void;
  121709. createQueryEXT(): WebGLQuery;
  121710. beginQueryEXT(target: number, query: WebGLQuery): void;
  121711. endQueryEXT(target: number): void;
  121712. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  121713. deleteQueryEXT(query: WebGLQuery): void;
  121714. }
  121715. interface WebGLUniformLocation {
  121716. _currentState: any;
  121717. }
  121718. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  121719. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  121720. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  121721. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121722. interface WebGLRenderingContext {
  121723. readonly RASTERIZER_DISCARD: number;
  121724. readonly DEPTH_COMPONENT24: number;
  121725. readonly TEXTURE_3D: number;
  121726. readonly TEXTURE_2D_ARRAY: number;
  121727. readonly TEXTURE_COMPARE_FUNC: number;
  121728. readonly TEXTURE_COMPARE_MODE: number;
  121729. readonly COMPARE_REF_TO_TEXTURE: number;
  121730. readonly TEXTURE_WRAP_R: number;
  121731. readonly HALF_FLOAT: number;
  121732. readonly RGB8: number;
  121733. readonly RED_INTEGER: number;
  121734. readonly RG_INTEGER: number;
  121735. readonly RGB_INTEGER: number;
  121736. readonly RGBA_INTEGER: number;
  121737. readonly R8_SNORM: number;
  121738. readonly RG8_SNORM: number;
  121739. readonly RGB8_SNORM: number;
  121740. readonly RGBA8_SNORM: number;
  121741. readonly R8I: number;
  121742. readonly RG8I: number;
  121743. readonly RGB8I: number;
  121744. readonly RGBA8I: number;
  121745. readonly R8UI: number;
  121746. readonly RG8UI: number;
  121747. readonly RGB8UI: number;
  121748. readonly RGBA8UI: number;
  121749. readonly R16I: number;
  121750. readonly RG16I: number;
  121751. readonly RGB16I: number;
  121752. readonly RGBA16I: number;
  121753. readonly R16UI: number;
  121754. readonly RG16UI: number;
  121755. readonly RGB16UI: number;
  121756. readonly RGBA16UI: number;
  121757. readonly R32I: number;
  121758. readonly RG32I: number;
  121759. readonly RGB32I: number;
  121760. readonly RGBA32I: number;
  121761. readonly R32UI: number;
  121762. readonly RG32UI: number;
  121763. readonly RGB32UI: number;
  121764. readonly RGBA32UI: number;
  121765. readonly RGB10_A2UI: number;
  121766. readonly R11F_G11F_B10F: number;
  121767. readonly RGB9_E5: number;
  121768. readonly RGB10_A2: number;
  121769. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  121770. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  121771. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  121772. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121773. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  121774. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  121775. 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;
  121776. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  121777. readonly TRANSFORM_FEEDBACK: number;
  121778. readonly INTERLEAVED_ATTRIBS: number;
  121779. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  121780. createTransformFeedback(): WebGLTransformFeedback;
  121781. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  121782. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  121783. beginTransformFeedback(primitiveMode: number): void;
  121784. endTransformFeedback(): void;
  121785. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  121786. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121787. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121788. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121789. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  121790. }
  121791. interface ImageBitmap {
  121792. readonly width: number;
  121793. readonly height: number;
  121794. close(): void;
  121795. }
  121796. interface WebGLQuery extends WebGLObject {
  121797. }
  121798. declare var WebGLQuery: {
  121799. prototype: WebGLQuery;
  121800. new(): WebGLQuery;
  121801. };
  121802. interface WebGLSampler extends WebGLObject {
  121803. }
  121804. declare var WebGLSampler: {
  121805. prototype: WebGLSampler;
  121806. new(): WebGLSampler;
  121807. };
  121808. interface WebGLSync extends WebGLObject {
  121809. }
  121810. declare var WebGLSync: {
  121811. prototype: WebGLSync;
  121812. new(): WebGLSync;
  121813. };
  121814. interface WebGLTransformFeedback extends WebGLObject {
  121815. }
  121816. declare var WebGLTransformFeedback: {
  121817. prototype: WebGLTransformFeedback;
  121818. new(): WebGLTransformFeedback;
  121819. };
  121820. interface WebGLVertexArrayObject extends WebGLObject {
  121821. }
  121822. declare var WebGLVertexArrayObject: {
  121823. prototype: WebGLVertexArrayObject;
  121824. new(): WebGLVertexArrayObject;
  121825. };
  121826. // Type definitions for WebVR API
  121827. // Project: https://w3c.github.io/webvr/
  121828. // Definitions by: six a <https://github.com/lostfictions>
  121829. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121830. interface VRDisplay extends EventTarget {
  121831. /**
  121832. * Dictionary of capabilities describing the VRDisplay.
  121833. */
  121834. readonly capabilities: VRDisplayCapabilities;
  121835. /**
  121836. * z-depth defining the far plane of the eye view frustum
  121837. * enables mapping of values in the render target depth
  121838. * attachment to scene coordinates. Initially set to 10000.0.
  121839. */
  121840. depthFar: number;
  121841. /**
  121842. * z-depth defining the near plane of the eye view frustum
  121843. * enables mapping of values in the render target depth
  121844. * attachment to scene coordinates. Initially set to 0.01.
  121845. */
  121846. depthNear: number;
  121847. /**
  121848. * An identifier for this distinct VRDisplay. Used as an
  121849. * association point in the Gamepad API.
  121850. */
  121851. readonly displayId: number;
  121852. /**
  121853. * A display name, a user-readable name identifying it.
  121854. */
  121855. readonly displayName: string;
  121856. readonly isConnected: boolean;
  121857. readonly isPresenting: boolean;
  121858. /**
  121859. * If this VRDisplay supports room-scale experiences, the optional
  121860. * stage attribute contains details on the room-scale parameters.
  121861. */
  121862. readonly stageParameters: VRStageParameters | null;
  121863. /**
  121864. * Passing the value returned by `requestAnimationFrame` to
  121865. * `cancelAnimationFrame` will unregister the callback.
  121866. * @param handle Define the hanle of the request to cancel
  121867. */
  121868. cancelAnimationFrame(handle: number): void;
  121869. /**
  121870. * Stops presenting to the VRDisplay.
  121871. * @returns a promise to know when it stopped
  121872. */
  121873. exitPresent(): Promise<void>;
  121874. /**
  121875. * Return the current VREyeParameters for the given eye.
  121876. * @param whichEye Define the eye we want the parameter for
  121877. * @returns the eye parameters
  121878. */
  121879. getEyeParameters(whichEye: string): VREyeParameters;
  121880. /**
  121881. * Populates the passed VRFrameData with the information required to render
  121882. * the current frame.
  121883. * @param frameData Define the data structure to populate
  121884. * @returns true if ok otherwise false
  121885. */
  121886. getFrameData(frameData: VRFrameData): boolean;
  121887. /**
  121888. * Get the layers currently being presented.
  121889. * @returns the list of VR layers
  121890. */
  121891. getLayers(): VRLayer[];
  121892. /**
  121893. * Return a VRPose containing the future predicted pose of the VRDisplay
  121894. * when the current frame will be presented. The value returned will not
  121895. * change until JavaScript has returned control to the browser.
  121896. *
  121897. * The VRPose will contain the position, orientation, velocity,
  121898. * and acceleration of each of these properties.
  121899. * @returns the pose object
  121900. */
  121901. getPose(): VRPose;
  121902. /**
  121903. * Return the current instantaneous pose of the VRDisplay, with no
  121904. * prediction applied.
  121905. * @returns the current instantaneous pose
  121906. */
  121907. getImmediatePose(): VRPose;
  121908. /**
  121909. * The callback passed to `requestAnimationFrame` will be called
  121910. * any time a new frame should be rendered. When the VRDisplay is
  121911. * presenting the callback will be called at the native refresh
  121912. * rate of the HMD. When not presenting this function acts
  121913. * identically to how window.requestAnimationFrame acts. Content should
  121914. * make no assumptions of frame rate or vsync behavior as the HMD runs
  121915. * asynchronously from other displays and at differing refresh rates.
  121916. * @param callback Define the eaction to run next frame
  121917. * @returns the request handle it
  121918. */
  121919. requestAnimationFrame(callback: FrameRequestCallback): number;
  121920. /**
  121921. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  121922. * Repeat calls while already presenting will update the VRLayers being displayed.
  121923. * @param layers Define the list of layer to present
  121924. * @returns a promise to know when the request has been fulfilled
  121925. */
  121926. requestPresent(layers: VRLayer[]): Promise<void>;
  121927. /**
  121928. * Reset the pose for this display, treating its current position and
  121929. * orientation as the "origin/zero" values. VRPose.position,
  121930. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  121931. * updated when calling resetPose(). This should be called in only
  121932. * sitting-space experiences.
  121933. */
  121934. resetPose(): void;
  121935. /**
  121936. * The VRLayer provided to the VRDisplay will be captured and presented
  121937. * in the HMD. Calling this function has the same effect on the source
  121938. * canvas as any other operation that uses its source image, and canvases
  121939. * created without preserveDrawingBuffer set to true will be cleared.
  121940. * @param pose Define the pose to submit
  121941. */
  121942. submitFrame(pose?: VRPose): void;
  121943. }
  121944. declare var VRDisplay: {
  121945. prototype: VRDisplay;
  121946. new(): VRDisplay;
  121947. };
  121948. interface VRLayer {
  121949. leftBounds?: number[] | Float32Array | null;
  121950. rightBounds?: number[] | Float32Array | null;
  121951. source?: HTMLCanvasElement | null;
  121952. }
  121953. interface VRDisplayCapabilities {
  121954. readonly canPresent: boolean;
  121955. readonly hasExternalDisplay: boolean;
  121956. readonly hasOrientation: boolean;
  121957. readonly hasPosition: boolean;
  121958. readonly maxLayers: number;
  121959. }
  121960. interface VREyeParameters {
  121961. /** @deprecated */
  121962. readonly fieldOfView: VRFieldOfView;
  121963. readonly offset: Float32Array;
  121964. readonly renderHeight: number;
  121965. readonly renderWidth: number;
  121966. }
  121967. interface VRFieldOfView {
  121968. readonly downDegrees: number;
  121969. readonly leftDegrees: number;
  121970. readonly rightDegrees: number;
  121971. readonly upDegrees: number;
  121972. }
  121973. interface VRFrameData {
  121974. readonly leftProjectionMatrix: Float32Array;
  121975. readonly leftViewMatrix: Float32Array;
  121976. readonly pose: VRPose;
  121977. readonly rightProjectionMatrix: Float32Array;
  121978. readonly rightViewMatrix: Float32Array;
  121979. readonly timestamp: number;
  121980. }
  121981. interface VRPose {
  121982. readonly angularAcceleration: Float32Array | null;
  121983. readonly angularVelocity: Float32Array | null;
  121984. readonly linearAcceleration: Float32Array | null;
  121985. readonly linearVelocity: Float32Array | null;
  121986. readonly orientation: Float32Array | null;
  121987. readonly position: Float32Array | null;
  121988. readonly timestamp: number;
  121989. }
  121990. interface VRStageParameters {
  121991. sittingToStandingTransform?: Float32Array;
  121992. sizeX?: number;
  121993. sizeY?: number;
  121994. }
  121995. interface Navigator {
  121996. getVRDisplays(): Promise<VRDisplay[]>;
  121997. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  121998. }
  121999. interface Window {
  122000. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122001. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122002. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122003. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122004. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122005. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122006. }
  122007. interface Gamepad {
  122008. readonly displayId: number;
  122009. }
  122010. interface XRDevice {
  122011. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  122012. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  122013. }
  122014. interface XRSession {
  122015. getInputSources(): Array<any>;
  122016. baseLayer: XRWebGLLayer;
  122017. requestFrameOfReference(type: string): Promise<void>;
  122018. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  122019. end(): Promise<void>;
  122020. requestAnimationFrame: Function;
  122021. addEventListener: Function;
  122022. }
  122023. interface XRSessionCreationOptions {
  122024. outputContext?: WebGLRenderingContext | null;
  122025. immersive?: boolean;
  122026. environmentIntegration?: boolean;
  122027. }
  122028. interface XRLayer {
  122029. getViewport: Function;
  122030. framebufferWidth: number;
  122031. framebufferHeight: number;
  122032. }
  122033. interface XRView {
  122034. projectionMatrix: Float32Array;
  122035. }
  122036. interface XRFrame {
  122037. getDevicePose: Function;
  122038. getInputPose: Function;
  122039. views: Array<XRView>;
  122040. baseLayer: XRLayer;
  122041. }
  122042. interface XRFrameOfReference {
  122043. }
  122044. interface XRWebGLLayer extends XRLayer {
  122045. framebuffer: WebGLFramebuffer;
  122046. }
  122047. declare var XRWebGLLayer: {
  122048. prototype: XRWebGLLayer;
  122049. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122050. };